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

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

Loading…
Cancel
Save