-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflake.nix
222 lines (216 loc) · 12.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
{
description = "Minimal devshell flake for haskell";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix/angerman-patch-3";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
inputs.flake-utils.url = "github:hamishmack/flake-utils/hkm/nested-hydraJobs";
inputs.iohk-nix.url = "github:input-output-hk/iohk-nix";
outputs = { self, nixpkgs, flake-utils, haskellNix, iohk-nix }:
let overlays = {
inherit (iohk-nix.overlays) crypto;
# add static-$pkg for a few packages to be able to pull them im explicitly.
static-libs = (final: prev: {
static-libsodium-vrf = final.libsodium-vrf.overrideDerivation (old: {
configureFlags = old.configureFlags ++ [ "--disable-shared" ];
});
static-secp256k1 = final.secp256k1.overrideDerivation (old: {
configureFlags = old.configureFlags ++ ["--enable-static" "--disable-shared" ];
});
static-gmp = (final.gmp.override { withStatic = true; }).overrideDerivation (old: {
configureFlags = old.configureFlags ++ ["--enable-static" "--disable-shared" ];
});
static-openssl = (final.openssl.override { static = true; });
static-zlib = final.zlib.override { shared = false; };
static-pcre = final.pcre.override { shared = false; };
});
# the haskell inline-r package depends on internals of the R
# project that have been hidden in R 4.2+. See
# https://github.com/tweag/HaskellR/issues/374
oldR = (final: prev: {
R_4_1_3 = final.R.overrideDerivation (old: rec {
version = "4.1.3";
patches = []; # upstream patches will most likely break this build, as they are specific to a different version.
src = final.fetchurl {
url = "https://cran.r-project.org/src/base/R-${final.lib.versions.major version}/${old.pname}-${version}.tar.gz";
sha256 = "sha256-Ff9bMzxhCUBgsqUunB2OxVzELdAp45yiKr2qkJUm/tY="; };
});
});
cddl-tools = (final: prev: {
cbor-diag = final.callPackage ./pkgs/cbor-diag { };
cddl = final.callPackage ./pkgs/cddl { };
});
};
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
in flake-utils.lib.eachSystem supportedSystems (system:
let
pkgs = import nixpkgs {
overlays = [haskellNix.overlay] ++ builtins.attrValues overlays;
inherit system;
inherit (haskellNix) config;
};
# These are for checking IOG projects build in an environment
# without haskell packages built by haskell.nix.
#
# Usage:
#
# nix develop github:input-output-hk/devx#ghc924 --no-write-lock-file -c cabal build
#
devShellsWithToolsModule = toolsModule:
let compilers = pkgs: builtins.removeAttrs pkgs.haskell-nix.compiler
# Exclude old versions of GHC to speed up `nix flake check`
[ "ghc844"
"ghc861" "ghc862" "ghc863" "ghc864" "ghc865"
"ghc881" "ghc882" "ghc883" "ghc884"
"ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc810420210212"
"ghc901"
"ghc921" "ghc922" "ghc923" "ghc924" "ghc925" "ghc926" "ghc927"
"ghc941" "ghc942" "ghc943" "ghc944"
"ghc96020230302"
"ghc961"
];
js-compilers = pkgs: builtins.removeAttrs (compilers pkgs)
[
"ghc902"
"ghc928"
"ghc945"
];
windows-compilers = pkgs:
pkgs.lib.optionalAttrs (__elem system ["x86_64-linux" "x86_64-darwin"])
(builtins.removeAttrs (compilers pkgs)
[
]);
static-pkgs = if pkgs.stdenv.hostPlatform.isLinux
then if pkgs.stdenv.hostPlatform.isAarch64
then pkgs.pkgsCross.aarch64-multiplatform-musl
else pkgs.pkgsCross.musl64
else pkgs;
js-pkgs = pkgs.pkgsCross.ghcjs;
windows-pkgs = pkgs.pkgsCross.mingwW64;
in (builtins.mapAttrs (compiler-nix-name: compiler:
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withIOG = false; }
) (compilers pkgs)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-minimal" (
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = false; }
)) (compilers pkgs)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-static" (
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withIOG = false; }
)) (compilers static-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-static-minimal" (
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = false; }
)) (compilers static-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-js" (
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; }
)) (js-compilers js-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-js-minimal" (
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; }
)) (js-compilers js-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-windows" (
import ./cross-windows.nix { pkgs = windows-pkgs; inherit self compiler compiler-nix-name; }
)) (windows-compilers windows-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-windows-minimal" (
import ./cross-windows.nix { pkgs = windows-pkgs; inherit self compiler compiler-nix-name; withHLS = false; withHlint = false; }
)) (windows-compilers windows-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-iog" (
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withIOG = true; }
)) (compilers pkgs)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-minimal-iog" (
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
)) (compilers pkgs)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-static-iog" (
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withIOG = true; }
)) (compilers static-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-static-minimal-iog" (
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
)) (compilers static-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-js-iog" (
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; withIOG = true; }
)) (js-compilers js-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-js-minimal-iog" (
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
)) (js-compilers js-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-windows-iog" (
import ./cross-windows.nix { pkgs = windows-pkgs; inherit self compiler compiler-nix-name; withIOG = true; }
)) (windows-compilers windows-pkgs.buildPackages)
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
pkgs.lib.nameValuePair "${compiler-nix-name}-windows-minimal-iog" (
import ./cross-windows.nix { pkgs = windows-pkgs; inherit self compiler compiler-nix-name; withHLS = false; withHlint = false; withIOG = true; }
)) (windows-compilers windows-pkgs.buildPackages)
);
devShells = devShellsWithToolsModule {};
# Eval must be done on linux when we use hydra to build environment
# scripts for other platforms. That way a linux GHA can download the
# cached files without needing access to the actual build platform.
devShellsWithEvalOnLinux = devShellsWithToolsModule { evalSystem = "x86_64-linux"; };
in {
inherit devShells;
hydraJobs = devShells //
(pkgs.lib.mapAttrs' (name: drv:
pkgs.lib.nameValuePair "${name}-env" (
let env = pkgs.runCommand "${name}-env.sh" {
requiredSystemFeatures = [ "recursive-nix" ];
nativeBuildInputs = [ pkgs.nix ];
} ''
nix --offline --extra-experimental-features "nix-command flakes" \
print-dev-env ${drv.drvPath} >> $out
'';
# this needs to be linux. It would be great if we could have this
# eval platform agnostic, but flakes don't permit this. A the
# platform where we build the docker images is linux (github
# ubuntu runners), this needs to be evaluable on linux.
in (import nixpkgs { system = "x86_64-linux"; }).writeTextFile {
name = "devx";
executable = true;
text = ''
#!/bin/bash
set -euo pipefail
source ${env}
source "$1"
'';
meta = {
description = "DevX shell";
longDescription = ''
The DevX shell is supposed to be used with GitHub Actions, and
can be used by setting the default shell to:
shell: devx {0}
'';
homepage = "https://github.com/input-output-hk/devx";
license = pkgs.lib.licenses.asl20;
platforms = pkgs.lib.platforms.unix;
};
})) devShellsWithEvalOnLinux) // {
};
});
# --- Flake Local Nix Configuration ----------------------------
nixConfig = {
extra-substituters = [
"https://cache.iog.io"
# We only have zw3rk cache in here, because it provide aarch64-linux and aarch64-darwin.
"https://cache.zw3rk.com"
];
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk="
];
# post-build-hook = "./upload-to-cache.sh";
allow-import-from-derivation = "true";
};
# --------------------------------------------------------------
}