Skip to content

Commit 19933d8

Browse files
committed
Refactor Nix files
Move everything to release.nix to have a single source of truth
1 parent 7fe4edc commit 19933d8

3 files changed

Lines changed: 38 additions & 20 deletions

File tree

default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
with (import ./pypi2nixpkgs/nixpkgs.nix) {};
2-
python3.pkgs.faradaysec
1+
# Running nix-build will build will build Faraday using the current directory
2+
# as source. Untracked or modified files will be used
3+
(import ./release.nix { useLastCommit = false; }).faraday-server

release.nix

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,39 @@ with (import ./pypi2nixpkgs/nixpkgs.nix) { };
22
let
33
version = builtins.head (builtins.match ".*'([0-9]+.[0-9]+(.[0-9]+)?)'.*"
44
(builtins.readFile ./faraday/__init__.py));
5+
6+
product = if builtins.pathExists ./pypi2nixpkgs_black then
7+
"corp"
8+
else if builtins.pathExists ./pypi2nixpkgs_pink then
9+
"pro"
10+
else
11+
"community";
12+
513
in { dockerName ? "registry.gitlab.com/faradaysec/faraday", dockerTag ? version
6-
}: {
14+
15+
# If true, will ignore the contents of the last commit as source, ignoring
16+
# uncommited changes. Recommended to improve reproducibility
17+
, useLastCommit ? true }: rec {
18+
19+
faraday-server = python3.pkgs.faradaysec.overrideAttrs (old:
20+
{
21+
doCheck = true;
22+
checkPhase = "true";
23+
checkInputs = with python3.pkgs; [
24+
pylint
25+
factory_boy
26+
pytest
27+
pytest-factoryboy
28+
responses
29+
hypothesis
30+
sphinx
31+
pytestcov
32+
];
33+
} // lib.optionalAttrs useLastCommit { src = builtins.fetchGit ./.; });
34+
735
dockerImage = dockerTools.buildImage {
8-
name = "registry.gitlab.com/faradaysec/faraday";
9-
tag = version;
36+
name = dockerName;
37+
tag = dockerTag;
1038
created = "now";
1139
fromImage = null;
1240
contents = [ python3.pkgs.faradaysec bash gnused coreutils ];
@@ -27,7 +55,10 @@ in { dockerName ? "registry.gitlab.com/faradaysec/faraday", dockerTag ? version
2755
} . # Not required, but useful for debug
2856
cp ${coreutils}/bin/env usr/bin/env
2957
ln -s ${python3.pkgs.faradaysec} opt/faraday
30-
ln -s /home/faraday/.faraday/doc faraday-license # Not useful in Community version
58+
${
59+
lib.optionalString (product != "community")
60+
"ln -s /home/faraday/.faraday/doc faraday-license"
61+
}
3162
ln -s /home/faraday/.faraday/storage faraday-storage
3263
ln -s /home/faraday/.faraday/config faraday-config
3364
'';

shell.nix

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)