-
Notifications
You must be signed in to change notification settings - Fork 271
/
flake.nix
100 lines (93 loc) · 3.4 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
90
91
92
93
94
95
96
97
98
99
100
{
description = "Unison";
nixConfig = {
extra-substituters = ["https://unison.cachix.org"];
extra-trusted-public-keys = ["unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k="];
};
inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs-haskellNix.follows = "haskellNix/nixpkgs-unstable";
nixpkgs-release.url = "github:NixOS/nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
haskellNix,
nixpkgs-haskellNix,
nixpkgs-release,
flake-utils,
}:
flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system: let
## It’s much easier to read from a JSON file than to have JSON import from some other file, so we extract some
## configuration from the VS Code settings to avoid duplication.
vscodeSettings = nixpkgs-release.lib.importJSON ./.vscode/settings.json;
versions =
vscodeSettings."haskell.toolchain"
## There are some things we want to pin that the VS Code Haskell extension doesn’t let us control.
// {
hpack = "0.35.2";
ormolu = "0.7.2.0";
};
pkgs = import nixpkgs-haskellNix {
inherit system;
inherit (haskellNix) config;
overlays = [
haskellNix.overlay
(import ./nix/dependencies.nix {inherit nixpkgs-release;})
];
};
unison-project = import ./nix/unison-project.nix {
inherit (nixpkgs-haskellNix) lib;
inherit (pkgs) haskell-nix;
};
haskell-nix-flake = import ./nix/haskell-nix-flake.nix {
inherit pkgs unison-project versions;
inherit (nixpkgs-haskellNix) lib;
};
renameAttrs = fn:
nixpkgs-haskellNix.lib.mapAttrs' (name: value: {
inherit value;
name = fn name;
});
in
assert pkgs.stack.version == versions.stack;
assert pkgs.hpack.version == versions.hpack; {
packages =
renameAttrs (name: "component-${name}") haskell-nix-flake.packages
// renameAttrs (name: "docker-${name}") (import ./nix/docker.nix {
inherit pkgs;
haskell-nix = haskell-nix-flake.packages;
})
// {
default = haskell-nix-flake.defaultPackage;
all = pkgs.symlinkJoin {
name = "all";
paths = let
all-other-packages =
builtins.attrValues (builtins.removeAttrs self.packages."${system}" [
"all"
"docker-ucm" # this package doesn’t produce a directory
]);
devshell-inputs =
builtins.concatMap
(devShell: devShell.buildInputs ++ devShell.nativeBuildInputs)
(builtins.attrValues self.devShells."${system}");
in
all-other-packages ++ devshell-inputs;
};
};
apps =
renameAttrs (name: "component-${name}") haskell-nix-flake.apps
// {default = self.apps."${system}"."component-unison-cli-main:exe:unison";};
devShells =
renameAttrs (name: "cabal-${name}") haskell-nix-flake.devShells
// {default = self.devShells."${system}".cabal-local;};
checks = renameAttrs (name: "component-${name}") haskell-nix-flake.checks;
formatter = pkgs.alejandra;
});
}