-
Notifications
You must be signed in to change notification settings - Fork 33
/
flake.nix
154 lines (127 loc) · 6.75 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
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/22.05;
utils.url = github:numtide/flake-utils;
};
outputs = { nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
let withCompiler = compiler:
let overlay = pkgsNew: pkgsOld: {
haskell = pkgsOld.haskell // {
packages = pkgsOld.haskell.packages // {
"${compiler}" = pkgsOld.haskell.packages."${compiler}".override (old: {
overrides =
let
oldOverrides = old.overrides or (_: _: {});
manualOverrides = haskellPackagesNew: haskellPackagesOld: {
ghcjs-fetch =
pkgsNew.haskell.lib.addBuildDepend
(pkgsNew.haskell.lib.doJailbreak
(pkgsNew.haskell.lib.dontCheck haskellPackagesOld.ghcjs-fetch)
)
[ haskellPackagesNew.ghcjs-base ];
grace =
let
drv =
pkgsNew.haskell.lib.overrideCabal
haskellPackagesOld.grace
(old: {
doCheck = false;
src =
pkgsNew.lib.cleanSourceWith
{ inherit (old) src;
filter = path: type:
pkgsNew.lib.cleanSourceFilter path type
&& (!((pkgsNew.lib.hasPrefix "result" (baseNameOf path) && type == "symlink")
|| (pkgsNew.lib.hasSuffix ".nix" (baseNameOf path) && type == "regular")
|| (pkgsNew.lib.hasSuffix ".md" (baseNameOf path) && type == "regular")
|| (baseNameOf path == "cabal.project.local" && type == "regular")
|| (baseNameOf path == "dist" && type == "directory")
|| (baseNameOf path == "dist-newstyle" && type == "directory")
|| (baseNameOf path == "examples" && type == "directory")
|| (baseNameOf path == "prelude" && type == "directory")
|| (baseNameOf path == "website" && type == "directory")
));
};
});
in
if compiler == "ghcjs"
then
pkgsNew.haskell.lib.overrideCabal drv
(old: {
postInstall = (old.postInstall or "") +
''
${pkgsNew.closurecompiler}/bin/closure-compiler $out/bin/try-grace.jsexe/all.js --jscomp_off=checkVars --externs=$out/bin/try-grace.jsexe/all.js.externs > $out/bin/try-grace.jsexe/all.min.js
'';
})
else
drv;
aeson = haskellPackagesNew.aeson_1_5_6_0;
haskeline = haskellPackagesNew.haskeline_0_8_2;
insert-ordered-containers =
pkgsNew.haskell.lib.dontCheck
haskellPackagesOld.insert-ordered-containers;
prettyprinter-ansi-terminal =
pkgsNew.haskell.lib.dontCheck
haskellPackagesOld.prettyprinter-ansi-terminal;
text-short =
pkgsNew.haskell.lib.dontCheck
haskellPackagesOld.text-short;
vector =
pkgsNew.haskell.lib.dontCheck haskellPackagesOld.vector;
};
sourceOverrides = pkgsNew.haskell.lib.packageSourceOverrides {
grace = ./.;
};
in
pkgsNew.lib.fold pkgsNew.lib.composeExtensions oldOverrides
( [ sourceOverrides ]
++ pkgsNew.lib.optional (compiler == "ghcjs") manualOverrides
);
});
};
};
website = pkgsNew.runCommand "try-grace" { } ''
mkdir -p $out/prelude
${pkgsNew.rsync}/bin/rsync --archive ${./website}/ $out
${pkgsNew.rsync}/bin/rsync --archive ${./prelude}/ $out/prelude
chmod -R u+w $out
cp ${pkgsNew.haskell.packages."${compiler}".grace}/bin/try-grace.jsexe/all.min.js $out/js
'';
};
config.allowBroken = true;
pkgs = import nixpkgs { inherit config system; overlays = [ overlay ]; };
grace = pkgs.haskell.packages."${compiler}".grace;
graceMinimal =
pkgs.haskell.lib.justStaticExecutables
(grace.overrideAttrs (_: { doCheck = false; }));
website = pkgs.website;
in
{ inherit grace graceMinimal website; };
withDefaultCompiler = withCompiler "ghc902";
withghcjs = withCompiler "ghcjs";
in
rec {
packages = {
default = withDefaultCompiler.graceMinimal;
website = withghcjs.website;
};
defaultPackage = packages.default;
apps.default = {
type = "app";
program = "${withDefaultCompiler.graceMinimal}/bin/grace";
};
defaultApp = apps.default;
devShells = {
default = withDefaultCompiler.grace.env;
ghcjs = withghcjs.grace.env;
};
devShell = devShells.default;
});
nixConfig = {
extra-substituters = [ "https://cache.garnix.io" ];
extra-trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
};
}