initramfs: eliminate custom $build variable

Previously the initramfs required overriders to use a custom
`$build` environment variable as the destination for files to be
packed into an initramfs image.  This commit eliminates it, so the
standard $NIX_BUILD_TOP can be used instead.
master
Adam Joseph 1 year ago
parent 0e0ab73687
commit 6dbb2f8c92

@ -40,47 +40,44 @@ in stdenv.mkDerivation {
passAsFile = [ "modulesList" ];
buildPhase = ''
mkdir build
build=$(pwd)/build
runHook preBuild
mkdir -p $build/lib/modules
mkdir -p $NIX_BUILD_TOP/lib/modules
pushd ${kernel}/lib/modules/
cat $modulesListPath | ${cpio}/bin/cpio -p -d $build/lib/modules
cat $modulesListPath | ${cpio}/bin/cpio -p -d $NIX_BUILD_TOP/lib/modules
popd
mkdir -p $build/usr
ln -s bin $build/sbin
ln -s ../bin $build/usr/bin
ln -s ../sbin $build/usr/sbin
mkdir -p $NIX_BUILD_TOP/usr
ln -s bin $NIX_BUILD_TOP/sbin
ln -s ../bin $NIX_BUILD_TOP/usr/bin
ln -s ../sbin $NIX_BUILD_TOP/usr/sbin
'' + lib.optionalString withBusybox ''
cp -r ${busybox}/bin $build/bin
chmod -R u+w $build/bin
cp -r ${busybox}/bin $NIX_BUILD_TOP/bin
chmod -R u+w $NIX_BUILD_TOP/bin
'' + lib.optionalString (bootScript != null) ''
cp ${bootScript} $build/boot.sh
chmod +x $build/boot.sh
ln -s boot.sh $build/init
chmod +x $build/sbin/init
cp ${bootScript} $NIX_BUILD_TOP/boot.sh
chmod +x $NIX_BUILD_TOP/boot.sh
ln -s boot.sh $NIX_BUILD_TOP/init
chmod +x $NIX_BUILD_TOP/sbin/init
'' + lib.optionalString withSignify ''
cp ${signify}/bin/signify $build/bin/
cp ${signify}/bin/signify $NIX_BUILD_TOP/bin/
'' + lib.optionalString withLvm ''
cp ${lib.getBin lvm2}/bin/lvm $build/bin/
cp ${lib.getBin lvm2}/bin/dmsetup $build/bin/
cp ${lib.getBin lvm2}/bin/lvm $NIX_BUILD_TOP/bin/
cp ${lib.getBin lvm2}/bin/dmsetup $NIX_BUILD_TOP/bin/
'' + lib.optionalString withCryptsetup ''
cp ${cryptsetup}/bin/cryptsetup $build/bin/
cp ${cryptsetup}/bin/cryptsetup $NIX_BUILD_TOP/bin/
'' + lib.optionalString withKexec ''
cp ${kexec-tools}/bin/kexec $build/bin/
cp ${kexec-tools}/bin/kexec $NIX_BUILD_TOP/bin/
'' + lib.optionalString withNvramTool ''
cp ${nvramtool}/bin/nvramtool $build/bin/
cp ${nvramtool}/bin/nvramtool $NIX_BUILD_TOP/bin/
'' + ''
runHook postBuild
'';
installPhase = ''
runHook preInstall
chmod -R u+w $build
pushd $build
chmod -R u+w $NIX_BUILD_TOP
pushd $NIX_BUILD_TOP
${findutils}/bin/find . | ${cpio}/bin/cpio --create -H newc -R +0:+0 > $out
popd
runHook postInstall

@ -19,9 +19,9 @@
initramfs = prev.initramfs.overrideAttrs (a: {
postBuild = (a.postBuild or "") + ''
mkdir -p $build/etc
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.layout $build/etc/
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.default $build/etc/
mkdir -p $NIX_BUILD_TOP/etc
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.layout $NIX_BUILD_TOP/etc/
cp ${final.image.src}/src/mainboard/asus/kgpe-d16/cmos.default $NIX_BUILD_TOP/etc/
'';
});

Loading…
Cancel
Save