1{ 2 lib, 3 buildPythonPackage, 4 fetchPypi, 5 python, 6 pythonOlder, 7 installShellFiles, 8 docutils, 9 setuptools, 10 ansible, 11 cryptography, 12 jinja2, 13 junit-xml, 14 lxml, 15 ncclient, 16 packaging, 17 paramiko, 18 ansible-pylibssh, 19 pexpect, 20 psutil, 21 pycrypto, 22 pyyaml, 23 requests, 24 resolvelib, 25 scp, 26 windowsSupport ? false, 27 pywinrm, 28 xmltodict, 29 # Additional packages to add to dependencies 30 extraPackages ? _: [ ], 31}: 32 33buildPythonPackage rec { 34 pname = "ansible-core"; 35 # IMPORTANT: When bumping the minor version (2.XX.0 - the XX), please update pinned package in pkgs/top-level/all-packages.nix 36 # There are pinned packages called ansible_2_XX, create a new one with the previous minor version and then update the version here 37 version = "2.19.2"; 38 pyproject = true; 39 40 disabled = pythonOlder "3.12"; 41 42 src = fetchPypi { 43 pname = "ansible_core"; 44 inherit version; 45 hash = "sha256-h/y7xJLtFutq2wN5uuCtv2nzzoioRA5+iODc76n4pUw="; 46 }; 47 48 # ansible_connection is already wrapped, so don't pass it through 49 # the python interpreter again, as it would break execution of 50 # connection plugins. 51 postPatch = '' 52 patchShebangs --build packaging/cli-doc/build.py 53 54 SETUPTOOLS_PATTERN='"setuptools[0-9 <>=.,]+"' 55 WHEEL_PATTERN='"wheel[0-9 <>=.,]+"' 56 echo "Patching pyproject.toml" 57 # print replaced patterns to stdout 58 sed -r -i -e 's/'"$SETUPTOOLS_PATTERN"'/"setuptools"/w /dev/stdout' \ 59 -e 's/'"$WHEEL_PATTERN"'/"wheel"/w /dev/stdout' pyproject.toml 60 ''; 61 62 nativeBuildInputs = [ 63 installShellFiles 64 docutils 65 ]; 66 67 build-system = [ setuptools ]; 68 69 dependencies = [ 70 # depend on ansible instead of the other way around 71 ansible 72 # from requirements.txt 73 cryptography 74 jinja2 75 packaging 76 pyyaml 77 resolvelib 78 # optional dependencies 79 junit-xml 80 lxml 81 ncclient 82 paramiko 83 ansible-pylibssh 84 pexpect 85 psutil 86 pycrypto 87 requests 88 scp 89 xmltodict 90 ] 91 ++ lib.optionals windowsSupport [ pywinrm ] 92 ++ extraPackages python.pkgs; 93 94 pythonRelaxDeps = [ "resolvelib" ]; 95 96 postInstall = '' 97 export HOME="$(mktemp -d)" 98 packaging/cli-doc/build.py man --output-dir=man 99 installManPage man/* 100 ''; 101 102 # internal import errors, missing dependencies 103 doCheck = false; 104 105 meta = with lib; { 106 changelog = "https://github.com/ansible/ansible/blob/v${version}/changelogs/CHANGELOG-v${lib.versions.majorMinor version}.rst"; 107 description = "Radically simple IT automation"; 108 homepage = "https://www.ansible.com"; 109 license = licenses.gpl3Plus; 110 maintainers = with maintainers; [ 111 HarisDotParis 112 robsliwi 113 ]; 114 }; 115}