liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

overlay.nix (13574B)


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