From d655099d76de16c93302fabaae1ef7e3584b547d Mon Sep 17 00:00:00 2001 From: William Date: Wed, 15 Oct 2025 20:07:51 -0300 Subject: [PATCH] added error handling to ephemeral.nix --- modules/ephemeral.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/ephemeral.nix b/modules/ephemeral.nix index be6fc6b..7403aac 100644 --- a/modules/ephemeral.nix +++ b/modules/ephemeral.nix @@ -45,8 +45,13 @@ in RemainAfterExit = true; }; script = '' + set -euo pipefail + mkdir /btrfs_tmp - mount ${cfg.rootDevice} /btrfs_tmp + if ! mount ${cfg.rootDevice} /btrfs_tmp; then + echo "ERROR: Failed to mount ${cfg.rootDevice}" + exit 1 + fi if [[ -e /btrfs_tmp/${cfg.rootSubvolume} ]]; then mkdir -p /btrfs_tmp/old_roots @@ -66,7 +71,12 @@ in delete_subvolume_recursively "$i" done - btrfs subvolume create /btrfs_tmp/${cfg.rootSubvolume} + if ! btrfs subvolume create /btrfs_tmp/${cfg.rootSubvolume}; then + echo "ERROR: Failed to create subvolume ${cfg.rootSubvolume}" + umount /btrfs_tmp + exit 1 + fi + umount /btrfs_tmp ''; };