From fd9869b0e03155c3a556cc969f7911fef01761b9 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Thu, 9 May 2024 02:09:13 -0700 Subject: [PATCH] Fix simple bash errors in user VM script --- user-machines/vm/config.nix | 2 ++ user-machines/vm/default.nix | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/user-machines/vm/config.nix b/user-machines/vm/config.nix index 06d9e45..f60bb1f 100644 --- a/user-machines/vm/config.nix +++ b/user-machines/vm/config.nix @@ -32,6 +32,8 @@ in hostOrderToIP mkCloudInitImage; + volumeSize = "4G"; + ips = rec { start = { ip = "192.168.168.2"; diff --git a/user-machines/vm/default.nix b/user-machines/vm/default.nix index 487a4fe..d269851 100644 --- a/user-machines/vm/default.nix +++ b/user-machines/vm/default.nix @@ -23,7 +23,8 @@ let inherit (import ./config.nix { inherit pkgs; }) lib ips - ubuntu; + ubuntu + volumeSize; mkRawImage = image: pkgs.runCommand "${image.name}-raw.img" @@ -48,12 +49,6 @@ in default = "/var/lib/acm-vm"; description = "The directory to store VM disk images in."; }; - - volumeSizeGB = mkOption { - type = types.int; - default = 4; - description = "The size in GB of the VM disk images applied to new and existing images."; - }; virtConnection = mkOption { type = types.str; @@ -162,7 +157,7 @@ in export POOL_NAME="acm-vm-pool" export POOL_DIRECTORY=${self.poolDirectory} - export VOLUME_SIZE=${toString self.volumeSizeGB}"GiB" + export VOLUME_SIZE=${volumeSize} log() { echo "$@" >&2; } @@ -174,7 +169,8 @@ in for uuid in ${concatStringsSep " " (map (user: user.uuid) activeUsers)}; do volume="$uuid.img" - echo "Creating $volume..." + volumePath="$POOL_DIRECTORY/$volume" + echo "Creating $volumePath..." if [[ -f "$volumePath" ]]; then log " volume already exists." @@ -198,7 +194,8 @@ in for uuid in ${concatStringsSep " " (map (user: user.uuid) deletedUsers)}; do volume="$uuid.img" - echo "Deleting $volume..." + volumePath="$POOL_DIRECTORY/$volume" + echo "Deleting $volumePath..." if [[ -f "$volumePath" ]]; then log " volume exists, deleting..."