Skip to content

Commit 4fa55ef

Browse files
committed
Refactor mkPython.
Signed-off-by: Rolf Schröder <rolf.schr@gmail.com>
1 parent 56a8ac9 commit 4fa55ef

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

etc/nix/flake.nix

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,28 @@
6161
pypiDataSha256 =
6262
"0499zl39aia74f0i7fkn5dsy8244dkmcw4vzd5nf4kai605j2jli";
6363
});
64+
# This wrapper allows to setup both the production as well as the
65+
# development Python environments in the same way (albeit having
66+
# different requirements.txt).
67+
getPythonEnv = system: requirements:
68+
machnixFor.${system}.mkPython {
69+
requirements = ''
70+
${requirements}
71+
'';
72+
# Fix an issue with an upstream dep of GitPython.
73+
# https://github.com/DavHau/mach-nix/issues/287
74+
# See https://github.com/DavHau/mach-nix/issues/318
75+
_.gitpython.propagatedBuildInputs.mod = pySelf: self: oldVal:
76+
oldVal ++ [ pySelf.typing-extensions ];
77+
};
6478

6579
in {
6680

6781
# A Nixpkgs overlay.
6882
overlay = final: prev:
6983
with final.pkgs; {
7084

71-
pythonEnv = machnixFor.${system}.mkPython {
72-
requirements = ''
73-
${requirements}
74-
'';
75-
};
85+
pythonEnv = getPythonEnv system requirements;
7686

7787
vulnerablecode = stdenv.mkDerivation {
7888
inherit version;
@@ -117,12 +127,10 @@
117127
# Tests run by 'nix flake check' and by Hydra.
118128
checks = forAllSystems (system:
119129
let
120-
pythonEnvDev = machnixFor.${system}.mkPython {
121-
requirements = ''
122-
${requirements}
123-
${requirementsDev}
124-
'';
125-
};
130+
pythonEnvDev = getPythonEnv system ''
131+
${requirements}
132+
${requirementsDev}
133+
'';
126134

127135
in {
128136
inherit (self.packages.${system}) vulnerablecode;

0 commit comments

Comments
 (0)