From e43f31656dae86d44a4278d27c096ebf47bab9c3 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 24 Sep 2022 03:29:16 -0700 Subject: [PATCH] userspace: overhaul --- src/platform/kevin/default.nix | 3 +- src/userspace/default.nix | 55 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/platform/kevin/default.nix b/src/platform/kevin/default.nix index 9fae447..0334863 100644 --- a/src/platform/kevin/default.nix +++ b/src/platform/kevin/default.nix @@ -56,9 +56,8 @@ in { ''; }); + inherit modules_insmod; userspace = prev.userspace.override { - inherit modules_insmod; - inherit modules_noinsmod; }; initramfs = prev.initramfs.override { diff --git a/src/userspace/default.nix b/src/userspace/default.nix index d4bb8f1..3a67b4f 100644 --- a/src/userspace/default.nix +++ b/src/userspace/default.nix @@ -3,9 +3,18 @@ { lib , nixpkgsOnBuildForHost , kernel -, modules_noinsmod ? [ ] -, modules_insmod ? [ ] -, kernelname +, bootScript ? ../boot.sh # symlinked to /init if non-null + +, withBusybox ? true +, withSignify ? true +# Inclusion of these is temporarily disabled. I had a bunch of +# ugly space-saving hacks that were removed during the pre-release +# cleanup, and it turns out that without those hacks there isn't enough +# space for the large userspace tools. Once I clean up and +# reinstate those hacks I will reenable this. +, withLvm ? false +, withCryptsetup ? false +, withKexec ? false }: let @@ -13,43 +22,33 @@ let in stdenv.mkDerivation { name = "ownerboot-initramfs-userspace"; - modules_all = (lib.concatMapStringsSep "\n" (m: "${kernel.version}/kernel/" + m) (modules_insmod ++ modules_noinsmod))+"\n"; - modules_insmod = (lib.concatMapStringsSep "\n" (m: "${kernel.version}/kernel/" + m) modules_insmod) + "\n"; - bootScript = builtins.readFile ../boot.sh; - passAsFile = [ "bootScript" "modules_insmod" ]; dontUnpack = true; dontFixup = true; - # FIXME: get this working again using `__impure` derivations - #bannerText = "$$(git describe --abbrev=4 --dirty --always --tags) built $$(date +'%Y-%h-%d at %H:%M')"; - bannerText = "ownerboot"; - installPhase = '' runHook preInstall mkdir -p $out/usr - cp -r ${busybox}/bin $out/bin - chmod -R u+w $out - cp ${signify}/bin/signify $out/bin/ ln -s bin $out/sbin ln -s ../bin $out/usr/bin ln -s ../sbin $out/usr/sbin - cp $bootScriptPath $out/boot.sh + '' + lib.optionalString (bootScript != null) '' + cp ${bootScript} $out/boot.sh chmod +x $out/boot.sh ln -s boot.sh $out/init chmod +x $out/sbin/init - mkdir -p $out/lib/modules - echo "ownerboot ${platform_name} $bannerText" > $out/banner.txt - cp $modules_insmodPath $out/modules-insmod.txt - - # Inclusion of these is temporarily disabled. I had a bunch of - # ugly space-saving hacks that were removed during the pre-release - # cleanup, and it turns out that without those hacks there isn't enough - # space for the large userspace tools. Once I clean up and - # reinstate those hacks I will reenable this. - #cp ${lib.getBin lvm2}/bin/lvm $out/bin/ - #cp ${lib.getBin lvm2}/bin/dmsetup $out/bin/ - #cp ${cryptsetup}/bin/cryptsetup $out/bin/ - #cp ${kexec-tools}/bin/kexec $out/bin/ + '' + lib.optionalString withBusybox '' + cp -r ${busybox}/bin $out/bin + chmod -R u+w $out/bin + '' + lib.optionalString withSignify '' + cp ${signify}/bin/signify $out/bin/ + '' + lib.optionalString withLvm '' + cp ${lib.getBin lvm2}/bin/lvm $out/bin/ + cp ${lib.getBin lvm2}/bin/dmsetup $out/bin/ + '' + lib.optionalString withCryptsetup '' + cp ${cryptsetup}/bin/cryptsetup $out/bin/ + '' + lib.optionalString withKexec '' + cp ${kexec-tools}/bin/kexec $out/bin/ + '' + '' runHook postInstall ''; }