From 604a83cdeeb7774338f4f6088ff4c02235946cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 5 Jan 2023 14:59:24 +0200 Subject: [PATCH] Revert "sanoid: replace paths with mountpoints" This reverts commit 32f786946011d3636c6947eddc9a713921ef91ad. --- configuration.nix | 4 ++-- scripts/snaplink | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/configuration.nix b/configuration.nix index d7b7720..54d74d5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -87,8 +87,8 @@ let ssh_pubkeys = { autoprune = true; post_snapshot_script = "/var/src/snaplink"; }; - datasets."/home".use_template = [ "prod" ]; - datasets."/var".use_template = [ "prod" ]; + datasets."rpool/nixos/home".use_template = [ "prod" ]; + datasets."rpool/nixos/var".use_template = [ "prod" ]; extraArgs = [ "--verbose" ]; }; diff --git a/scripts/snaplink b/scripts/snaplink index 7c0b278..1250dab 100755 --- a/scripts/snaplink +++ b/scripts/snaplink @@ -1,10 +1,10 @@ #!/usr/bin/env bash set -euo pipefail -snap_path="$SANOID_TARGET/.zfs/snapshot/$SANOID_SNAPNAME" -[[ -d "$snap_path" ]] || { - >&2 echo "expected to find a directory in $snap_path" - exit 1 -} -link_path="$SANOID_TARGET/.snapshot-latest" +_fatal() { >&2 echo "ERROR: $*"; exit 1; } +mountpoint=$(zfs list -H -t filesystem -o mountpoint "$SANOID_TARGET") +[[ -n "$mountpoint" ]] || _fatal "expected non-empty $SANOID_TARGET" +snap_path="$mountpoint/.zfs/snapshot/$SANOID_SNAPNAME" +[[ -d "$snap_path" ]] || _fatal "expected to find a directory in $snap_path" +link_path="$mountpoint/.snapshot-latest" ln -sf "$snap_path" "$link_path" >&2 printf "successfully created %s -> %s\n" "$link_path" "$snap_path"