Skip to content

Commit

Permalink
feat(modules/nixos/services/btrbk)!: move '/nix/btrbk' to '/btrbk'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
trueNAHO committed Feb 21, 2024
1 parent c9d23c2 commit a17ffd0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hosts/bluetop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

btrbk = {
enable = true;
snapshotDir = "/nix/btrbk";
snapshotDir = "/btrbk";
};

openssh.enable = true;
Expand Down
5 changes: 5 additions & 0 deletions hosts/bluetop/disko.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
extraArgs = ["-f"];

subvolumes = {
"/btrbk" = {
mountpoint = "/btrbk";
mountOptions = ["compress=zstd" "noatime"];
};

"/persistent" = {
mountpoint = "/persistent";
mountOptions = ["compress=zstd" "noatime"];
Expand Down
2 changes: 1 addition & 1 deletion hosts/masterplan/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

btrbk = {
enable = true;
snapshotDir = "/nix/btrbk";
snapshotDir = "/btrbk";
};

openssh.enable = true;
Expand Down
5 changes: 5 additions & 0 deletions hosts/masterplan/disko.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
extraArgs = ["-f"];

subvolumes = {
"/btrbk" = {
mountpoint = "/btrbk";
mountOptions = ["compress=zstd" "noatime"];
};

"/persistent" = {
mountpoint = "/persistent";
mountOptions = ["compress=zstd" "noatime"];
Expand Down
4 changes: 1 addition & 3 deletions modules/nixos/services/btrbk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

snapshotDir = lib.mkOption {
description = "Path to Btrbk's snapshot directory.";
example = "/nix/btrbk";
example = "/btrbk";
type = lib.types.str;
};
};
Expand All @@ -27,7 +27,5 @@
subvolume = "/home";
};
};

systemd.tmpfiles.rules = ["d ${cfg.snapshotDir} 700"];
};
}

0 comments on commit a17ffd0

Please sign in to comment.