fixed btrfs support configs and swap

This commit is contained in:
2026-06-22 00:28:55 -04:00
parent 61374936cf
commit 67d969f812
10 changed files with 167 additions and 94 deletions
+26
View File
@@ -63,6 +63,32 @@
fileSystems = ["/" "/home" "/nix"];
};
# Snapper — automatic btrfs snapshots so you can roll back
services.snapper = {
enable = true;
# Snapshot / every hour, keep 10 hourly and 7 daily
rootConfig = ''
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
# Snapshot /home every 4 hours
homeConfig = ''
SUBVOLUME="/home"
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="14400"
TIMELINE_LIMIT_HOURLY="6"
TIMELINE_LIMIT_DAILY="14"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
};
# Set your time zone.
time.timeZone = "America/Los_Angeles";
+26
View File
@@ -57,6 +57,32 @@
fileSystems = ["/" "/home" "/nix"];
};
# Snapper — automatic btrfs snapshots so you can roll back
services.snapper = {
enable = true;
# Snapshot / every hour, keep 10 hourly and 7 daily
rootConfig = ''
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
# Snapshot /home every 4 hours
homeConfig = ''
SUBVOLUME="/home"
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="14400"
TIMELINE_LIMIT_HOURLY="6"
TIMELINE_LIMIT_DAILY="14"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
};
# Set your time zone.
time.timeZone = "America/Los_Angeles";
+33 -7
View File
@@ -34,6 +34,39 @@
options = "--delete-older-than 30d";
};
# Btrfs filesystem
services.btrfs.autoScrub = {
enable = true;
interval = "weekly";
fileSystems = ["/" "/home" "/nix"];
};
# Snapper — automatic btrfs snapshots so you can roll back
services.snapper = {
enable = true;
# Snapshot / every hour, keep 10 hourly and 7 daily
rootConfig = ''
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
# Snapshot /home every 4 hours
homeConfig = ''
SUBVOLUME="/home"
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="14400"
TIMELINE_LIMIT_HOURLY="6"
TIMELINE_LIMIT_DAILY="14"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
};
networking.hostName = "buildbox"; # Define your hostname.
# Enable networking
@@ -53,13 +86,6 @@
algorithm = "zstd";
};
# Btrfs auto-scrub
services.btrfs.autoScrub = {
enable = true;
interval = "weekly";
fileSystems = ["/" "/home" "/nix"];
};
# Set your time zone.
time.timeZone = "America/Los_Angeles";
+11 -2
View File
@@ -1,6 +1,7 @@
# ── buildbox disk layout ────────────────────────────────────────
# QEMU VM: Btrfs with subvolumes for snapshot-capable root, home,
# nix store, logs, and snapshot directory.
# QEMU VM: ESP + dedicated swap partition + Btrfs root with
# subvolumes for snapshot-capable root, home, nix store, logs,
# and snapshot directory.
#
# Run from rescue ISO:
# disko --mode disko /etc/disko-config.nix
@@ -26,6 +27,14 @@
mountOptions = ["umask=0077"];
};
};
swap = {
size = "8G";
content = {
type = "swap";
priority = 10;
discardPolicy = "both";
};
};
root = {
size = "100%";
content = {
+35 -1
View File
@@ -12,6 +12,8 @@
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
# Declarative disk layout (consumed by disko + nixos-anywhere).
./disko-config.nix
inputs.home-manager.nixosModules.default
];
@@ -24,7 +26,6 @@
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.graceful = true;
nix.settings.experimental-features = ["nix-command" "flakes"];
# Nix optimizations
@@ -37,6 +38,39 @@
options = "--delete-older-than 30d";
};
# Btrfs filesystem
services.btrfs.autoScrub = {
enable = true;
interval = "weekly";
fileSystems = ["/" "/home" "/nix"];
};
# Snapper — automatic btrfs snapshots so you can roll back
services.snapper = {
enable = true;
# Snapshot / every hour, keep 10 hourly and 7 daily
rootConfig = ''
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
# Snapshot /home every 4 hours
homeConfig = ''
SUBVOLUME="/home"
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
TIMELINE_MIN_AGE="14400"
TIMELINE_LIMIT_HOURLY="6"
TIMELINE_LIMIT_DAILY="14"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
'';
};
networking.hostName = "ender-ml"; # Define your hostname.
# Enable networking
+12 -3
View File
@@ -1,6 +1,7 @@
# ── buildbox disk layout ────────────────────────────────────────
# QEMU VM: Btrfs with subvolumes for snapshot-capable root, home,
# nix store, logs, and snapshot directory.
# ── ender-ml disk layout ────────────────────────────────────────
# QEMU VM: ESP + dedicated swap partition + Btrfs root with
# subvolumes for snapshot-capable root, home, nix store, logs,
# and snapshot directory.
#
# Run from rescue ISO:
# disko --mode disko /etc/disko-config.nix
@@ -26,6 +27,14 @@
mountOptions = ["umask=0077"];
};
};
swap = {
size = "8G";
content = {
type = "swap";
priority = 10;
discardPolicy = "both";
};
};
root = {
size = "100%";
content = {
+7 -15
View File
@@ -1,6 +1,10 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
# Hardware profile for ender-ml (QEMU/KVM VM).
#
# Filesystems, swap, and boot-related disk config are intentionally NOT
# declared here — they are owned by disko via ./disko-config.nix, which
# sets config.fileSystems / config.swapDevices / config.boot when
# disko.enableConfig = true (the default). Keep this file limited to
# kernel modules and platform settings that disko does not manage.
{
config,
lib,
@@ -17,17 +21,5 @@
boot.kernelModules = [];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "/dev/disk/by-uuid/bf8d1e67-f9c0-47ef-a635-2aeef68246a6";
fsType = "ext4";
};
swapDevices = [
{
device = "/var/lib/swapfile";
size = 4 * 1024;
}
];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}
+2
View File
@@ -11,6 +11,8 @@
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
# Declarative disk layout (consumed by disko + nixos-anywhere).
./disko-config.nix
inputs.home-manager.nixosModules.default
];
+8
View File
@@ -26,6 +26,14 @@
];
};
};
swap = {
size = "16G";
content = {
type = "swap";
priority = 10;
discardPolicy = "both";
};
};
root = {
size = "100%";
content = {
+7 -66
View File
@@ -1,6 +1,10 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
# Hardware profile for eva-01 (ThinkPad X1 Nano Gen 1).
#
# Filesystems, swap, and boot-related disk config are intentionally NOT
# declared here — they are owned by disko via ./disko-config.nix, which
# sets config.fileSystems / config.swapDevices / config.boot when
# disko.enableConfig = true (the default). Keep this file limited to
# kernel modules and platform settings that disko does not manage.
{
config,
lib,
@@ -17,70 +21,7 @@
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];
# ── btrfs subvolumes ───────────────────────────────────────────────
# All share the same physical device. Each subvolume can be snapshotted
# and rolled back independently.
#
# IMPORTANT: These subvolumes must exist on disk before this config is
# applied. Create them from a live USB with:
#
# mount /dev/nvme0n1pX /mnt
# btrfs subvolume create /mnt/home
# btrfs subvolume create /mnt/nix
# btrfs subvolume create /mnt/var-log
# btrfs subvolume create /mnt/snapshots
#
fileSystems."/" = {
device = "/dev/disk/by-uuid/0ec1b4fd-ca0f-4938-a038-37a69ec00b21";
fsType = "btrfs";
options = ["subvol=root" "compress=zstd" "discard=async" "noatime"];
};
fileSystems."/home" = {
device = "/dev/disk/by-uuid/0ec1b4fd-ca0f-4938-a038-37a69ec00b21";
fsType = "btrfs";
options = ["subvol=home" "compress=zstd" "discard=async" "noatime"];
};
fileSystems."/nix" = {
device = "/dev/disk/by-uuid/0ec1b4fd-ca0f-4938-a038-37a69ec00b21";
fsType = "btrfs";
options = ["subvol=nix" "compress=zstd" "discard=async" "noatime"];
};
fileSystems."/var/log" = {
device = "/dev/disk/by-uuid/0ec1b4fd-ca0f-4938-a038-37a69ec00b21";
fsType = "btrfs";
options = ["subvol=var-log" "compress=zstd" "discard=async" "noatime"];
neededForBoot = false;
};
fileSystems."/.snapshots" = {
device = "/dev/disk/by-uuid/0ec1b4fd-ca0f-4938-a038-37a69ec00b21";
fsType = "btrfs";
options = ["subvol=snapshots" "compress=zstd" "discard=async" "noatime"];
neededForBoot = false;
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/2066-E44D";
fsType = "vfat";
options = ["fmask=0077" "dmask=0077"];
};
swapDevices = [
{
device = "/var/lib/swapfile";
size = 8 * 1024;
}
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;