mirror of
https://gitlab.com/TECHNOFAB/nixible.git
synced 2026-02-02 03:15:09 +01:00
feat: switch from flake-parts and devenv to rensa ecosystem
This commit is contained in:
parent
0a0d354962
commit
dcb87e8c3e
21 changed files with 649 additions and 652 deletions
|
|
@ -1,92 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
installShellFiles,
|
||||
docutils,
|
||||
setuptools,
|
||||
cryptography,
|
||||
jinja2,
|
||||
junit-xml,
|
||||
lxml,
|
||||
ncclient,
|
||||
packaging,
|
||||
paramiko,
|
||||
ansible-pylibssh,
|
||||
pexpect,
|
||||
psutil,
|
||||
pycrypto,
|
||||
pyyaml,
|
||||
requests,
|
||||
resolvelib,
|
||||
scp,
|
||||
windowsSupport ? false,
|
||||
pywinrm,
|
||||
xmltodict,
|
||||
}:
|
||||
buildPythonPackage rec {
|
||||
pname = "ansible-core";
|
||||
version = "2.19.2";
|
||||
pyproject = true;
|
||||
|
||||
src = fetchPypi {
|
||||
pname = "ansible_core";
|
||||
inherit version;
|
||||
hash = "sha256-h/y7xJLtFutq2wN5uuCtv2nzzoioRA5+iODc76n4pUw=";
|
||||
};
|
||||
|
||||
# ansible_connection is already wrapped, so don't pass it through
|
||||
# the python interpreter again, as it would break execution of
|
||||
# connection plugins.
|
||||
postPatch = ''
|
||||
patchShebangs --build packaging/cli-doc/build.py
|
||||
|
||||
SETUPTOOLS_PATTERN='"setuptools[0-9 <>=.,]+"'
|
||||
WHEEL_PATTERN='"wheel[0-9 <>=.,]+"'
|
||||
echo "Patching pyproject.toml"
|
||||
# print replaced patterns to stdout
|
||||
sed -r -i -e 's/'"$SETUPTOOLS_PATTERN"'/"setuptools"/w /dev/stdout' \
|
||||
-e 's/'"$WHEEL_PATTERN"'/"wheel"/w /dev/stdout' pyproject.toml
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
docutils
|
||||
];
|
||||
|
||||
build-system = [setuptools];
|
||||
|
||||
dependencies =
|
||||
[
|
||||
# from requirements.txt
|
||||
cryptography
|
||||
jinja2
|
||||
packaging
|
||||
pyyaml
|
||||
resolvelib
|
||||
# optional dependencies
|
||||
junit-xml
|
||||
lxml
|
||||
ncclient
|
||||
paramiko
|
||||
ansible-pylibssh
|
||||
pexpect
|
||||
psutil
|
||||
pycrypto
|
||||
requests
|
||||
scp
|
||||
xmltodict
|
||||
]
|
||||
++ lib.optionals windowsSupport [pywinrm];
|
||||
|
||||
pythonRelaxDeps = ["resolvelib"];
|
||||
|
||||
postInstall = ''
|
||||
export HOME="$(mktemp -d)"
|
||||
packaging/cli-doc/build.py man --output-dir=man
|
||||
installManPage man/*
|
||||
'';
|
||||
|
||||
# internal import errors, missing dependencies
|
||||
doCheck = false;
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
name = "unset";
|
||||
description = "unset";
|
||||
descriptionClass = "noun";
|
||||
check = value: true;
|
||||
check = value: isType "unset";
|
||||
};
|
||||
unset = {
|
||||
_type = "unset";
|
||||
|
|
@ -33,12 +33,18 @@
|
|||
else value;
|
||||
|
||||
mkUnsetOption = args:
|
||||
mkOption args
|
||||
// {
|
||||
type = unsetOr args.type;
|
||||
default = args.default or unset;
|
||||
defaultText = literalExpression "unset";
|
||||
};
|
||||
mkOption (args
|
||||
// {
|
||||
type = unsetOr args.type;
|
||||
default = args.default or unset;
|
||||
defaultText = literalExpression "unset";
|
||||
});
|
||||
# no "getSubOptions" here, otherwise its infinite recursion
|
||||
mkUnsetOptionNoSub = args:
|
||||
mkUnsetOption (args
|
||||
// {
|
||||
type = (types.either unsetType args.type) // {inherit (args.type) description;};
|
||||
});
|
||||
|
||||
collectionType = types.submodule {
|
||||
options = {
|
||||
|
|
@ -73,14 +79,14 @@
|
|||
Register the task's output to a variable.
|
||||
'';
|
||||
};
|
||||
block = mkUnsetOption {
|
||||
type = types.listOf tasksType;
|
||||
block = mkUnsetOptionNoSub {
|
||||
type = types.listOf (tasksType // {description = "tasksType";});
|
||||
description = ''
|
||||
A block of tasks to execute.
|
||||
'';
|
||||
};
|
||||
rescue = mkUnsetOption {
|
||||
type = types.listOf tasksType;
|
||||
rescue = mkUnsetOptionNoSub {
|
||||
type = types.listOf (tasksType // {description = "tasksType";});
|
||||
description = ''
|
||||
A list of tasks to execute on failure of block tasks.
|
||||
'';
|
||||
|
|
@ -189,9 +195,19 @@ in {
|
|||
options = {
|
||||
ansiblePackage = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.python3Packages.callPackage ./ansible-core.nix {};
|
||||
default = pkgs.ansible.overridePythonAttrs (before: {
|
||||
# filter out "ansible" (non-core) since its useless for nixible and just bloats stuff...
|
||||
dependencies = builtins.filter (el: el.pname != "ansible") before.dependencies;
|
||||
});
|
||||
defaultText = literalExpression ''
|
||||
pkgs.ansible.overridePythonAttrs (before: {
|
||||
dependencies = builtins.filter (el: el.pname != "ansible") before.dependencies;
|
||||
})
|
||||
'';
|
||||
description = ''
|
||||
The Ansible package to use. The default package is optimized for size, by not including the gazillion collections that pkgs.ansible and pkgs.ansible-core include.
|
||||
The Ansible package to use.
|
||||
The default package is optimized for size, by not including the gazillion collections that
|
||||
`pkgs.ansible` and `pkgs.ansible-core` include by default.
|
||||
'';
|
||||
example = literalExpression "pkgs.ansible";
|
||||
};
|
||||
|
|
@ -216,7 +232,7 @@ in {
|
|||
};
|
||||
playbook = mkOption {
|
||||
type = playbookType;
|
||||
apply = res: filterUnset res;
|
||||
# apply = res: filterUnset res;
|
||||
description = "The actual playbook, defined as a Nix data structure";
|
||||
example = [
|
||||
{
|
||||
|
|
@ -273,7 +289,7 @@ in {
|
|||
};
|
||||
config = {
|
||||
inventoryFile = (pkgs.formats.json {}).generate "inventory.json" config.inventory;
|
||||
playbookFile = (pkgs.formats.yaml {}).generate "playbook.yml" config.playbook;
|
||||
playbookFile = (pkgs.formats.yaml {}).generate "playbook.yml" (filterUnset config.playbook);
|
||||
installedCollections = pkgs.callPackage ./ansible-collections.nix {} config.ansiblePackage config.collections;
|
||||
cli = pkgs.writeShellApplication {
|
||||
name = "nixible";
|
||||
|
|
@ -283,13 +299,15 @@ in {
|
|||
if config.inventory != {}
|
||||
then "-i ${config.inventoryFile}"
|
||||
else "";
|
||||
in ''
|
||||
set -euo pipefail
|
||||
export ANSIBLE_COLLECTIONS_PATH=${config.installedCollections}
|
||||
in
|
||||
# sh
|
||||
''
|
||||
set -euo pipefail
|
||||
export ANSIBLE_COLLECTIONS_PATH=${config.installedCollections}
|
||||
|
||||
git_repo=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
||||
${config.ansiblePackage}/bin/ansible-playbook ${inventoryStr} ${config.playbookFile} -e "pwd=$(pwd)" -e "git_root=$git_repo" "$@"
|
||||
'';
|
||||
git_repo=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
||||
${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