-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
49 lines (41 loc) · 1.55 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
{ compiler ? "ghc922"
, doStatic ? false
, ...
}:
let
## Import sources:
sources = import ./nix/sources.nix;
## Import nixpkgs:
pkgs = import sources.nixpkgs { };
## Import rrclone:
rrclone = import sources.rrclone;
## Get the haskell set:
haskell = pkgs.haskell.packages.${compiler};
## Define a function that makes deback statically compiled:
makeDebackStatic = drv: pkgs.haskell.lib.compose.overrideCabal
(_: {
enableSharedExecutables = false;
enableSharedLibraries = false;
configureFlags = [
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-L${pkgs.gmp6.override { withStatic = true; }}/lib"
"--ghc-option=-optl=-L${pkgs.zlib.static}/lib"
"--ghc-option=-optl=-L${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
];
})
drv;
## Define a function that makes deback installable in Nix environment with all its dependencies:
makeDebackInstallable = drv: drv.overrideAttrs (oldAttrs: rec {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [
pkgs.makeWrapper
];
postFixup = (oldAttrs.postFixup or "") + ''
wrapProgram $out/bin/deback --prefix PATH : ${pkgs.lib.makeBinPath [ rrclone pkgs.autorestic pkgs.cryptsetup pkgs.rclone pkgs.restic pkgs.smartmontools ]}
'';
});
## Get raw deback:
deback = haskell.callCabal2nixWithOptions "deback" ./. "--no-haddock" { };
in
if doStatic then makeDebackStatic deback else makeDebackInstallable deback