diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2021-06-23 16:45:04 +0200 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2021-09-18 16:46:20 +0200 |
commit | c1fd51f490c418203087239eac1d69b04cf4ec3e (patch) | |
tree | f8848e4bed722d8da83f5d2754ca576d9c4db8ca /nixos/modules | |
parent | 772c3e6ec590d32741e0f3d3c6d5930d194723b5 (diff) | |
download | nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.tar nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.tar.gz nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.tar.bz2 nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.tar.lz nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.tar.xz nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.tar.zst nixpkgs-c1fd51f490c418203087239eac1d69b04cf4ec3e.zip |
nixos/qemu: fix several shellcheck issues
- Fix shell quoting issues - Fix unsafe cd in run-machine-vm script
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index b51c29f83d6..4bd7403ed3c 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -108,7 +108,7 @@ let '' #! ${pkgs.runtimeShell} - NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}}) + NIX_DISK_IMAGE=$(readlink -f "''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}}") if ! test -e "$NIX_DISK_IMAGE"; then ${qemu}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \ @@ -121,14 +121,14 @@ let fi # Create a directory for exchanging data with the VM. - mkdir -p $TMPDIR/xchg + mkdir -p "$TMPDIR/xchg" ${if cfg.useBootLoader then '' # Create a writable copy/snapshot of the boot disk. # A writable boot disk can be booted from automatically. - ${qemu}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img $TMPDIR/disk.img || exit 1 + ${qemu}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img "$TMPDIR/disk.img" || exit 1 - NIX_EFI_VARS=$(readlink -f ''${NIX_EFI_VARS:-${cfg.efiVars}}) + NIX_EFI_VARS=$(readlink -f "''${NIX_EFI_VARS:-${cfg.efiVars}}") ${if cfg.useEFIBoot then '' # VM needs writable EFI vars @@ -139,7 +139,8 @@ let '' else ""} '' else ""} - cd $TMPDIR + cd "$TMPDIR" || exit 1 + idx=0 ${flip concatMapStrings cfg.emptyDiskImages (size: '' if ! test -e "empty$idx.qcow2"; then @@ -646,7 +647,7 @@ in virtualisation.qemu.drives = mkMerge [ [{ name = "root"; - file = "$NIX_DISK_IMAGE"; + file = ''"$NIX_DISK_IMAGE"''; driveExtraOpts.cache = "writeback"; driveExtraOpts.werror = "report"; }] @@ -655,7 +656,7 @@ in # note [Disk layout with `useBootLoader`]. { name = "boot"; - file = "$TMPDIR/disk.img"; + file = ''"$TMPDIR"/disk.img''; driveExtraOpts.media = "disk"; deviceExtraOpts.bootindex = "1"; } |