-
Notifications
You must be signed in to change notification settings - Fork 27
/
vaultenv.nix
90 lines (81 loc) · 2.44 KB
/
vaultenv.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
86
87
88
89
90
{ haskellPackages
, mkDerivation
, lib
, pkgs
, glibcLocales
, nix-gitignore
}:
let
dependencies = import ./nix/haskell-dependencies.nix haskellPackages;
in
mkDerivation {
pname = "vaultenv";
version = "0.17.0";
src =
let
# We do not want to include all files, because that leads to a lot of things that nix
# has to copy to the temporary build directory that we don't want to have in there
# (e.g. the `.stack-work` directory, the `.git` directory, etc.)
prefixWhitelist = builtins.map builtins.toString [
./package.yaml
# Blanket-include for subdirectories
./app
./src
./test
];
# Compute source based on whitelist
whitelistedSrc = lib.cleanSourceWith {
src = lib.cleanSource ./.;
filter = path: _type: lib.any (prefix: lib.hasPrefix prefix path) prefixWhitelist;
};
rootGitignoredSrc = lib.cleanSourceWith {
src = whitelistedSrc;
filter =
let
gitignore = builtins.readFile ./.gitignore;
extraFilter = path: type:
# Where we're going we don't need no documentation
! (lib.hasSuffix ".md" path);
in
nix-gitignore.gitignoreFilterPure extraFilter gitignore ./.;
};
testGitignoredSrc = lib.cleanSourceWith {
src = rootGitignoredSrc;
filter =
let
gitignore = builtins.readFile ./test/.gitignore;
in
nix-gitignore.gitignoreFilter gitignore ./test;
};
in
testGitignoredSrc;
configureFlags = [
# Do not print a wall of text before compiling
"--verbose=0"
# Treat warnings as errors
"--ghc-option=-Werror"
];
isLibrary = false;
isExecutable = true;
buildTools = [ haskellPackages.hpack glibcLocales ];
preConfigure = ''
# Generate the cabal file from package.yaml
hpack .
'';
postInstall = ''
# By default, a Haskell derivation contains extra stuff that causes the output to retain
# a dependency on GHC and other build tools. Those are not necessary for running the
# executable, so we get rid of that.
rm -rf $out/lib
'';
# Disable features that we don't need
enableLibraryProfiling = false;
doHoogle = false;
doHaddock = false;
# Always run the unit tests
doCheck = false;
testToolDepends = [];
libraryHaskellDepends = dependencies;
librarySystemDepends = [ glibcLocales ];
license = lib.licenses.bsd3;
}