userspace: overhaul

master
Adam Joseph 2 years ago
parent 4711bd6676
commit e43f31656d

@ -56,9 +56,8 @@ in {
''; '';
}); });
userspace = prev.userspace.override {
inherit modules_insmod; inherit modules_insmod;
inherit modules_noinsmod; userspace = prev.userspace.override {
}; };
initramfs = prev.initramfs.override { initramfs = prev.initramfs.override {

@ -3,9 +3,18 @@
{ lib { lib
, nixpkgsOnBuildForHost , nixpkgsOnBuildForHost
, kernel , kernel
, modules_noinsmod ? [ ] , bootScript ? ../boot.sh # symlinked to /init if non-null
, modules_insmod ? [ ]
, kernelname , 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 let
@ -13,43 +22,33 @@ let
in stdenv.mkDerivation { in stdenv.mkDerivation {
name = "ownerboot-initramfs-userspace"; 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; dontUnpack = true;
dontFixup = 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 = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/usr 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/sbin
ln -s ../bin $out/usr/bin ln -s ../bin $out/usr/bin
ln -s ../sbin $out/usr/sbin 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 chmod +x $out/boot.sh
ln -s boot.sh $out/init ln -s boot.sh $out/init
chmod +x $out/sbin/init chmod +x $out/sbin/init
mkdir -p $out/lib/modules '' + lib.optionalString withBusybox ''
echo "ownerboot ${platform_name} $bannerText" > $out/banner.txt cp -r ${busybox}/bin $out/bin
cp $modules_insmodPath $out/modules-insmod.txt chmod -R u+w $out/bin
'' + lib.optionalString withSignify ''
# Inclusion of these is temporarily disabled. I had a bunch of cp ${signify}/bin/signify $out/bin/
# ugly space-saving hacks that were removed during the pre-release '' + lib.optionalString withLvm ''
# cleanup, and it turns out that without those hacks there isn't enough cp ${lib.getBin lvm2}/bin/lvm $out/bin/
# space for the large userspace tools. Once I clean up and cp ${lib.getBin lvm2}/bin/dmsetup $out/bin/
# reinstate those hacks I will reenable this. '' + lib.optionalString withCryptsetup ''
#cp ${lib.getBin lvm2}/bin/lvm $out/bin/ cp ${cryptsetup}/bin/cryptsetup $out/bin/
#cp ${lib.getBin lvm2}/bin/dmsetup $out/bin/ '' + lib.optionalString withKexec ''
#cp ${cryptsetup}/bin/cryptsetup $out/bin/ cp ${kexec-tools}/bin/kexec $out/bin/
#cp ${kexec-tools}/bin/kexec $out/bin/ '' + ''
runHook postInstall runHook postInstall
''; '';
} }

Loading…
Cancel
Save