mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
make-disk-image: create directories images in out path
In case we are crossing some filesystem boundary (i.e. /tmp -> /nix/store), this is faster. Also tmpfs might be probelemantic regarding memory usage.
This commit is contained in:
1 parent
785c1e02c7
commit
98894c8598
1 file changed
+13
-10
+13
-10
@@ -48,18 +48,17 @@ let
|
||||
kmod
|
||||
] ++ cfg.extraDependencies;
|
||||
preVM = ''
|
||||
${lib.concatMapStringsSep "\n" (disk: "${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} ${disk.imageName}.${imageFormat} ${disk.imageSize}") (lib.attrValues diskoCfg.devices.disk)}
|
||||
# shellcheck disable=SC2154
|
||||
mkdir -p "$out"
|
||||
${lib.concatMapStringsSep "\n" (disk:
|
||||
# shellcheck disable=SC2154
|
||||
"${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} \"$out/${disk.imageName}.${imageFormat}\" ${disk.imageSize}"
|
||||
) (lib.attrValues diskoCfg.devices.disk)}
|
||||
# This makes disko work, when canTouchEfiVariables is set to true.
|
||||
# Technically these boot entries will no be persisted this way, but
|
||||
# in most cases this is OK, because we can rely on the standard location for UEFI executables.
|
||||
install -m600 ${pkgs.OVMF.variables} efivars.fd
|
||||
'';
|
||||
postVM = ''
|
||||
# shellcheck disable=SC2154
|
||||
mkdir -p "$out"
|
||||
${lib.concatMapStringsSep "\n" (disk: "mv ${disk.imageName}.${imageFormat} \"$out\"/${disk.imageName}.${imageFormat}") (lib.attrValues diskoCfg.devices.disk)}
|
||||
${cfg.extraPostVM}
|
||||
'';
|
||||
|
||||
closureInfo = pkgs.closureInfo {
|
||||
rootPaths = [ systemToInstall.config.system.build.toplevel ];
|
||||
@@ -105,7 +104,7 @@ let
|
||||
"-drive if=pflash,format=raw,unit=1,file=efivars.fd"
|
||||
] ++ builtins.map
|
||||
(disk:
|
||||
"-drive file=${disk.imageName}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}"
|
||||
"-drive file=\"$out\"/${disk.imageName}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}"
|
||||
)
|
||||
(lib.attrValues diskoCfg.devices.disk));
|
||||
in
|
||||
@@ -113,7 +112,8 @@ in
|
||||
system.build.diskoImages = vmTools.runInLinuxVM (pkgs.runCommand cfg.name
|
||||
{
|
||||
buildInputs = dependencies;
|
||||
inherit preVM postVM QEMU_OPTS;
|
||||
inherit preVM QEMU_OPTS;
|
||||
postVm = cfg.extraPostVM;
|
||||
inherit (diskoCfg) memSize;
|
||||
}
|
||||
(partitioner + installer));
|
||||
@@ -204,10 +204,13 @@ in
|
||||
echo "export origBuilder=$origBuilder" >> xchg/saved-env
|
||||
${preVM}
|
||||
''}
|
||||
export postVM=${diskoLib.writeCheckedBash { inherit pkgs checked; } "postVM.sh" postVM}
|
||||
export postVM=${diskoLib.writeCheckedBash { inherit pkgs checked; } "postVM.sh" cfg.extraPostVM}
|
||||
|
||||
build_memory=''${build_memory:-${builtins.toString diskoCfg.memSize}}
|
||||
# shellcheck disable=SC2016
|
||||
QEMU_OPTS=${lib.escapeShellArg QEMU_OPTS}
|
||||
# replace quoted $out with the actual path
|
||||
QEUM_OPTS=''${QEMU_OPTS//\$out/$out}
|
||||
QEMU_OPTS+=" -m $build_memory"
|
||||
export QEMU_OPTS
|
||||
|
||||
|
||||
Reference in new issue
Block a user