overlay.nix (13009B)
1 nixpkgs: final: prev: 2 let 3 isCross = final.stdenv.buildPlatform != final.stdenv.hostPlatform; 4 crossOnly = pkg: amendFn: if isCross then (amendFn pkg) else pkg; 5 extraPkgs = import ./pkgs/default.nix { 6 inherit (final) lib callPackage; 7 inherit nixpkgs; 8 }; 9 inherit (final) fetchpatch lib; 10 luaHost = 11 let 12 l = prev.lua5_3.overrideAttrs (o: { 13 name = "lua-tty"; 14 preBuild = '' 15 makeFlagsArray+=(PLAT="posix" SYSLIBS="-Wl,-E -ldl" CFLAGS="-O2 -fPIC -DLUA_USE_POSIX -DLUA_USE_DLOPEN") 16 ''; 17 # lua in nixpkgs has a postInstall stanza that assumes only 18 # one output, we need to override that if we're going to 19 # convert to multi-output 20 # outputs = ["bin" "man" "out"]; 21 makeFlags = builtins.filter (x: (builtins.match "(PLAT|MYLIBS).*" x) == null) o.makeFlags; 22 }); 23 in 24 l.override { 25 self = l; 26 packageOverrides = 27 lua-final: lua-prev: 28 let 29 openssl = final.opensslNoThreads; 30 in 31 { 32 cqueues = lua-prev.cqueues.overrideAttrs (o: { 33 externalDeps = [ 34 { 35 name = "CRYPTO"; 36 dep = openssl; 37 } 38 { 39 name = "OPENSSL"; 40 dep = openssl; 41 } 42 ]; 43 }); 44 luaossl = lua-prev.luaossl.overrideAttrs (o: { 45 externalDeps = [ 46 { 47 name = "CRYPTO"; 48 dep = openssl; 49 } 50 { 51 name = "OPENSSL"; 52 dep = openssl; 53 } 54 ]; 55 name = "${o.name}-218"; 56 patches = [ 57 (fetchpatch { 58 url = "https://patch-diff.githubusercontent.com/raw/wahern/luaossl/pull/218.patch"; 59 hash = "sha256-2GOliY4/RUzOgx3rqee3X3szCdUVxYDut7d+XFcUTJw="; 60 }) 61 ]; 62 preInstall = "rm src/openssl.c.orig ; chmod +w src/openssl.c"; 63 }); 64 }; 65 }; 66 67 s6 = prev.s6.overrideAttrs ( 68 o: 69 let 70 patch = fetchpatch { 71 # add "p" directive in s6-log 72 url = "https://github.com/skarnet/s6/commit/ddc76841398dfd5e18b22943727ad74b880236d3.patch"; 73 hash = "sha256-fBtUinBdp5GqoxgF6fcR44Tu8hakxs/rOShhuZOgokc="; 74 }; 75 patch_needed = builtins.compareVersions o.version "2.11.1.2" <= 0; 76 in 77 { 78 configureFlags = 79 (builtins.filter (x: (builtins.match ".*shared.*" x) == null) o.configureFlags) 80 ++ [ 81 "--disable-allstatic" 82 "--disable-static" 83 "--enable-shared" 84 ]; 85 hardeningDisable = [ "all" ]; 86 stripAllList = [ 87 "sbin" 88 "bin" 89 ]; 90 patches = (if o ? patches then o.patches else [ ]) ++ (if patch_needed then [ patch ] else [ ]); 91 } 92 ); 93 in 94 extraPkgs 95 // { 96 # liminix library functions 97 lim = { 98 parseInt = s: (builtins.fromTOML "r=${s}").r; 99 orEmpty = x: if x != null then x else [ ]; 100 }; 101 102 # keep these alphabetical 103 104 btrfs-progs = crossOnly prev.btrfs-progs ( 105 d: 106 d.override { 107 udevSupport = false; 108 udev = null; 109 } 110 ); 111 112 chrony = 113 let 114 chrony' = prev.chrony.overrideAttrs (o: { 115 configureFlags = [ 116 "--chronyvardir=$(out)/var/lib/chrony" 117 "--sbindir=$(out)/bin" 118 "--chronyrundir=/run/chrony" 119 "--disable-readline" 120 "--disable-editline" 121 ]; 122 }); 123 in 124 chrony'.override { 125 gnutls = null; 126 libedit = null; 127 libseccomp = null; 128 libcap = null; 129 } 130 // lib.optionalAttrs (lib.versionOlder lib.version "24.10") { 131 nss = null; 132 nspr = null; 133 readline = null; 134 }; 135 136 # clevis without luks/tpm 137 clevis = crossOnly prev.clevis ( 138 d: 139 let 140 c = d.overrideAttrs (o: { 141 outputs = [ "out" ]; 142 preConfigure = '' 143 rm -rf src/luks 144 sed -i -e '/luks/d' src/meson.build 145 ''; 146 }); 147 in 148 c.override { 149 asciidoc = null; 150 cryptsetup = null; 151 luksmeta = null; 152 tpm2-tools = null; 153 } 154 ); 155 156 dnsmasq = 157 let 158 d = prev.dnsmasq.overrideAttrs (o: { 159 preBuild = '' 160 makeFlagsArray=("COPTS=") 161 ''; 162 }); 163 in 164 d.override { 165 dbusSupport = false; 166 nettle = null; 167 }; 168 169 dropbear = crossOnly prev.dropbear ( 170 d: 171 d.overrideAttrs (o: rec { 172 patches = o.patches ++ [ 173 ./pkgs/dropbear/add-authkeyfile-option.patch 174 ]; 175 postPatch = '' 176 (echo '#define DSS_PRIV_FILENAME "/run/dropbear/dropbear_dss_host_key"' 177 echo '#define RSA_PRIV_FILENAME "/run/dropbear/dropbear_rsa_host_key"' 178 echo '#define ECDSA_PRIV_FILENAME "/run/dropbear/dropbear_ecdsa_host_key"' 179 echo '#define ED25519_PRIV_FILENAME "/run/dropbear/dropbear_ed25519_host_key"') > localoptions.h 180 ''; 181 }) 182 ); 183 184 elfutils = crossOnly prev.elfutils ( 185 d: 186 let 187 e = d.overrideAttrs (o: { 188 configureFlags = o.configureFlags ++ [ 189 "ac_cv_has_stdatomic=no" 190 ]; 191 nativeBuildInputs = [ 192 # upstream only includes this if enableDebuginfod is true, 193 # but seems it's now needed unconditionally 194 final.buildPackages.pkg-config 195 final.buildPackages.m4 196 ]; 197 }); 198 in 199 e.override { 200 enableDebuginfod = false; 201 } 202 ); 203 204 fennel = 205 let version = "1.6.1"; in 206 luaHost.pkgs.buildLuaPackage { 207 pname= "fennel"; 208 inherit version; 209 src = final.fetchFromSourcehut { 210 owner = "~technomancy"; 211 repo = "fennel"; 212 rev = version; 213 hash = "sha256-MLXLkRKlxqvEOogM5I4uHxnlRLjK8Pbeq9b1+kAgqFg="; 214 }; 215 nativeBuildInputs = [ final.pkgsBuildBuild.lua5_3 ]; 216 }; 217 218 hostapd = 219 let 220 config = [ 221 "CONFIG_DRIVER_NL80211=y" 222 "CONFIG_IAPP=y" 223 "CONFIG_IEEE80211AC=y" 224 "CONFIG_IEEE80211AX=y" 225 "CONFIG_IEEE80211N=y" 226 "CONFIG_IEEE80211W=y" 227 "CONFIG_INTERNAL_LIBTOMMATH=y" 228 "CONFIG_INTERNAL_LIBTOMMATH_FAST=y" 229 "CONFIG_IPV6=y" 230 "CONFIG_LIBNL32=y" 231 "CONFIG_PKCS12=y" 232 "CONFIG_RSN_PREAUTH=y" 233 "CONFIG_TLS=internal" 234 ]; 235 h = prev.hostapd.overrideAttrs (o: { 236 extraConfig = ""; 237 configurePhase = '' 238 cat > hostapd/defconfig <<EOF 239 ${builtins.concatStringsSep "\n" config} 240 EOF 241 ${o.configurePhase} 242 ''; 243 }); 244 in 245 h.override { 246 openssl = null; 247 sqlite = null; 248 }; 249 250 # berlekey db needs libatomic which we haven't figured out yet. 251 # disabling it means we don't have arpd 252 iproute2 = crossOnly prev.iproute2 (d: d.override { db = null; }); 253 254 kexec-tools-static = prev.kexec-tools.overrideAttrs (o: { 255 # For kexecboot we copy kexec into a ramdisk on the system being 256 # upgraded from. This is more likely to work if kexec is 257 # statically linked so doesn't have dependencies on store paths that 258 # may not exist on that machine. (We can't nix-copy-closure as 259 # the store may not be on a writable filesystem) 260 LDFLAGS = "-static"; 261 262 patches = o.patches ++ [ 263 (fetchpatch { 264 # merge user command line options into DTB chosen 265 url = "https://patch-diff.githubusercontent.com/raw/horms/kexec-tools/pull/3.patch"; 266 hash = "sha256-MvlJhuex9dlawwNZJ1sJ33YPWn1/q4uKotqkC/4d2tk="; 267 }) 268 pkgs/kexec-map-file.patch 269 ]; 270 }); 271 272 libadwaita = prev.libadwaita.overrideAttrs (o: { 273 # tests fail with a message 274 # Gdk-DEBUG: error: XDG_RUNTIME_DIR is invalid or not set in the environment. 275 doCheck = false; 276 }); 277 278 lua = crossOnly prev.lua5_3 (_: luaHost); 279 luad = 280 let s = final.fetchFromGitea { 281 domain = "gti.telent.net"; 282 owner = "dan"; 283 repo= "luad"; 284 rev = "73efb4223387a64ae11490648b51c632a98e4737"; 285 hash = "sha256-gPIrqL5wDTkvkyTIBq6CJwzmEBvhfMBcVh9GYgCVohQ="; 286 }; 287 in (final.callPackage s { lua = luaHost; }) 288 .overrideAttrs(o: { 289 RUSTFLAGS = "-C prefer-dynamic"; 290 stripAllList = [ "bin" ]; 291 }); 292 293 mtdutils = 294 (prev.mtdutils.overrideAttrs (o: { 295 296 src = final.fetchgit { 297 url = "git://git.infradead.org/mtd-utils.git"; 298 rev = "77981a2888c711268b0e7f32af6af159c2288e23"; 299 hash = "sha256-pHunlPOuvCRyyk9qAiR3Kn3cqS/nZHIxsv6m4nsAcbk="; 300 }; 301 302 patches = (if o ? patches then o.patches else [ ]) ++ [ 303 ./pkgs/mtdutils/0001-mkfs.jffs2-add-graft-option.patch 304 ]; 305 })).override 306 { util-linux = final.util-linux-small; }; 307 308 nftables = prev.nftables.overrideAttrs (o: { 309 configureFlags = [ 310 "--disable-debug" 311 "--disable-python" 312 "--with-mini-gmp" 313 "--without-cli" 314 ]; 315 }); 316 317 opensslNoThreads = prev.openssl.overrideAttrs ( 318 o: with final; { 319 pname = "${o.pname}-nothreads"; 320 # openssl with threads requires stdatomic which drags in libgcc 321 # as a dependency 322 preConfigure = 323 let 324 arch = if stdenv.hostPlatform.gcc ? arch then "-march=${stdenv.hostPlatform.gcc.arch}" else ""; 325 soft = if arch == "-march=24kc" then "-msoft-float" else ""; 326 in 327 '' 328 configureFlagsArray+=(no-threads no-asm CFLAGS="${arch} ${soft}") 329 ''; 330 # don't need or want this bash script 331 postInstall = o.postInstall + "rm $bin/bin/c_rehash\n"; 332 } 333 ); 334 335 pppBuild = prev.ppp; 336 337 qemuLim = 338 let 339 inherit (final) lib; 340 q = prev.qemu.overrideAttrs (o: { 341 patches = o.patches ++ [ 342 ./pkgs/qemu/arm-image-friendly-load-addr.patch 343 (final.fetchpatch { 344 url = "https://lore.kernel.org/qemu-devel/20220322154658.1687620-1-raj.khem@gmail.com/raw"; 345 hash = "sha256-jOsGka7xLkJznb9M90v5TsJraXXTAj84lcphcSxjYLU="; 346 }) 347 ]; 348 buildInputs = o.buildInputs ++ [ 349 final.libslirp 350 final.libtasn1 # https://github.com/NixOS/nixpkgs/issues/547163 351 ]; 352 }); 353 354 overrides = { 355 hostCpuTargets = map (f: "${f}-softmmu") [ 356 "arm" 357 "aarch64" 358 "mips" 359 "mipsel" 360 ]; 361 sdlSupport = false; 362 numaSupport = false; 363 seccompSupport = false; 364 usbredirSupport = false; 365 libiscsiSupport = false; 366 tpmSupport = false; 367 uringSupport = false; 368 capstoneSupport = false; 369 minimal = true; 370 }; 371 in 372 q.override overrides; 373 rsyncSmall = 374 let 375 r = prev.rsync.overrideAttrs (o: { 376 configureFlags = o.configureFlags ++ [ "--disable-openssl" ]; 377 }); 378 in 379 r.override { openssl = null; }; 380 381 inherit s6; 382 383 s6-rc = prev.s6-rc.override { 384 skawarePackages = prev.skawarePackages // { 385 inherit s6; 386 }; 387 }; 388 389 strace = prev.strace.override { libunwind = null; }; 390 391 ubootQemuAarch64 = final.buildUBoot { 392 defconfig = "qemu_arm64_defconfig"; 393 extraMeta.platforms = [ "aarch64-linux" ]; 394 filesToInstall = [ "u-boot.bin" ]; 395 }; 396 397 ubootQemuArm = final.buildUBoot { 398 defconfig = "qemu_arm_defconfig"; 399 extraMeta.platforms = [ "armv7l-linux" ]; 400 filesToInstall = [ "u-boot.bin" ]; 401 extraConfig = '' 402 CONFIG_CMD_UBI=y 403 CONFIG_CMD_UBIFS=y 404 CONFIG_BOOTSTD=y 405 CONFIG_BOOTMETH_DISTRO=y 406 CONFIG_LZMA=y 407 CONFIG_CMD_LZMADEC=y 408 CONFIG_SYS_BOOTM_LEN=0x1000000 409 ''; 410 }; 411 412 ubootQemuMips = final.buildUBoot { 413 defconfig = "malta_defconfig"; 414 extraMeta.platforms = [ "mips-linux" ]; 415 filesToInstall = [ "u-boot.bin" ]; 416 # define the prompt to be the same as arm{32,64} so 417 # we can use the same expect script for both 418 extraPatches = [ ./pkgs/u-boot/0002-virtio-init-for-malta.patch ]; 419 extraConfig = '' 420 CONFIG_SYS_PROMPT="=> " 421 CONFIG_VIRTIO=y 422 CONFIG_AUTOBOOT=y 423 CONFIG_DM_PCI=y 424 CONFIG_VIRTIO_PCI=y 425 CONFIG_VIRTIO_NET=y 426 CONFIG_VIRTIO_BLK=y 427 CONFIG_VIRTIO_MMIO=y 428 CONFIG_QFW_MMIO=y 429 CONFIG_FIT=y 430 CONFIG_LZMA=y 431 CONFIG_CMD_LZMADEC=y 432 CONFIG_SYS_BOOTM_LEN=0x1000000 433 CONFIG_SYS_MALLOC_LEN=0x400000 434 CONFIG_MIPS_BOOT_FDT=y 435 CONFIG_OF_LIBFDT=y 436 CONFIG_OF_STDOUT_VIA_ALIAS=y 437 ''; 438 }; 439 440 libusb1 = crossOnly prev.libusb1 ( 441 d: 442 let 443 u = d.overrideAttrs (o: { 444 # don't use gcc libatomic because it vastly increases the 445 # closure size 446 preConfigure = "sed -i.bak /__atomic_fetch_add_4/c\: configure.ac"; 447 }); 448 in 449 u.override { 450 enableUdev = false; 451 withDocs = false; 452 } 453 ); 454 455 util-linux-small = prev.util-linux.override { 456 ncursesSupport = false; 457 pamSupport = false; 458 systemdSupport = false; 459 nlsSupport = false; 460 translateManpages = false; 461 capabilitiesSupport = false; 462 withLastlog = false; 463 shadowSupport = false; # transitively depends on systemd 464 }; 465 466 xl2tpd = prev.xl2tpd.overrideAttrs (o: { 467 patches = [ ./pkgs/xl2tpd-exit-on-close.patch ]; 468 }); 469 }