|
13 | 13 | type = "github"; |
14 | 14 | owner = "DavHau"; |
15 | 15 | repo = "mach-nix"; |
16 | | - ref = "235a0a81d05a043bca2a93442f2560946266fc73"; |
| 16 | + ref = "fe5255e6fd8df57e9507b7af82fc59dda9e9ff2b"; # 3.4.0 |
17 | 17 | }; |
18 | 18 |
|
19 | 19 | outputs = { self, nixpkgs, machnix }: |
|
29 | 29 | version = builtins.head (builtins.match ''.*version=["']?([^"',]+).*'' |
30 | 30 | (builtins.readFile (vulnerablecode-src + "/setup.py"))); |
31 | 31 |
|
32 | | - # Common shell code. |
33 | | - libSh = ./lib.sh; |
34 | | - |
35 | 32 | # System types to support. |
36 | 33 | supportedSystems = [ "x86_64-linux" ]; |
37 | 34 |
|
|
57 | 54 | # mach-nix release) is usually insufficient. Use |
58 | 55 | # ./get-latest-pypi-deps-db.sh to obtain the data rev & hash. |
59 | 56 | pypiDataRev = |
60 | | - "8dcec158c51f8a96f316630679222e436c1b078c"; # 2021-06-16T08:41:20Z |
| 57 | + "897a7471aa4e83aab21d2c501e00fee3f440e0fe"; # 2022-02-21T08:57:22Z |
61 | 58 | pypiDataSha256 = |
62 | | - "0499zl39aia74f0i7fkn5dsy8244dkmcw4vzd5nf4kai605j2jli"; |
| 59 | + "03gnaq687gg9afb6i6czw4kzr1gbnzna15lfb26f9nszyfq3iyaj"; |
| 60 | + |
63 | 61 | }); |
64 | 62 | # This wrapper allows to setup both the production as well as the |
65 | 63 | # development Python environments in the same way (albeit having |
|
69 | 67 | requirements = '' |
70 | 68 | ${requirements} |
71 | 69 | ''; |
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 | 70 | }; |
78 | 71 |
|
79 | 72 | in { |
|
91 | 84 | dontBuild = true; # do not use Makefile |
92 | 85 | propagatedBuildInputs = [ pythonEnv postgresql gitMinimal ]; |
93 | 86 |
|
94 | | - postPatch = '' |
95 | | - # Do not use absolute path. |
96 | | - substituteInPlace vulnerablecode/settings.py \ |
97 | | - --replace 'STATIC_ROOT = "/var/vulnerablecode/static"' 'STATIC_ROOT = "./static"' |
98 | | - ''; |
99 | | - |
100 | 87 | installPhase = '' |
101 | 88 | cp -r . $out |
102 | 89 | ''; |
|
144 | 131 | unpackPhase = "true"; |
145 | 132 |
|
146 | 133 | buildPhase = '' |
147 | | - source ${libSh} |
148 | | - initPostgres $(pwd) |
149 | | - export SECRET_KEY=REALLY_SECRET |
150 | | - ${vulnerablecode}/manage.py collectstatic --no-input |
151 | | - ${vulnerablecode}/manage.py migrate |
| 134 | + # Work on a local copy. |
| 135 | + cp -r ${vulnerablecode} ./vulnerablecode |
| 136 | + cd ./vulnerablecode |
| 137 | + chmod -R +w . |
| 138 | +
|
| 139 | + source ./etc/nix/lib.sh |
| 140 | +
|
| 141 | + setupDevEnv |
152 | 142 | ''; |
153 | 143 |
|
154 | 144 | doCheck = true; |
155 | 145 | checkPhase = '' |
156 | | - # Run pytest on the installed version. A running postgres |
157 | | - # database server is needed. |
158 | | - ( |
159 | | - cd ${vulnerablecode} |
160 | | - black -l 100 --check . |
161 | | - pytest -m "not webtest" |
162 | | - ) |
| 146 | + export PYTHON_EXE=${pythonEnvDev}/bin/python3 # use correct python |
| 147 | + make check |
| 148 | + make test |
163 | 149 |
|
164 | 150 | # Launch the webserver and call the API. |
165 | | - ${vulnerablecode}/manage.py runserver & |
| 151 | + make run & |
166 | 152 | sleep 2 |
167 | 153 | wget http://127.0.0.1:8000/api/ |
168 | 154 | kill %1 # kill background task (i.e. webserver) |
|
0 commit comments