-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathdefault.nix
More file actions
99 lines (91 loc) · 2.44 KB
/
default.nix
File metadata and controls
99 lines (91 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
lib,
stdenv,
buildPlatform,
python3Packages,
nixVersions,
nix-eval-jobs,
git,
bash,
coreutils,
bubblewrap,
nix-output-monitor,
installShellFiles,
cacert,
ghc,
pkgsStatic,
path,
withSandboxSupport ? false,
withAutocomplete ? true,
withNom ? false,
}:
let
withNom' =
withNom
&& (builtins.tryEval (builtins.elem buildPlatform.system ghc.meta.platforms)).value or false;
in
python3Packages.buildPythonApplication {
name = "nixpkgs-review";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./pyproject.toml
./nixpkgs_review
./tests
];
};
format = "pyproject";
nativeBuildInputs = [
installShellFiles
python3Packages.setuptools
]
++ lib.optional withAutocomplete python3Packages.argcomplete;
dependencies = with python3Packages; [ argcomplete ];
nativeCheckInputs = [
# needed for interactive unittests
python3Packages.pytest
python3Packages.pytest-xdist
nixVersions.stable
nix-eval-jobs
git
]
++ lib.optional withSandboxSupport bubblewrap
++ lib.optional withNom' nix-output-monitor;
# Disable checks when building with sandbox support since bwrap doesn't work in build sandbox
doCheck = !withSandboxSupport;
checkPhase = ''
# Set up test dependencies
export TEST_BASH_PATH="${if stdenv.isLinux then pkgsStatic.bash else bash}"
export TEST_COREUTILS_PATH="${if stdenv.isLinux then pkgsStatic.coreutils else coreutils}"
export TEST_NIXPKGS_PATH="${path}"
# Run tests
python -m pytest tests/ -x
'';
makeWrapperArgs =
let
binPath = [
nixVersions.stable
nix-eval-jobs
git
]
++ lib.optional withSandboxSupport bubblewrap
++ lib.optional withNom' nix-output-monitor;
in
[
"--prefix PATH : ${lib.makeBinPath binPath}"
"--set-default NIX_SSL_CERT_FILE ${cacert}/etc/ssl/certs/ca-bundle.crt"
# we don't have any runtime deps but nix-review shells might inject unwanted dependencies
"--unset PYTHONPATH"
];
postInstall = lib.optionalString withAutocomplete ''
for cmd in nix-review nixpkgs-review; do
installShellCompletion --cmd $cmd \
--bash <(register-python-argcomplete $cmd) \
--fish <(register-python-argcomplete $cmd -s fish) \
--zsh <(register-python-argcomplete $cmd -s zsh)
done
'';
shellHook = ''
# workaround because `python setup.py develop` breaks for me
'';
}