From 44b8121edbc39b9cfd02d43f77f75fb228b86f6b Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 17 Jun 2026 14:51:47 -0400 Subject: [PATCH 1/2] feat: add btrfs + btrbk module for 16TB data disk - New module: modules/nixos/filesystem/temp-16tb-disk.nix with btrfs kernel support, btrfs-progs + btrbk, LUKS2 auto-unlock, nofail mount, btrbk daily snapshots (14d/4w/3m) - Registered in flake.nix for lazyworkhorse - Host config with commented-out enable block (fill UUID when disk reconnected) --- flake.nix | 1 + hosts/lazyworkhorse/configuration.nix | 8 ++ modules/nixos/filesystem/temp-16tb-disk.nix | 121 ++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 modules/nixos/filesystem/temp-16tb-disk.nix diff --git a/flake.nix b/flake.nix index ea2a6b6..5732c05 100644 --- a/flake.nix +++ b/flake.nix @@ -65,6 +65,7 @@ ./hosts/lazyworkhorse/configuration.nix ./hosts/lazyworkhorse/hardware-configuration.nix ./modules/nixos/filesystem/hoardingcow-mount.nix + ./modules/nixos/filesystem/temp-16tb-disk.nix ./modules/nixos/services/docker_manager.nix ./modules/nixos/services/open_code_server.nix ./modules/nixos/services/ollama_init_custom_models.nix diff --git a/hosts/lazyworkhorse/configuration.nix b/hosts/lazyworkhorse/configuration.nix index 6f02a2b..dfd5e30 100644 --- a/hosts/lazyworkhorse/configuration.nix +++ b/hosts/lazyworkhorse/configuration.nix @@ -8,6 +8,14 @@ # NAS Mounting hoardingcow-mount.enable = true; + # 16TB btrfs storage disk (WD Red Pro — LUKS2 + btrfs + btrbk snapshots) + # ⚠ SETUP REQUIRED: Connect the disk, get the LUKS UUID with 'blkid /dev/sdb', + # then set gortium.temp16tb.luksUuid here and deploy. + # gortium.temp16tb = { + # enable = true; + # luksUuid = "REPLACE_ME_WITH_REAL_UUID"; + # }; + # Flakesss nix.settings.experimental-features = [ "nix-command" "flakes" "flake-self-attrs" ]; nix.settings.trusted-users = [ "root" "gortium" ]; diff --git a/modules/nixos/filesystem/temp-16tb-disk.nix b/modules/nixos/filesystem/temp-16tb-disk.nix new file mode 100644 index 0000000..a0780d5 --- /dev/null +++ b/modules/nixos/filesystem/temp-16tb-disk.nix @@ -0,0 +1,121 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.gortium.temp16tb; + luksName = cfg.luksName; +in +with lib; + +{ + options.gortium.temp16tb = { + enable = mkEnableOption "16TB temp storage disk (btrfs + LUKS + btrbk snapshots)"; + + luksUuid = mkOption { + type = types.str; + description = '' + UUID of the LUKS partition on the 16TB disk. + + Find this by running as root when the disk is connected: + blkid /dev/sdb # or wherever the disk appears + lsblk -o NAME,SIZE,FSTYPE,UUID + + Since btrfs is inside LUKS, the FS UUID is hidden — use the + LUKS partition UUID from blkid (it'll show TYPE=\"crypto_LUKS\"). + ''; + example = "00000000-0000-0000-0000-000000000000"; + }; + + luksName = mkOption { + type = types.str; + default = "temp_16tb"; + description = "Name for the LUKS /dev/mapper/ mapping"; + }; + + mountPoint = mkOption { + type = types.str; + default = "/mnt/temp_16tb"; + description = "Mount point for the 16TB disk"; + }; + + btrfsOptions = mkOption { + type = types.listOf types.str; + default = [ "defaults" "noatime" "compress=zstd:3" "nofail" ]; + description = "Mount options for the btrfs filesystem. 'nofail' ensures boot succeeds when disk is disconnected."; + }; + + btrbk = { + enable = mkOption { + type = types.bool; + default = true; + description = "Enable btrbk snapshot management on this volume"; + }; + + schedule = mkOption { + type = types.str; + default = "daily"; + description = "systemd calendar event for btrbk (e.g. 'daily', 'hourly', '*-*-* 00:00:00')"; + }; + + preserveMin = mkOption { + type = types.str; + default = "2d"; + description = "btrbk snapshot_preserve_min — minimum age before pruning"; + }; + + preserve = mkOption { + type = types.str; + default = "14d 4w 3m"; + description = "btrbk snapshot_preserve — retention policy (daily, weekly, monthly)"; + }; + + snapshotDir = mkOption { + type = types.str; + default = ".snapshots"; + description = "Directory name for snapshots relative to volume root"; + }; + }; + }; + + config = mkIf cfg.enable { + # Enable btrfs kernel support (no DKMS needed — it's in-tree) + boot.supportedFilesystems = [ "btrfs" ]; + + # Install btrfs administration tools + environment.systemPackages = with pkgs; [ + btrfs-progs # mkfs.btrfs, btrfs, fsck, balance, scrub + btrbk # Snapshot management + rotation + ]; + + # LUKS2 unlock at boot (uses keyfile or prompts if unavailable) + # Since the disk may be disconnected, initrd times out gracefully (~30s) + boot.initrd.luks.devices.${luksName} = { + device = "/dev/disk/by-uuid/${cfg.luksUuid}"; + preLVM = false; + allowDiscards = true; + }; + + # Mount the unlocked mapper device as btrfs + fileSystems.${cfg.mountPoint} = { + device = "/dev/mapper/${luksName}"; + fsType = "btrfs"; + options = cfg.btrfsOptions; + }; + + # btrbk — automated snapshot creation and rotation + services.btrbk = mkIf cfg.btrbk.enable { + instances.temp16tb = { + onCalendar = cfg.btrbk.schedule; + settings = { + snapshot_preserve_min = cfg.btrbk.preserveMin; + snapshot_preserve = cfg.btrbk.preserve; + + volume.${cfg.mountPoint} = { + snapshot_create = "always"; + snapshot_dir = cfg.btrbk.snapshotDir; + subvolume = "."; + }; + }; + }; + }; + }; +} -- 2.49.1 From 7a3885a036977b6e56b13c4dd8504a0503046fc0 Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 17 Jun 2026 14:57:37 -0400 Subject: [PATCH 2/2] rename: temp_16tb -> Poup_16T throughout - Module renamed to poup-16t-disk.nix - Option namespace: gortium.poup16t (was gortium.temp16tb) - LUKS name: poup_16t (was temp_16tb) - Mount point: /mnt/Poup_16T (was /mnt/temp_16tb) - btrbk instance: poup16t (was temp16tb) - flake.nix import and host config updated --- assets/compose | 2 +- flake.nix | 2 +- hosts/lazyworkhorse/configuration.nix | 6 +++--- .../{temp-16tb-disk.nix => poup-16t-disk.nix} | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) rename modules/nixos/filesystem/{temp-16tb-disk.nix => poup-16t-disk.nix} (89%) diff --git a/assets/compose b/assets/compose index d3f2e3b..dab158d 160000 --- a/assets/compose +++ b/assets/compose @@ -1 +1 @@ -Subproject commit d3f2e3b7b9dcb03b0bd7df0278faca6b64ea9272 +Subproject commit dab158da0a869262f227d4d35451960ae11b6642 diff --git a/flake.nix b/flake.nix index 5732c05..1d0a6e4 100644 --- a/flake.nix +++ b/flake.nix @@ -65,7 +65,7 @@ ./hosts/lazyworkhorse/configuration.nix ./hosts/lazyworkhorse/hardware-configuration.nix ./modules/nixos/filesystem/hoardingcow-mount.nix - ./modules/nixos/filesystem/temp-16tb-disk.nix + ./modules/nixos/filesystem/poup-16t-disk.nix ./modules/nixos/services/docker_manager.nix ./modules/nixos/services/open_code_server.nix ./modules/nixos/services/ollama_init_custom_models.nix diff --git a/hosts/lazyworkhorse/configuration.nix b/hosts/lazyworkhorse/configuration.nix index dfd5e30..ccb683c 100644 --- a/hosts/lazyworkhorse/configuration.nix +++ b/hosts/lazyworkhorse/configuration.nix @@ -8,10 +8,10 @@ # NAS Mounting hoardingcow-mount.enable = true; - # 16TB btrfs storage disk (WD Red Pro — LUKS2 + btrfs + btrbk snapshots) + # 16TB btrfs storage disk (WD Red Pro — Poup_16T — LUKS2 + btrfs + btrbk snapshots) # ⚠ SETUP REQUIRED: Connect the disk, get the LUKS UUID with 'blkid /dev/sdb', - # then set gortium.temp16tb.luksUuid here and deploy. - # gortium.temp16tb = { + # then set gortium.poup16t.luksUuid here and deploy. + # gortium.poup16t = { # enable = true; # luksUuid = "REPLACE_ME_WITH_REAL_UUID"; # }; diff --git a/modules/nixos/filesystem/temp-16tb-disk.nix b/modules/nixos/filesystem/poup-16t-disk.nix similarity index 89% rename from modules/nixos/filesystem/temp-16tb-disk.nix rename to modules/nixos/filesystem/poup-16t-disk.nix index a0780d5..1cd377c 100644 --- a/modules/nixos/filesystem/temp-16tb-disk.nix +++ b/modules/nixos/filesystem/poup-16t-disk.nix @@ -1,19 +1,19 @@ { config, lib, pkgs, ... }: let - cfg = config.gortium.temp16tb; + cfg = config.gortium.poup16t; luksName = cfg.luksName; in with lib; { - options.gortium.temp16tb = { - enable = mkEnableOption "16TB temp storage disk (btrfs + LUKS + btrbk snapshots)"; + options.gortium.poup16t = { + enable = mkEnableOption "Poup_16T storage disk (btrfs + LUKS + btrbk snapshots)"; luksUuid = mkOption { type = types.str; description = '' - UUID of the LUKS partition on the 16TB disk. + UUID of the LUKS partition on the 16TB disk (WD Red Pro). Find this by running as root when the disk is connected: blkid /dev/sdb # or wherever the disk appears @@ -27,14 +27,14 @@ with lib; luksName = mkOption { type = types.str; - default = "temp_16tb"; + default = "poup_16t"; description = "Name for the LUKS /dev/mapper/ mapping"; }; mountPoint = mkOption { type = types.str; - default = "/mnt/temp_16tb"; - description = "Mount point for the 16TB disk"; + default = "/mnt/Poup_16T"; + description = "Mount point for the 16TB data disk"; }; btrfsOptions = mkOption { @@ -103,7 +103,7 @@ with lib; # btrbk — automated snapshot creation and rotation services.btrbk = mkIf cfg.btrbk.enable { - instances.temp16tb = { + instances.poup16t = { onCalendar = cfg.btrbk.schedule; settings = { snapshot_preserve_min = cfg.btrbk.preserveMin; -- 2.49.1