Skip to content

Commit a74f0af

Browse files
committed
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.
1 parent 1783a5f commit a74f0af

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/make-disk-image.nix

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ let
5454
xcp'
5555
] ++ cfg.extraDependencies;
5656
preVM = ''
57-
${lib.concatMapStringsSep "\n" (disk: "${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} ${disk.imageName}.${imageFormat} ${disk.imageSize}") (lib.attrValues diskoCfg.devices.disk)}
57+
mkdir -p "$out"
58+
${lib.concatMapStringsSep "\n" (disk: "${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} \"$out/${disk.imageName}.${imageFormat}\" ${disk.imageSize}") (lib.attrValues diskoCfg.devices.disk)}
5859
# This makes disko work, when canTouchEfiVariables is set to true.
5960
# Technically these boot entries will no be persisted this way, but
6061
# in most cases this is OK, because we can rely on the standard location for UEFI executables.
6162
install -m600 ${pkgs.OVMF.variables} efivars.fd
6263
'';
6364
postVM = ''
6465
# shellcheck disable=SC2154
65-
mkdir -p "$out"
66-
${lib.concatMapStringsSep "\n" (disk: "mv ${disk.imageName}.${imageFormat} \"$out\"/${disk.imageName}.${imageFormat}") (lib.attrValues diskoCfg.devices.disk)}
6766
${cfg.extraPostVM}
6867
'';
6968

@@ -111,7 +110,7 @@ let
111110
"-drive if=pflash,format=raw,unit=1,file=efivars.fd"
112111
] ++ builtins.map
113112
(disk:
114-
"-drive file=${disk.imageName}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}"
113+
"-drive file=\"$out\"/${disk.imageName}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}"
115114
)
116115
(lib.attrValues diskoCfg.devices.disk));
117116
in

0 commit comments

Comments
 (0)