diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-12-12 00:38:57 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-12-12 00:44:50 +0000 |
commit | 13901c129dea111960f410ac41105fb566c6673d (patch) | |
tree | 9c3632623a9f8f7acfca7296858ab26858d8abb0 /host/initramfs/default.nix | |
parent | fea2aa066633bed62f67514b7ef66fbf841b9e30 (diff) | |
download | spectrum-13901c129dea111960f410ac41105fb566c6673d.tar spectrum-13901c129dea111960f410ac41105fb566c6673d.tar.gz spectrum-13901c129dea111960f410ac41105fb566c6673d.tar.bz2 spectrum-13901c129dea111960f410ac41105fb566c6673d.tar.lz spectrum-13901c129dea111960f410ac41105fb566c6673d.tar.xz spectrum-13901c129dea111960f410ac41105fb566c6673d.tar.zst spectrum-13901c129dea111960f410ac41105fb566c6673d.zip |
host/initramfs: move to monorepo path
Diffstat (limited to 'host/initramfs/default.nix')
-rw-r--r-- | host/initramfs/default.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix new file mode 100644 index 0000000..ba6ede2 --- /dev/null +++ b/host/initramfs/default.nix @@ -0,0 +1,66 @@ +{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage ( + +{ lib, stdenv, runCommand, writeReferencesToFile, pkgsStatic +, busybox, cpio, cryptsetup, linux, lvm2 +}: + +let + cryptsetup' = cryptsetup; +in +let + inherit (lib) cleanSource cleanSourceWith concatMapStringsSep; + + cryptsetup = cryptsetup'.override { lvm2 = lvm2.override { udev = null; }; }; + + packages = [ + cryptsetup pkgsStatic.mdevd pkgsStatic.execline + + (busybox.override { + enableStatic = true; + extraConfig = '' + CONFIG_FINDFS n + ''; + }) + ]; + + packagesSysroot = runCommand "packages-sysroot" {} '' + mkdir -p $out/bin + ln -s ${concatMapStringsSep " " (p: "${p}/bin/*") packages} $out/bin + cp -R ${linux}/lib $out + ln -s /bin $out/sbin + + # TODO: this is a hack and we should just build the util-linux + # programs we want. + # https://lore.kernel.org/util-linux/87zgrl6ufb.fsf@alyssa.is/ + cp ${pkgsStatic.util-linux.override { systemd = null; }}/bin/{findfs,lsblk} $out/bin + ''; + + packagesCpio = runCommand "packages.cpio" { + nativeBuildInputs = [ cpio ]; + storePaths = writeReferencesToFile packagesSysroot; + } '' + cd ${packagesSysroot} + (printf "/nix\n/nix/store\n" && find . $(< $storePaths)) | + cpio -o -H newc -R +0:+0 --reproducible > $out + ''; +in + +stdenv.mkDerivation { + name = "initramfs"; + + src = cleanSourceWith { + filter = name: _type: name != "${toString ./.}/build" && name != "${toString ./.}/spectrum-live"; + src = cleanSource ./.; + }; + + PACKAGES_CPIO = packagesCpio; + + nativeBuildInputs = [ cpio ]; + + installPhase = '' + cp build/initramfs $out + ''; + + enableParallelBuilding = true; +} +) {} |