-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
68 lines (55 loc) · 1.96 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
# based on https://discourse.nixos.org/t/another-simple-flake-for-haskell-development/18164
# TODO why can't the tests find git-annex? or are they just failing separately?
{
inputs = {
nixpkgs.url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/22.11.tar.gz";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
with nixpkgs.legacyPackages.${system}.pkgsStatic;
let
t = lib.trivial;
hl = haskell.lib;
name = "gander";
project = devTools:
let addBuildTools = (t.flip hl.addBuildTools) devTools;
in haskellPackages.developPackage {
root = lib.sourceFilesBySuffices ./. [ ".cabal" ".hs" ".txt" ];
name = name;
returnShellEnv = !(devTools == [ ]);
modifier = (t.flip t.pipe) [
addBuildTools
hl.dontHaddock
hl.enableStaticLibraries
hl.justStaticExecutables
hl.disableLibraryProfiling
hl.disableExecutableProfiling
];
};
in rec {
# empty devTools tells it to build the package
packages.pkg = project [ ];
# use `nix build` to build the static binary
defaultPackage = self.packages.${system}.pkg;
# use `nix build .#docker` to build the docker image
# TODO is it missing something? how can it be smaller than the binary?
packages.docker = pkgs.dockerTools.buildImage {
name = "gander";
config = {
Cmd = [ "${packages.pkg}/bin/gander" ];
};
};
executableSystemDepends = [
gitAndTools.git
gitAndTools.gitAnnex
rsync
];
devShell = project (executableSystemDepends ++ (with haskellPackages; [
cabal-fmt
cabal-install
haskell-language-server
hlint
]));
});
}