On Sun, Dec 12, 2021 at 03:11:14PM +0100, Yureka wrote: > --- > host/initramfs/default.nix | 31 +++++++++++++++++++++++++++---- > 1 file changed, 27 insertions(+), 4 deletions(-) Just a note to say, I didn't apply this particular patch because you'd already fixed it in Nixpkgs by the time I saw it, but I have now (finally) integrated static cryptsetup in Spectrum, and it's working and it made the initramfs much smaller and faster to build. Thanks so much for the work you put into it! > diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix > index ba6ede2..91e598f 100644 > --- a/host/initramfs/default.nix > +++ b/host/initramfs/default.nix > @@ -2,15 +2,38 @@ > > { lib, stdenv, runCommand, writeReferencesToFile, pkgsStatic > , busybox, cpio, cryptsetup, linux, lvm2 > +, fetchpatch > }: > > -let > - cryptsetup' = cryptsetup; > -in > let > inherit (lib) cleanSource cleanSourceWith concatMapStringsSep; > > - cryptsetup = cryptsetup'.override { lvm2 = lvm2.override { udev = null; }; }; > + # https://github.com/NixOS/nixpkgs/pull/148948 > + cryptsetup = (pkgsStatic.cryptsetup.override { > + lvm2 = (pkgsStatic.lvm2.override { > + udev = null; > + }).overrideAttrs (old: { > + patches = (old.patches or []) ++ [ > + (fetchpatch { > + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/bf8b0d818a6c5fa65f318603756762af492c1a0c/pkgs/os-specific/linux/lvm2/no-shared.diff"; > + sha256 = "sha256-t67Osvcn92R7q9V+KDW+SyJDmajzVbnTPONlokcBU9U="; > + }) > + ]; > + configureFlags = old.configureFlags ++ [ "--enable-static_link" ]; > + makeFlags = old.makeFlags ++ [ "libdm.device-mapper" ]; > + installPhase = '' > + install -D -t $out/lib libdm/ioctl/libdevmapper.a > + make -C libdm install_include > + make -C libdm install_pkgconfig > + ''; > + outputs = [ "out" ]; > + }); > + }).overrideAttrs (old: { > + NIX_LDFLAGS = ""; > + configureFlags = old.configureFlags ++ [ > + "--enable-static-cryptsetup" > + ]; > + }); > > packages = [ > cryptsetup pkgsStatic.mdevd pkgsStatic.execline > -- > 2.34.0 >