mirror of
https://gitlab.com/TECHNOFAB/nixible.git
synced 2026-02-02 03:15:09 +01:00
chore: minor improvements like making inventory arg optional
This commit is contained in:
parent
4e6694ca64
commit
0a0d354962
2 changed files with 12 additions and 9 deletions
|
|
@ -152,11 +152,9 @@
|
||||||
};
|
};
|
||||||
optionsDoc = doclib.mkOptionDocs {
|
optionsDoc = doclib.mkOptionDocs {
|
||||||
module = {
|
module = {
|
||||||
|
_module.args.pkgs = pkgs;
|
||||||
imports = [
|
imports = [
|
||||||
nblib.module
|
nblib.module
|
||||||
{
|
|
||||||
_module.args.pkgs = pkgs;
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
roots = [
|
roots = [
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
unsetOr = typ:
|
unsetOr = typ:
|
||||||
(types.either unsetType typ)
|
(types.either unsetType typ)
|
||||||
// {
|
// {
|
||||||
description = typ.description;
|
inherit (typ) description getSubOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
filterUnset = value:
|
filterUnset = value:
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
mkOption args
|
mkOption args
|
||||||
// {
|
// {
|
||||||
type = unsetOr args.type;
|
type = unsetOr args.type;
|
||||||
default = unset;
|
default = args.default or unset;
|
||||||
defaultText = literalExpression "unset";
|
defaultText = literalExpression "unset";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
tasksType = types.submodule {
|
tasksType = types.submodule {
|
||||||
freeformType = types.attrsOf (types.attrsOf types.anything);
|
freeformType = types.attrsOf types.anything;
|
||||||
options = {
|
options = {
|
||||||
name = mkUnsetOption {
|
name = mkUnsetOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
|
@ -118,7 +118,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
playType = types.submodule {
|
playType = types.submodule {
|
||||||
freeformType = types.attrsOf (types.attrsOf types.anything);
|
freeformType = types.attrsOf types.anything;
|
||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
|
@ -278,12 +278,17 @@ in {
|
||||||
cli = pkgs.writeShellApplication {
|
cli = pkgs.writeShellApplication {
|
||||||
name = "nixible";
|
name = "nixible";
|
||||||
runtimeInputs = config.dependencies;
|
runtimeInputs = config.dependencies;
|
||||||
text = ''
|
text = let
|
||||||
|
inventoryStr =
|
||||||
|
if config.inventory != {}
|
||||||
|
then "-i ${config.inventoryFile}"
|
||||||
|
else "";
|
||||||
|
in ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export ANSIBLE_COLLECTIONS_PATH=${config.installedCollections}
|
export ANSIBLE_COLLECTIONS_PATH=${config.installedCollections}
|
||||||
|
|
||||||
git_repo=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
git_repo=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
||||||
${config.ansiblePackage}/bin/ansible-playbook -i ${config.inventoryFile} ${config.playbookFile} -e "pwd=$(pwd)" -e "git_root=$git_repo" "$@"
|
${config.ansiblePackage}/bin/ansible-playbook ${inventoryStr} ${config.playbookFile} -e "pwd=$(pwd)" -e "git_root=$git_repo" "$@"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue