|
61 | 61 | pypiDataSha256 = |
62 | 62 | "0499zl39aia74f0i7fkn5dsy8244dkmcw4vzd5nf4kai605j2jli"; |
63 | 63 | }); |
| 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 | + }; |
64 | 78 |
|
65 | 79 | in { |
66 | 80 |
|
67 | 81 | # A Nixpkgs overlay. |
68 | 82 | overlay = final: prev: |
69 | 83 | with final.pkgs; { |
70 | 84 |
|
71 | | - pythonEnv = machnixFor.${system}.mkPython { |
72 | | - requirements = '' |
73 | | - ${requirements} |
74 | | - ''; |
75 | | - }; |
| 85 | + pythonEnv = getPythonEnv system requirements; |
76 | 86 |
|
77 | 87 | vulnerablecode = stdenv.mkDerivation { |
78 | 88 | inherit version; |
79 | 89 | name = "vulnerablecode-${version}"; |
80 | 90 | src = vulnerablecode-src; |
81 | | - dontConfigure = true; # do not use ./configure |
| 91 | + dontBuild = true; # do not use Makefile |
82 | 92 | propagatedBuildInputs = [ pythonEnv postgresql gitMinimal ]; |
83 | 93 |
|
84 | 94 | postPatch = '' |
85 | | - # Make sure the pycodestyle binary in $PATH is used. |
86 | | - substituteInPlace vulnerabilities/tests/test_basics.py \ |
87 | | - --replace 'join(bin_dir, "pycodestyle")' '"pycodestyle"' |
| 95 | + # Do not use absolute path. |
| 96 | + substituteInPlace vulnerablecode/settings.py \ |
| 97 | + --replace 'STATIC_ROOT = "/var/vulnerablecode/static"' 'STATIC_ROOT = "./static"' |
88 | 98 | ''; |
89 | 99 |
|
90 | 100 | installPhase = '' |
|
117 | 127 | # Tests run by 'nix flake check' and by Hydra. |
118 | 128 | checks = forAllSystems (system: |
119 | 129 | let |
120 | | - pythonEnvDev = machnixFor.${system}.mkPython { |
121 | | - requirements = '' |
122 | | - ${requirements} |
123 | | - ${requirementsDev} |
124 | | - ''; |
125 | | - }; |
| 130 | + pythonEnvDev = getPythonEnv system '' |
| 131 | + ${requirements} |
| 132 | + ${requirementsDev} |
| 133 | + ''; |
126 | 134 |
|
127 | 135 | in { |
128 | 136 | inherit (self.packages.${system}) vulnerablecode; |
|
138 | 146 | buildPhase = '' |
139 | 147 | source ${libSh} |
140 | 148 | initPostgres $(pwd) |
| 149 | + export SECRET_KEY=REALLY_SECRET |
| 150 | + ${vulnerablecode}/manage.py collectstatic --no-input |
141 | 151 | ${vulnerablecode}/manage.py migrate |
142 | 152 | ''; |
143 | 153 |
|
|
0 commit comments