-
Notifications
You must be signed in to change notification settings - Fork 265
/
flake.nix
141 lines (133 loc) · 4.5 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{
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.follows = "haskellNix/nixpkgs-unstable";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
haskellNix,
nixpkgs-unstable,
}:
flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system: let
versions = {
ghc = "928";
ormolu = "0.5.2.0";
hls = "2.4.0.0";
stack = "2.13.1";
hpack = "0.35.2";
};
overlays = [
haskellNix.overlay
(import ./nix/haskell-nix-overlay.nix)
(import ./nix/unison-overlay.nix)
];
pkgs = import nixpkgs {
inherit system overlays;
inherit (haskellNix) config;
};
haskell-nix-flake = import ./nix/haskell-nix-flake.nix {
inherit pkgs versions;
inherit (nixpkgs-packages) stack hpack;
};
unstable = import nixpkgs-unstable {
inherit system;
overlays = [
(import ./nix/unison-overlay.nix)
(import ./nix/nixpkgs-overlay.nix {inherit versions;})
];
};
nixpkgs-packages = let
hpkgs = unstable.haskell.packages.ghcunison;
exe = unstable.haskell.lib.justStaticExecutables;
in {
ghc = unstable.haskell.compiler."ghc${versions.ghc}";
ormolu = exe hpkgs.ormolu;
hls = unstable.unison-hls;
stack = unstable.unison-stack;
unwrapped-stack = unstable.stack;
hpack = unstable.hpack;
};
nixpkgs-devShells = {
only-tools-nixpkgs = unstable.mkShell {
name = "only-tools-nixpkgs";
buildInputs = let
build-tools = with nixpkgs-packages; [
ghc
ormolu
hls
stack
hpack
];
native-packages =
pkgs.lib.optionals pkgs.stdenv.isDarwin
(with unstable.darwin.apple_sdk.frameworks; [Cocoa]);
c-deps = with unstable; [pkg-config zlib glibcLocales];
in
build-tools ++ c-deps ++ native-packages;
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.zlib}/lib:$LD_LIBRARY_PATH
'';
};
};
renameAttrs = fn:
nixpkgs.lib.mapAttrs' (name: value: {
inherit value;
name = fn name;
});
in
assert nixpkgs-packages.ormolu.version == versions.ormolu;
assert nixpkgs-packages.hls.version == versions.hls;
assert nixpkgs-packages.unwrapped-stack.version == versions.stack;
assert nixpkgs-packages.hpack.version == versions.hpack; {
packages =
nixpkgs-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;
build-tools = pkgs.symlinkJoin {
name = "build-tools";
paths = self.devShells."${system}".only-tools-nixpkgs.buildInputs;
};
all = pkgs.symlinkJoin {
name = "all";
paths = let
all-other-packages = builtins.attrValues (builtins.removeAttrs self.packages."${system}" ["all" "build-tools"]);
devshell-inputs =
builtins.concatMap
(devShell: devShell.buildInputs ++ devShell.nativeBuildInputs)
[
self.devShells."${system}".only-tools-nixpkgs
];
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 =
nixpkgs-devShells
// renameAttrs (name: "cabal-${name}") haskell-nix-flake.devShells
// {default = self.devShells."${system}".only-tools-nixpkgs;};
checks = renameAttrs (name: "component-${name}") haskell-nix-flake.checks;
formatter = pkgs.alejandra;
});
}