|
48 | 48 | kmod
|
49 | 49 | ] ++ cfg.extraDependencies;
|
50 | 50 | preVM = ''
|
51 |
| - ${lib.concatMapStringsSep "\n" (disk: "${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} ${disk.imageName}.${imageFormat} ${disk.imageSize}") (lib.attrValues diskoCfg.devices.disk)} |
| 51 | + # shellcheck disable=SC2154 |
| 52 | + mkdir -p "$out" |
| 53 | + ${lib.concatMapStringsSep "\n" (disk: |
| 54 | + # shellcheck disable=SC2154 |
| 55 | + "${pkgs.qemu}/bin/qemu-img create -f ${imageFormat} \"$out/${disk.imageName}.${imageFormat}\" ${disk.imageSize}" |
| 56 | + ) (lib.attrValues diskoCfg.devices.disk)} |
52 | 57 | # This makes disko work, when canTouchEfiVariables is set to true.
|
53 | 58 | # Technically these boot entries will no be persisted this way, but
|
54 | 59 | # in most cases this is OK, because we can rely on the standard location for UEFI executables.
|
55 | 60 | install -m600 ${pkgs.OVMF.variables} efivars.fd
|
56 | 61 | '';
|
57 |
| - postVM = '' |
58 |
| - # shellcheck disable=SC2154 |
59 |
| - mkdir -p "$out" |
60 |
| - ${lib.concatMapStringsSep "\n" (disk: "mv ${disk.imageName}.${imageFormat} \"$out\"/${disk.imageName}.${imageFormat}") (lib.attrValues diskoCfg.devices.disk)} |
61 |
| - ${cfg.extraPostVM} |
62 |
| - ''; |
63 | 62 |
|
64 | 63 | closureInfo = pkgs.closureInfo {
|
65 | 64 | rootPaths = [ systemToInstall.config.system.build.toplevel ];
|
@@ -105,15 +104,16 @@ let
|
105 | 104 | "-drive if=pflash,format=raw,unit=1,file=efivars.fd"
|
106 | 105 | ] ++ builtins.map
|
107 | 106 | (disk:
|
108 |
| - "-drive file=${disk.imageName}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}" |
| 107 | + "-drive file=\"$out\"/${disk.imageName}.${imageFormat},if=virtio,cache=unsafe,werror=report,format=${imageFormat}" |
109 | 108 | )
|
110 | 109 | (lib.attrValues diskoCfg.devices.disk));
|
111 | 110 | in
|
112 | 111 | {
|
113 | 112 | system.build.diskoImages = vmTools.runInLinuxVM (pkgs.runCommand cfg.name
|
114 | 113 | {
|
115 | 114 | buildInputs = dependencies;
|
116 |
| - inherit preVM postVM QEMU_OPTS; |
| 115 | + inherit preVM QEMU_OPTS; |
| 116 | + postVm = cfg.extraPostVM; |
117 | 117 | inherit (diskoCfg) memSize;
|
118 | 118 | }
|
119 | 119 | (partitioner + installer));
|
|
204 | 204 | echo "export origBuilder=$origBuilder" >> xchg/saved-env
|
205 | 205 | ${preVM}
|
206 | 206 | ''}
|
207 |
| - export postVM=${diskoLib.writeCheckedBash { inherit pkgs checked; } "postVM.sh" postVM} |
| 207 | + export postVM=${diskoLib.writeCheckedBash { inherit pkgs checked; } "postVM.sh" cfg.extraPostVM} |
208 | 208 |
|
209 | 209 | build_memory=''${build_memory:-${builtins.toString diskoCfg.memSize}}
|
| 210 | + # shellcheck disable=SC2016 |
210 | 211 | QEMU_OPTS=${lib.escapeShellArg QEMU_OPTS}
|
| 212 | + # replace quoted $out with the actual path |
| 213 | + QEUM_OPTS=''${QEMU_OPTS//\$out/$out} |
211 | 214 | QEMU_OPTS+=" -m $build_memory"
|
212 | 215 | export QEMU_OPTS
|
213 | 216 |
|
|
0 commit comments