2
0
Files
liminix/overlay.nix
T

425 lines
12 KiB
Nix
Raw Normal View History

2023-03-03 22:20:59 +00:00
final: prev:
2023-03-17 11:49:30 +00:00
let
isCross = final.stdenv.buildPlatform != final.stdenv.hostPlatform;
2025-02-10 21:55:08 +00:00
crossOnly = pkg: amendFn: if isCross then (amendFn pkg) else pkg;
2023-07-14 20:22:29 +01:00
extraPkgs = import ./pkgs/default.nix {
inherit (final) lib callPackage;
};
inherit (final) fetchpatch lib;
2024-10-03 22:58:57 +01:00
luaHost =
let
2025-02-10 21:55:08 +00:00
l = prev.lua5_3.overrideAttrs (o: {
2024-10-03 22:58:57 +01:00
name = "lua-tty";
preBuild = ''
makeFlagsArray+=(PLAT="posix" SYSLIBS="-Wl,-E -ldl" CFLAGS="-O2 -fPIC -DLUA_USE_POSIX -DLUA_USE_DLOPEN")
2025-02-10 21:55:08 +00:00
'';
2024-10-03 22:58:57 +01:00
# 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"];
2025-02-10 21:55:08 +00:00
makeFlags = builtins.filter (x: (builtins.match "(PLAT|MYLIBS).*" x) == null) o.makeFlags;
2024-10-03 22:58:57 +01:00
});
2025-02-10 21:55:08 +00:00
in
l.override { self = l; };
2023-04-22 23:03:36 +01:00
2025-02-10 21:55:08 +00:00
s6 = prev.s6.overrideAttrs (
o:
2023-04-22 23:03:36 +01:00
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;
2025-02-10 21:55:08 +00:00
in
{
configureFlags =
(builtins.filter (x: (builtins.match ".*shared.*" x) == null) o.configureFlags)
++ [
"--disable-allstatic"
"--disable-static"
"--enable-shared"
];
hardeningDisable = [ "all" ];
stripAllList = [
"sbin"
"bin"
2023-04-19 21:44:06 +01:00
];
2025-02-10 21:55:08 +00:00
patches = (if o ? patches then o.patches else [ ]) ++ (if patch_needed then [ patch ] else [ ]);
}
);
2023-03-03 22:20:59 +00:00
in
2025-02-10 21:55:08 +00:00
extraPkgs
// {
2023-12-02 17:08:59 +00:00
# liminix library functions
lim = {
2024-06-30 16:58:29 +01:00
parseInt = s: (builtins.fromTOML "r=${s}").r;
2025-02-10 21:55:08 +00:00
orEmpty = x: if x != null then x else [ ];
2023-12-02 17:08:59 +00:00
};
2023-04-10 20:04:23 +01:00
2023-12-02 17:08:59 +00:00
# keep these alphabetical
2024-01-04 09:33:44 +00:00
btrfs-progs = crossOnly prev.btrfs-progs (
2025-02-10 21:55:08 +00:00
d:
d.override {
udevSupport = false;
udev = null;
}
);
2024-01-04 09:33:44 +00:00
2023-06-19 21:37:06 +01:00
chrony =
2025-02-10 21:55:08 +00:00
let
chrony' = prev.chrony.overrideAttrs (o: {
configureFlags = [
"--chronyvardir=$(out)/var/lib/chrony"
"--disable-readline"
"--disable-editline"
];
});
in
chrony'.override {
2023-06-19 21:37:06 +01:00
gnutls = null;
2023-06-20 20:09:17 +01:00
libedit = null;
2023-06-19 21:37:06 +01:00
libseccomp = null;
2023-06-20 20:09:17 +01:00
# should texinfo be in nativeBuildInputs instead of
# buildInputs?
texinfo = null;
2025-02-10 21:55:08 +00:00
}
// lib.optionalAttrs (lib.versionOlder lib.version "24.10") {
nss = null;
nspr = null;
readline = null;
2023-06-20 20:09:17 +01:00
};
2023-04-18 23:57:15 +01:00
2024-08-15 23:02:54 +01:00
# clevis without luks/tpm
2025-02-10 21:55:08 +00:00
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;
}
);
2024-08-15 23:02:54 +01:00
2024-03-08 22:36:42 +00:00
# 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
2025-02-10 21:55:08 +00:00
cmake = crossOnly prev.cmake (
d:
d.overrideAttrs (o: {
2024-03-08 22:36:42 +00:00
preConfigure =
2025-02-10 21:55:08 +00:00
builtins.replaceStrings [ "$configureFlags" ] [ "$configureFlags $cmakeFlags" ]
o.preConfigure;
})
);
2023-03-04 23:08:25 +00:00
2022-10-08 20:05:17 +01:00
dnsmasq =
2025-02-10 21:55:08 +00:00
let
d = prev.dnsmasq.overrideAttrs (o: {
preBuild = ''
makeFlagsArray=("COPTS=")
'';
});
in
d.override {
2023-03-03 22:20:59 +00:00
dbusSupport = false;
nettle = null;
};
2025-02-10 21:55:08 +00:00
dropbear = crossOnly prev.dropbear (
d:
d.overrideAttrs (o: rec {
2024-08-23 19:57:10 +01:00
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
2025-02-10 21:55:08 +00:00
let
passPath = final.runCommand "pass-path" { } ''
sed < ${builtins.head o.patches} -e 's,svr-chansession.c,src/svr-chansession.c,g' > $out
'';
in
[
2024-08-23 19:57:10 +01:00
passPath
2024-08-23 19:58:05 +01:00
./pkgs/dropbear/add-authkeyfile-option.patch
2024-08-23 19:57:10 +01:00
];
postPatch = ''
2025-02-10 21:55:08 +00:00
(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
2024-08-23 19:57:10 +01:00
'';
2025-02-10 21:55:08 +00:00
})
);
2023-12-02 17:08:59 +00:00
2025-02-10 21:55:08 +00:00
elfutils = crossOnly prev.elfutils (
d:
let
e = d.overrideAttrs (o: {
configureFlags = o.configureFlags ++ [
"ac_cv_has_stdatomic=no"
];
});
in
e.override {
enableDebuginfod = false;
}
);
2023-04-22 22:17:35 +01:00
hostapd =
let
2025-02-10 21:55:08 +00:00
config = [
2023-04-22 22:17:35 +01:00
"CONFIG_DRIVER_NL80211=y"
"CONFIG_IAPP=y"
"CONFIG_IEEE80211AC=y"
2024-02-17 04:34:00 +01:00
"CONFIG_IEEE80211AX=y"
2023-04-22 22:17:35 +01:00
"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"
];
2025-02-10 21:55:08 +00:00
h = prev.hostapd.overrideAttrs (o: {
2023-04-22 22:17:35 +01:00
extraConfig = "";
configurePhase = ''
cat > hostapd/defconfig <<EOF
${builtins.concatStringsSep "\n" config}
EOF
${o.configurePhase}
'';
});
2025-02-10 21:55:08 +00:00
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; });
2025-02-10 21:55:08 +00:00
kexec-tools-static = prev.kexec-tools.overrideAttrs (o: {
2023-12-02 17:08:59 +00:00
# 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
];
});
2024-09-07 00:58:11 +01:00
lua = crossOnly prev.lua5_3 (_: luaHost);
2023-12-02 17:08:59 +00:00
2025-02-10 21:55:08 +00:00
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;
});
2025-02-10 21:55:08 +00:00
mtdutils =
(prev.mtdutils.overrideAttrs (o: {
patches = (if o ? patches then o.patches else [ ]) ++ [
./pkgs/mtdutils/0001-mkfs.jffs2-add-graft-option.patch
];
})).override
{ util-linux = final.util-linux-small; };
2023-12-02 17:08:59 +00:00
2025-02-10 21:55:08 +00:00
nftables = prev.nftables.overrideAttrs (o: {
2023-12-02 17:08:59 +00:00
configureFlags = [
"--disable-debug"
"--disable-python"
"--with-mini-gmp"
"--without-cli"
];
2023-03-04 00:39:54 +00:00
});
2025-02-10 21:55:08 +00:00
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;
2025-02-10 21:55:08 +00:00
# don't need or want this bash script
postInstall = o.postInstall + "rm $bin/bin/c_rehash\n";
}
2025-02-10 21:55:08 +00:00
)
);
2023-09-12 18:44:43 +01:00
2023-12-02 17:08:59 +00:00
pppBuild = prev.ppp;
2024-08-25 14:23:29 +01:00
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/20220322154658.1687620-1-raj.khem@gmail.com/raw";
hash = "sha256-jOsGka7xLkJznb9M90v5TsJraXXTAj84lcphcSxjYLU=";
})
];
});
2025-02-10 21:55:08 +00:00
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;
2023-12-02 17:08:59 +00:00
rsyncSmall =
2024-06-30 16:58:29 +01:00
let
r = prev.rsync.overrideAttrs (o: {
configureFlags = o.configureFlags ++ [ "--disable-openssl" ];
});
in
r.override { openssl = null; };
2023-12-02 17:08:59 +00:00
inherit s6;
s6-linux-init = prev.s6-linux-init.override {
skawarePackages = prev.skawarePackages // {
inherit s6;
};
2023-11-05 15:13:06 +00:00
};
2023-12-02 17:08:59 +00:00
s6-rc = prev.s6-rc.override {
skawarePackages = prev.skawarePackages // {
inherit s6;
};
};
strace = prev.strace.override { libunwind = null; };
2023-12-04 23:39:27 +00:00
2023-12-19 12:12:12 +00:00
ubootQemuAarch64 = final.buildUBoot {
defconfig = "qemu_arm64_defconfig";
2024-06-30 16:58:29 +01:00
extraMeta.platforms = [ "aarch64-linux" ];
filesToInstall = [ "u-boot.bin" ];
2023-12-19 12:12:12 +00:00
};
2023-12-04 23:39:27 +00:00
ubootQemuArm = final.buildUBoot {
defconfig = "qemu_arm_defconfig";
2024-06-30 16:58:29 +01:00
extraMeta.platforms = [ "armv7l-linux" ];
filesToInstall = [ "u-boot.bin" ];
2023-12-04 23:39:27 +00:00
extraConfig = ''
CONFIG_CMD_UBI=y
CONFIG_CMD_UBIFS=y
CONFIG_BOOTSTD=y
CONFIG_BOOTMETH_DISTRO=y
2023-12-18 22:42:29 +00:00
CONFIG_LZMA=y
CONFIG_CMD_LZMADEC=y
CONFIG_SYS_BOOTM_LEN=0x1000000
2023-12-04 23:39:27 +00:00
'';
};
2023-12-13 21:54:15 +00:00
2023-12-21 19:17:14 +00:00
ubootQemuMips = final.buildUBoot {
defconfig = "malta_defconfig";
2024-06-30 16:58:29 +01:00
extraMeta.platforms = [ "mips-linux" ];
filesToInstall = [ "u-boot.bin" ];
2023-12-21 19:17:14 +00:00
# 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
2024-06-30 16:58:29 +01:00
'';
2023-12-21 19:17:14 +00:00
};
libusb1 = crossOnly prev.libusb1 (
2025-02-10 21:55:08 +00:00
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;
}
);
2024-05-14 12:56:58 +01:00
2024-01-03 10:45:40 +00:00
util-linux-small = prev.util-linux.override {
2023-12-30 22:26:12 +00:00
ncursesSupport = false;
pamSupport = false;
systemdSupport = false;
nlsSupport = false;
translateManpages = false;
capabilitiesSupport = false;
};
2024-07-08 20:29:48 +01:00
2025-02-10 21:55:08 +00:00
xl2tpd = prev.xl2tpd.overrideAttrs (o: {
2024-07-08 20:29:48 +01:00
patches = [ ./pkgs/xl2tpd-exit-on-close.patch ];
});
}