Skip to content

Commit

Permalink
ansible-dev-shell: fix shell, add extraAnsiblePy argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Apr 26, 2024
1 parent f837fe2 commit 0df7349
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
6 changes: 5 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@
system = null;
}).config.system.build.toplevel;

ansibleDevShell = pkgs.mkAnsibleDevShell {};
ansibleDevShell = pkgs.mkAnsibleDevShell { };

ansibleDevShellExtra = pkgs.mkAnsibleDevShell {
extraAnsiblePy = [ "jmespath" ];
};
}
);

Expand Down
6 changes: 3 additions & 3 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
final: prev:
(prev.lib.mapAttrs (pkg: _: prev.callPackage "${./pkgs}/${pkg}" {}) (builtins.readDir ./pkgs)) // {
mkAnsibleDevShell = { packages ? [], ... }@args: final.mkShell args // {
mkAnsibleDevShell = { extraAnsiblePy ? [], packages ? [], ... }@args: final.mkShell (args // {
packages = with final; packages ++ [
ansible-mgit
(ansible-mgit.mkCustom extraAnsiblePy)
age
];
};
});
}
25 changes: 4 additions & 21 deletions pkgs/ansible-mgit/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{ ansible
, python3
, python3Packages
}:
{ callPackage }:

let
extraPy = ps: with ps; [
hcloud
cryptography
pyopenssl
];
py = python3.withPackages extraPy;
in
ansible.overrideAttrs (a: {
name = "${a.name}-MGIT";
# add missing hcloud dependency to ansible
propagatedBuildInputs = a.propagatedBuildInputs ++ (extraPy python3Packages);

preFixup = ''
makeWrapperArgs+=(--prefix PYTHONPATH : "${py}/${py.sitePackages}")
'';
})
(callPackage ./package.nix {}) // {
mkCustom = extraAnsiblePy: callPackage ./package.nix { inherit extraAnsiblePy; };
}
24 changes: 24 additions & 0 deletions pkgs/ansible-mgit/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ ansible
, python3
, python3Packages
, extraAnsiblePy ? []
}:

let
extraPy = ps: with ps; [
hcloud
cryptography
pyopenssl
] ++ (builtins.map (name: ps.${name}) extraAnsiblePy);

py = python3.withPackages extraPy;
in
ansible.overrideAttrs (a: {
name = "${a.name}-MGIT";
# add missing hcloud dependency to ansible
propagatedBuildInputs = a.propagatedBuildInputs ++ (extraPy python3Packages);

preFixup = ''
makeWrapperArgs+=(--prefix PYTHONPATH : "${py}/${py.sitePackages}")
'';
})

0 comments on commit 0df7349

Please sign in to comment.