-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathflake.nix
85 lines (78 loc) · 2.52 KB
/
flake.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
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
{
description = "Shrinkwrap and freeze the dynamic dependencies of binaries.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ poetry2nix.overlay (import ./overlay.nix) ];
};
runCodeAnalysis = name: command:
pkgs.runCommand "shrinkwrap-${name}-check" { } ''
cd ${self}
${command}
mkdir $out
'';
in
{
packages = {
shrinkwrap = pkgs.shrinkwrap;
};
legacyPackages = {
experiments = {
emacs = pkgs.dockerTools.buildImage {
name = "shrinkwrap-emacs-experiment";
contents = [
pkgs.strace
pkgs.emacs
pkgs.shrinkwrap
pkgs.bashInteractive
pkgs.binutils
pkgs.patchelf
];
runAsRoot = ''
# this directory does not exist and is needed by shrinkwrap
mkdir /dev/fd
shrinkwrap ${pkgs.emacs}/bin/.emacs-27.2-wrapped -o /bin/emacs-stamped
'';
};
};
};
checks = {
pytest-check = runCodeAnalysis "pytest" ''
${pkgs.shrinkwrap-env}/bin/pytest -p no:cacheprovider .
'';
black-check = runCodeAnalysis "black" ''
${pkgs.shrinkwrap-env}/bin/black --check .
'';
mypy-check = runCodeAnalysis "mypy" ''
${pkgs.shrinkwrap-env}/bin/mypy .
'';
isort-check = runCodeAnalysis "isort" ''
${pkgs.shrinkwrap-env}/bin/isort -c .
'';
flake8-check = runCodeAnalysis "flake8" ''
${pkgs.shrinkwrap-env}/bin/flake8 .
'';
nixpkgs-fmt-check = runCodeAnalysis "nixpkgs-fmt" ''
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check .
'';
};
defaultPackage = pkgs.shrinkwrap;
devShell = pkgs.shrinkwrap-env.env.overrideAttrs (old: {
nativeBuildInputs = with pkgs;
old.nativeBuildInputs ++ [ poetry nixpkgs-fmt nix-linter ];
});
});
}