(untested) config for stinky and diff script.

This commit is contained in:
2025-10-27 12:21:57 +00:00
parent 32a22c783d
commit 762037d17f
22 changed files with 899 additions and 37 deletions

View File

@@ -1,6 +1,5 @@
{
pkgs,
inputs,
lib,
config,
...
@@ -9,31 +8,22 @@ let
cfg = config.custom.impermanence;
in
{
# Import common impermanence configuration
imports = [ ./impermanence-common.nix ];
options.custom.impermanence = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable impermanent root fs";
description = "Enable impermanent root fs with btrfs subvolume rollback";
};
};
config = lib.mkIf cfg.enable {
environment.persistence = {
"/persist" = {
directories = [
"/var/lib/nixos"
"/home"
];
files = [
"/etc/machine-id"
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
"/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_rsa_key.pub"
];
};
};
# Use /persist for btrfs-based impermanence
custom.impermanence.persistPath = "/persist";
# Btrfs-specific filesystem options
fileSystems."/".options = [
"compress=zstd"
"noatime"
@@ -53,17 +43,7 @@ in
];
fileSystems."/var/log".neededForBoot = true;
users.mutableUsers = false;
# rollback results in sudo lectures after each reboot
security.sudo.extraConfig = ''
Defaults lecture = never
'';
# needed for allowOther in the home-manager impermanence config
programs.fuse.userAllowOther = true;
# reset / at each boot
# Btrfs subvolume rollback at each boot
# Note `lib.mkBefore` is used instead of `lib.mkAfter` here.
boot.initrd.postDeviceCommands = pkgs.lib.mkBefore ''
mkdir /mnt