From a17ffd0d6e18d0600e68c88ea7c3afe2f1988b27 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:39:13 +0100 Subject: [PATCH] feat(modules/nixos/services/btrbk)!: move '/nix/btrbk' to '/btrbk' Move the '/nix/btrbk' directory to the '/btrbk' Btrfs subvolume because Btrbk has nothing to do with '/nix'. Initially, '/nix/btrbk' was used because everything within '/nix' already persisted across reboots without any additional efforts. BREAKING CHANGE: The Btrbk snapshot directory has moved from the '/nix/btrbk' directory to the '/btrbk' Btrfs subvolume. To create the new '/btrbk' subvolume, run the following script: #!/usr/bin/env bash MNTPOINT=$(mktemp -d) mount /dev/mapper/luks "$MNTPOINT" -o subvol=/ trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT SUBVOL_ABS_PATH="$MNTPOINT//btrbk" mkdir -p "$(dirname "$SUBVOL_ABS_PATH")" btrfs subvolume create "$SUBVOL_ABS_PATH" This script is an extract from the script generated by the following command: nix \ run \ github:nix-community/disko \ -- \ --dry-run \ --mode format \ hosts/masterplan/disko.nix --- hosts/bluetop/default.nix | 2 +- hosts/bluetop/disko.nix | 5 +++++ hosts/masterplan/default.nix | 2 +- hosts/masterplan/disko.nix | 5 +++++ modules/nixos/services/btrbk/default.nix | 4 +--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/hosts/bluetop/default.nix b/hosts/bluetop/default.nix index 7f13e2f..ec8fe02 100644 --- a/hosts/bluetop/default.nix +++ b/hosts/bluetop/default.nix @@ -70,7 +70,7 @@ btrbk = { enable = true; - snapshotDir = "/nix/btrbk"; + snapshotDir = "/btrbk"; }; openssh.enable = true; diff --git a/hosts/bluetop/disko.nix b/hosts/bluetop/disko.nix index c66aa79..0ca444e 100644 --- a/hosts/bluetop/disko.nix +++ b/hosts/bluetop/disko.nix @@ -22,6 +22,11 @@ extraArgs = ["-f"]; subvolumes = { + "/btrbk" = { + mountpoint = "/btrbk"; + mountOptions = ["compress=zstd" "noatime"]; + }; + "/persistent" = { mountpoint = "/persistent"; mountOptions = ["compress=zstd" "noatime"]; diff --git a/hosts/masterplan/default.nix b/hosts/masterplan/default.nix index b5f1339..b60f844 100644 --- a/hosts/masterplan/default.nix +++ b/hosts/masterplan/default.nix @@ -71,7 +71,7 @@ btrbk = { enable = true; - snapshotDir = "/nix/btrbk"; + snapshotDir = "/btrbk"; }; openssh.enable = true; diff --git a/hosts/masterplan/disko.nix b/hosts/masterplan/disko.nix index 0a56276..39110a6 100644 --- a/hosts/masterplan/disko.nix +++ b/hosts/masterplan/disko.nix @@ -22,6 +22,11 @@ extraArgs = ["-f"]; subvolumes = { + "/btrbk" = { + mountpoint = "/btrbk"; + mountOptions = ["compress=zstd" "noatime"]; + }; + "/persistent" = { mountpoint = "/persistent"; mountOptions = ["compress=zstd" "noatime"]; diff --git a/modules/nixos/services/btrbk/default.nix b/modules/nixos/services/btrbk/default.nix index 009443b..c7a5581 100644 --- a/modules/nixos/services/btrbk/default.nix +++ b/modules/nixos/services/btrbk/default.nix @@ -8,7 +8,7 @@ snapshotDir = lib.mkOption { description = "Path to Btrbk's snapshot directory."; - example = "/nix/btrbk"; + example = "/btrbk"; type = lib.types.str; }; }; @@ -27,7 +27,5 @@ subvolume = "/home"; }; }; - - systemd.tmpfiles.rules = ["d ${cfg.snapshotDir} 700"]; }; }