-
Notifications
You must be signed in to change notification settings - Fork 6
/
overlay.nix
383 lines (353 loc) · 11.4 KB
/
overlay.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
final: prev:
let
isCross = final.stdenv.buildPlatform != final.stdenv.hostPlatform;
crossOnly = pkg : amendFn : if isCross then (amendFn pkg) else pkg;
extraPkgs = import ./pkgs/default.nix {
inherit (final) lib callPackage;
};
inherit (final) fetchpatch lib;
luaHost =
let
l = prev.lua5_3.overrideAttrs(o: {
name = "lua-tty";
preBuild = ''
makeFlagsArray+=(PLAT="posix" SYSLIBS="-Wl,-E -ldl" CFLAGS="-O2 -fPIC -DLUA_USE_POSIX -DLUA_USE_DLOPEN")
'';
# lua in nixpkgs has a postInstall stanza that assumes only
# one output, we need to override that if we're going to
# convert to multi-output
# outputs = ["bin" "man" "out"];
makeFlags =
builtins.filter (x: (builtins.match "(PLAT|MYLIBS).*" x) == null)
o.makeFlags;
});
in l.override { self = l; };
s6 = prev.s6.overrideAttrs(o:
let
patch = fetchpatch {
# add "p" directive in s6-log
url = "https://github.com/skarnet/s6/commit/ddc76841398dfd5e18b22943727ad74b880236d3.patch";
hash = "sha256-fBtUinBdp5GqoxgF6fcR44Tu8hakxs/rOShhuZOgokc=";
};
patch_needed = builtins.compareVersions o.version "2.11.1.2" <= 0;
in {
configureFlags = (builtins.filter
(x: (builtins.match ".*shared.*" x) == null)
o.configureFlags) ++
[
"--disable-allstatic"
"--disable-static"
"--enable-shared"
];
hardeningDisable = ["all"];
stripAllList = [ "sbin" "bin" ];
patches =
(if o ? patches then o.patches else []) ++
(if patch_needed then [ patch ] else []);
});
in
extraPkgs // {
# liminix library functions
lim = {
parseInt = s: (builtins.fromTOML "r=${s}").r;
orEmpty = x: if x != null then x else [];
};
# keep these alphabetical
btrfs-progs = crossOnly prev.btrfs-progs (
d: d.override {
udevSupport = false;
udev = null;
}
);
chrony =
let chrony' = prev.chrony.overrideAttrs(o: {
configureFlags = [
"--chronyvardir=$(out)/var/lib/chrony"
"--disable-readline"
"--disable-editline"
];
});
in chrony'.override {
gnutls = null;
libedit = null;
libseccomp = null;
# should texinfo be in nativeBuildInputs instead of
# buildInputs?
texinfo = null;
} // lib.optionalAttrs (lib.versionOlder lib.version "24.10") {
nss = null;
nspr = null;
readline = null;
};
# clevis without luks/tpm
clevis = crossOnly prev.clevis
(d: let c = d.overrideAttrs(o: {
outputs = ["out"];
preConfigure = ''
rm -rf src/luks
sed -i -e '/luks/d' src/meson.build
'';
}); in c.override {
asciidoc = null;
cryptsetup = null;
luksmeta = null;
tpm2-tools = null;
});
# luarocks wants a cross-compiled cmake (which seems like a bug,
# we're never going to run luarocks on the device, but ...)
# but https://github.com/NixOS/nixpkgs/issues/284734
# so we do surgery on the cmake derivation until that's fixed
cmake = crossOnly prev.cmake
(d: d.overrideAttrs(o: {
preConfigure =
builtins.replaceStrings
["$configureFlags"] ["$configureFlags $cmakeFlags"] o.preConfigure;
}
));
dnsmasq =
let d = prev.dnsmasq.overrideAttrs(o: {
preBuild = ''
makeFlagsArray=("COPTS=")
'';
});
in d.override {
dbusSupport = false;
nettle = null;
};
dropbear = crossOnly prev.dropbear
(d: d.overrideAttrs (o: rec {
version = "2024.85";
src = final.fetchurl {
url = "https://matt.ucc.asn.au/dropbear/releases/dropbear-${version}.tar.bz2";
sha256 = "sha256-hrA2xDOmnYnOUeuuM11lxHc4zPkNE+XrD+qDLlVtpQI=";
};
patches =
# need to update nixpkgs patch for new version of dropbear
let passPath = final.runCommand "pass-path" {} ''
sed < ${builtins.head o.patches} -e 's,svr-chansession.c,src/svr-chansession.c,g' > $out
'';
in [
passPath
./pkgs/dropbear/add-authkeyfile-option.patch
];
postPatch = ''
(echo '#define DSS_PRIV_FILENAME "/run/dropbear/dropbear_dss_host_key"'
echo '#define RSA_PRIV_FILENAME "/run/dropbear/dropbear_rsa_host_key"'
echo '#define ECDSA_PRIV_FILENAME "/run/dropbear/dropbear_ecdsa_host_key"'
echo '#define ED25519_PRIV_FILENAME "/run/dropbear/dropbear_ed25519_host_key"') > localoptions.h
'';
}));
elfutils = crossOnly prev.elfutils
(d: let e = d.overrideAttrs(o: {
configureFlags = o.configureFlags ++[
"ac_cv_has_stdatomic=no"
];
});
in e.override {
enableDebuginfod = false;
});
hostapd =
let
config = [
"CONFIG_DRIVER_NL80211=y"
"CONFIG_IAPP=y"
"CONFIG_IEEE80211AC=y"
"CONFIG_IEEE80211AX=y"
"CONFIG_IEEE80211N=y"
"CONFIG_IEEE80211W=y"
"CONFIG_INTERNAL_LIBTOMMATH=y"
"CONFIG_INTERNAL_LIBTOMMATH_FAST=y"
"CONFIG_IPV6=y"
"CONFIG_LIBNL32=y"
"CONFIG_PKCS12=y"
"CONFIG_RSN_PREAUTH=y"
"CONFIG_TLS=internal"
];
h = prev.hostapd.overrideAttrs(o: {
extraConfig = "";
configurePhase = ''
cat > hostapd/defconfig <<EOF
${builtins.concatStringsSep "\n" config}
EOF
${o.configurePhase}
'';
});
in h.override { openssl = null; sqlite = null; };
# berlekey db needs libatomic which we haven't figured out yet.
# disabling it means we don't have arpd
iproute2 = crossOnly prev.iproute2 (d: d.override { db = null; });
kexec-tools-static = prev.kexec-tools.overrideAttrs(o: {
# For kexecboot we copy kexec into a ramdisk on the system being
# upgraded from. This is more likely to work if kexec is
# statically linked so doesn't have dependencies on store paths that
# may not exist on that machine. (We can't nix-copy-closure as
# the store may not be on a writable filesystem)
LDFLAGS = "-static";
patches = o.patches ++ [
(fetchpatch {
# merge user command line options into DTB chosen
url = "https://patch-diff.githubusercontent.com/raw/horms/kexec-tools/pull/3.patch";
hash = "sha256-MvlJhuex9dlawwNZJ1sJ33YPWn1/q4uKotqkC/4d2tk=";
})
pkgs/kexec-map-file.patch
];
});
lua = crossOnly prev.lua5_3 (_: luaHost);
luaossl' = luaHost.pkgs.luaossl.overrideAttrs(o: {
patches = [
(fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/wahern/luaossl/pull/218.patch";
hash = "sha256-2GOliY4/RUzOgx3rqee3X3szCdUVxYDut7d+XFcUTJw=";
})
] ++ final.lib.optionals (o ? patches) o.patches;
});
mtdutils = prev.mtdutils.overrideAttrs(o: {
patches = (if o ? patches then o.patches else []) ++ [
./pkgs/mtdutils/0001-mkfs.jffs2-add-graft-option.patch
];
});
nftables = prev.nftables.overrideAttrs(o: {
configureFlags = [
"--disable-debug"
"--disable-python"
"--with-mini-gmp"
"--without-cli"
];
});
openssl = crossOnly prev.openssl
(d: d.overrideAttrs (o:
with final; {
# we want to apply
# https://patch-diff.githubusercontent.com/raw/openssl/openssl/pull/20273.patch";
# which disables overriding the -march cflags to the wrong values,
# but openssl is used for bootstrapping so that's easier said than
# done. Do it the ugly way..
postPatch =
o.postPatch
+ ''
sed -i.bak 's/linux.*-mips/linux-mops/' Configure
'';
# openssl with threads requires stdatomic which drags in libgcc
# as a dependency
configureFlags = ["no-threads"] ++ o.configureFlags;
# don't need or want this bash script
postInstall = o.postInstall + "rm $bin/bin/c_rehash\n";
}
));
pppBuild = prev.ppp;
qemuLim =
let
inherit (final) lib;
q = prev.qemu.overrideAttrs (o: {
patches = o.patches ++ [
./pkgs/qemu/arm-image-friendly-load-addr.patch
(final.fetchpatch {
url = "https://lore.kernel.org/qemu-devel/[email protected]/raw";
hash = "sha256-jOsGka7xLkJznb9M90v5TsJraXXTAj84lcphcSxjYLU=";
})
];
});
overrides = {
nixosTestRunner = true;
hostCpuTargets = map (f: "${f}-softmmu") [
"arm" "aarch64" "mips" "mipsel"
];
sdlSupport = false;
numaSupport = false;
seccompSupport = false;
usbredirSupport = false;
libiscsiSupport = false;
tpmSupport = false;
uringSupport = false;
capstoneSupport = false;
} // lib.optionalAttrs (lib.versionOlder lib.version "24.10") {
texinfo = null;
};
in q.override overrides;
rsyncSmall =
let
r = prev.rsync.overrideAttrs (o: {
configureFlags = o.configureFlags ++ [ "--disable-openssl" ];
});
in
r.override { openssl = null; };
inherit s6;
s6-linux-init = prev.s6-linux-init.override {
skawarePackages = prev.skawarePackages // {
inherit s6;
};
};
s6-rc = prev.s6-rc.override {
skawarePackages = prev.skawarePackages // {
inherit s6;
};
};
strace = prev.strace.override { libunwind = null; };
ubootQemuAarch64 = final.buildUBoot {
defconfig = "qemu_arm64_defconfig";
extraMeta.platforms = [ "aarch64-linux" ];
filesToInstall = [ "u-boot.bin" ];
};
ubootQemuArm = final.buildUBoot {
defconfig = "qemu_arm_defconfig";
extraMeta.platforms = [ "armv7l-linux" ];
filesToInstall = [ "u-boot.bin" ];
extraConfig = ''
CONFIG_CMD_UBI=y
CONFIG_CMD_UBIFS=y
CONFIG_BOOTSTD=y
CONFIG_BOOTMETH_DISTRO=y
CONFIG_LZMA=y
CONFIG_CMD_LZMADEC=y
CONFIG_SYS_BOOTM_LEN=0x1000000
'';
};
ubootQemuMips = final.buildUBoot {
defconfig = "malta_defconfig";
extraMeta.platforms = [ "mips-linux" ];
filesToInstall = [ "u-boot.bin" ];
# define the prompt to be the same as arm{32,64} so
# we can use the same expect script for both
extraPatches = [ ./pkgs/u-boot/0002-virtio-init-for-malta.patch ];
extraConfig = ''
CONFIG_SYS_PROMPT="=> "
CONFIG_VIRTIO=y
CONFIG_AUTOBOOT=y
CONFIG_DM_PCI=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_NET=y
CONFIG_VIRTIO_BLK=y
CONFIG_VIRTIO_MMIO=y
CONFIG_QFW_MMIO=y
CONFIG_FIT=y
CONFIG_LZMA=y
CONFIG_CMD_LZMADEC=y
CONFIG_SYS_BOOTM_LEN=0x1000000
CONFIG_SYS_MALLOC_LEN=0x400000
CONFIG_MIPS_BOOT_FDT=y
CONFIG_OF_LIBFDT=y
CONFIG_OF_STDOUT_VIA_ALIAS=y
'';
};
libusb1 = crossOnly prev.libusb1 (
d: let u = d.overrideAttrs(o: {
# don't use gcc libatomic because it vastly increases the
# closure size
preConfigure = "sed -i.bak /__atomic_fetch_add_4/c\: configure.ac";
});
in u.override {
enableUdev = false;
withDocs = false;
});
util-linux-small = prev.util-linux.override {
ncursesSupport = false;
pamSupport = false;
systemdSupport = false;
nlsSupport = false;
translateManpages = false;
capabilitiesSupport = false;
};
xl2tpd = prev.xl2tpd.overrideAttrs(o: {
patches = [ ./pkgs/xl2tpd-exit-on-close.patch ];
});
}