-
Notifications
You must be signed in to change notification settings - Fork 9
/
flake.nix
89 lines (80 loc) · 2.8 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
86
87
88
89
{
description =
"Foliage is a tool to create custom Haskell package repositories, in a fully reproducible way.";
inputs = {
nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
haskell-nix.url = "github:input-output-hk/haskell.nix";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, flake-utils, haskell-nix, ... }:
let
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
in
flake-utils.lib.eachSystem systems (system:
let
pkgs = import nixpkgs {
inherit system;
inherit (haskell-nix) config;
overlays = [ haskell-nix.overlay ];
};
inherit (pkgs) lib;
project = pkgs.haskell-nix.cabalProject' {
src = ./.;
compiler-nix-name = "ghc948";
shell.tools = {
cabal = "latest";
hlint = "latest";
haskell-language-server = "latest";
fourmolu = "0.14.0.0";
};
modules = [{
# Wrap executables with the needed dependencies in PATH. See #71.
packages.foliage.postInstall = ''
for exe in $(find $out/bin -type f -executable); do
wrapProgram "$exe" \
--prefix PATH : ${with pkgs; lib.makeBinPath [ coreutils curl gnutar gitMinimal patch ]}
done
'';
}];
};
flake = project.flake (
lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ crossPlatforms = p: [ p.musl64 ]; }
);
in
flake // {
inherit project;
apps =
flake.apps
// { default = flake.apps."foliage:exe:foliage"; }
# Expose the derivation for a static executable as "static"
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.apps."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = flake.apps."aarch64-multiplatform-musl:foliage:exe:foliage"; }
;
packages =
flake.packages
// { default = flake.packages."foliage:exe:foliage"; }
# Expose the derivation for a static executable as "static"
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.packages."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = flake.packages."aarch64-multiplatform-musl:foliage:exe:foliage"; }
;
}
);
nixConfig = {
extra-substituters = [
"https://cache.iog.io"
];
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
};
}