Dear all,
the following code (for home-manager) gives me a python that has the kubernetes and hvac python modules available.
home.packages = with pkgs; [
ansible
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.hvac
python-pkgs.kubernetes
]))
];
(In my case today this is pointing to /nix/store/ipwx571dlhxmdf1n1yd8vgqq5ndjnxba-python3-3.12.8-env/bin/python3
)
The following snippet gives me a Ansible that find additional modules (like kubernetes and hvac):
packageOverrides = pkgs: {
ansible = pkgs.ansible.overrideAttrs (oldAttrs: {
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [
pkgs.python3Packages.hvac
pkgs.python3Packages.kubernetes
];
});
};
Is there a way to have ansible use that python (that has the modules available) as its python interpreter?
What I mean is: which ansible
points to a link in ~/.nix-profiles/bin/
which points to a bash script that calls a .ansible-wrapped
file, that has a shebang pointing to a python3.12 binary in the nix store:
$ head -1 /nix/store/0cbxbilzv11xs6fb2fnsn1zrizdmyjkq-python3.12-ansible-core-2.17.6/bin/.ansible-wrapped
/nix/store/lhpwdis5hkyljz1d200bj1s6g51ljq9k-python3-3.12.8/bin/python3.12
$
Is it possible to build the ansible package/derivation using the “python with modules” as a build input? So that the .ansible-wrapped
script (and thus Ansible) are using this python?
Using the first code snippet in the pkgs.ansible.overrideAttrs
only gives me Package duplicates found in closure
errors…
(My issue is that calling that python3.12 binary without the additional PATH-mangling done in the .ansible-wrapped
does not have the additional modules available. Which is needed as Ansible falls back to using “its own” python as interpreter in some cases. And then cannot find the modules it might need)
Kind Regards,
Johannes
P.S.: Yes, there has been a lot of discussion on this on a mastodon thread and I already got a lot of help there. But I am missing the last part of the puzzle.