forked from Mic92/nixpkgs-review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
50 lines (46 loc) · 1.35 KB
/
default.nix
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
{ pkgs ? import <nixpkgs> { }
, withSandboxSupport ? false
}:
with pkgs;
python3.pkgs.buildPythonApplication rec {
name = "nixpkgs-review";
src = ./.;
buildInputs = [ makeWrapper ];
checkInputs = [
mypy
python3.pkgs.black
python3.pkgs.flake8
glibcLocales
# needed for interactive unittests
python3.pkgs.pytest
pkgs.nixVersions.stable or nix_2_4
git
];
checkPhase = ''
${if pkgs.lib.versionAtLeast python3.pkgs.black.version "20" then ''
echo -e "\x1b[32m## run black\x1b[0m"
LC_ALL=en_US.utf-8 black --check .
'' else ''
echo -e "\033[0;31mskip running black (version too old)\x1b[0m"
''}
echo -e "\x1b[32m## run flake8\x1b[0m"
flake8 .
echo -e "\x1b[32m## run mypy\x1b[0m"
mypy --strict nixpkgs_review
'';
makeWrapperArgs =
let
binPath = [ pkgs.nixVersions.stable or nix_2_4 git ]
++ lib.optional withSandboxSupport bubblewrap;
in
[
"--prefix PATH : ${lib.makeBinPath binPath}"
"--set 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"
];
shellHook = ''
# workaround because `python setup.py develop` breaks for me
'';
passthru.env = buildEnv { inherit name; paths = buildInputs ++ checkInputs; };
}