-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
201 lines (172 loc) · 6.29 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{
description = "A flake containing useful tools for building Elm applications with Nix.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
elm-spa = {
url = "github:jeslie0/elm-spa";
inputs.nixpkgs.follows = "nixpkgs";
};
elm-watch = {
url = "github:jeslie0/elm-watch";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, elm-spa, elm-watch }:
let
supportedSystems =
[ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
forAllSystems =
nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
});
allPackagesJsonPath =
./mkElmDerivation/all-packages.json;
elmHashesJsonPath =
./mkElmDerivation/elm-hashes.json;
snapshot =
system: import ./src/snapshot/default.nix (nixpkgsFor.${system}.haskellPackages // { lib = nixpkgsFor.${system}.lib; });
homepage =
"https://github.com/jeslie0/mkElmDerivation";
changelog =
"https://github.com/jeslie0/mkElmDerivation/blob/main/CHANGELOG.org";
mkElmDerivation = pkgs: with pkgs;
import ./nix/mkElmDerivation.nix {
inherit stdenv lib allPackagesJsonPath elmHashesJsonPath;
elm = elmPackages.elm;
uglify-js = nodePackages.uglify-js;
snapshot = snapshot system;
};
in
{
overlay =
builtins.trace "\"mkElmDerivation.overlay\" has been deprecated. Please use \"mkElmDerivation.overlays.mkElmDerivation\" instead." self.overlays.mkElmDerivation;
overlays = {
# The default overlay is the union of the other overlays in
# this flake.
default = final: prev:
prev.lib.composeManyExtensions
(builtins.attrValues
(builtins.removeAttrs self.overlays ["default"])
) final prev;
mkElmDerivation = final: prev: {
mkElmDerivation = mkElmDerivation prev;
};
mkElmSpaDerivation = final: prev: {
mkElmSpaDerivation = with prev;
import ./nix/mkElmSpaDerivation.nix {
inherit stdenv lib allPackagesJsonPath elmHashesJsonPath;
elm = elmPackages.elm;
elm-spa = elm-spa.packages.${system}.elmSpa;
snapshot = snapshot prev.system;
};
};
mkElmWatchDerivation = final: prev: {
mkElmWatchDerivation = with prev;
import ./nix/mkElmWatchDerivation.nix {
inherit allPackagesJsonPath elmHashesJsonPath lib stdenv;
elm-watch = elm-watch.packages.${system}.elm-watch;
snapshot = snapshot prev.system;
};
};
mkDotElmDirectoryCmd = final: prev: {
mkDotElmDirectoryCmd = with prev; (import ./nix/lib.nix {
inherit allPackagesJsonPath lib stdenv;
snapshot = snapshot prev.system;
}).mkDotElmCommand ./mkElmDerivation/elm-hashes.json;
};
};
packages =
forAllSystems
(system:
let
pkgs =
nixpkgsFor.${system};
haskellPackages =
pkgs.haskellPackages;
in
{
default = self.packages.${system}.elmHasher;
elmHasher =
(import ./src/elmHasher/default.nix (haskellPackages // { lib = pkgs.lib; }))
//
{
meta = {
description = "A program to fetch and hash all elm packages";
homepage = homepage;
changelog = changelog;
license = pkgs.lib.licenses.mit;
};
};
elmHashes =
pkgs.stdenvNoCC.mkDerivation {
name = "elmHashes";
src = ./mkElmDerivation;
installPhase = "mkdir $out; cp elm-hashes.json $out";
meta = {
description = "A JSON of elm packages and their hashes";
homepage = homepage;
changelog = changelog;
license = pkgs.lib.licenses.mit;
};
};
}
);
# These require IFD. Use these for development, but not
# for release. Run cabal2nix manually to update the
# default.nix files. One needs to add ellipses to the
# input attribute set in both these files.
# elmHasher = haskellPackages.callCabal2nix "elmHasher" ./src/elmHasher { };
# snapshot = haskellPackages.callCabal2nix "snapshot" ./src/snapshot { };
defaultPackage =
forAllSystems (system:
builtins.trace "defaultPackage has been deprecated. Please use packages.default." self.packages.${system}.default
);
checks =
forAllSystems (system:
let
pkgs =
nixpkgsFor.${system};
in
{
basic =
import ./tests/basic/default.nix {
mkElmDerivation = mkElmDerivation pkgs;
elm = pkgs.elmPackages.elm;
};
custom =
import ./tests/custom/default.nix {
mkElmDerivation = mkElmDerivation pkgs;
};
elm-optimize-level-2 =
import ./tests/elm-level-2/default.nix {
mkElmDerivation = mkElmDerivation pkgs;
elm-optimize-level-2 = pkgs.elmPackages.elm-optimize-level-2;
elm = pkgs.elmPackages.elm;
};
}
);
devShell =
forAllSystems (system:
let
pkgs =
nixpkgsFor.${system};
haskellPackages =
pkgs.haskellPackages;
in
haskellPackages.shellFor {
packages = p: [
self.packages.${system}.elmHasher
];
nativeBuildInputs = with haskellPackages;
[
# haskell-language-server
cabal-install
];
# Enables Hoogle for the builtin packages.
withHoogle = true;
}
);
};
}