48 lines
1004 B
Nix
48 lines
1004 B
Nix
{ inputs, pkgs, ... }:
|
|
|
|
{
|
|
imports = [ inputs.impermanence.nixosModules.impermanence ];
|
|
|
|
boot.initrd.systemd =
|
|
let
|
|
bins = with pkgs; [
|
|
coreutils
|
|
util-linux
|
|
findutils
|
|
btrfs-progs
|
|
];
|
|
in
|
|
{
|
|
initrdBin = bins;
|
|
|
|
services.impermanence = {
|
|
description = "Rollback BTRFS subvolumes to a pristine state";
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
wantedBy = [ "initrd.target" ];
|
|
before = [ "sysroot.mount" ];
|
|
after = [ "cryptsetup.target" ];
|
|
unitConfig.DefaultDependencies = "no";
|
|
|
|
path = bins;
|
|
script = builtins.readFile ./impermanence.sh;
|
|
};
|
|
};
|
|
|
|
fileSystems."/persist".neededForBoot = true;
|
|
|
|
environment.persistence."/persist" = {
|
|
hideMounts = true;
|
|
directories = [
|
|
"/etc/nixos"
|
|
"/etc/NetworkManager/system-connections"
|
|
"/var/lib/nixos"
|
|
"/var/lib/systemd/coredump"
|
|
"/var/log"
|
|
];
|
|
files = [
|
|
"/etc/machine-id"
|
|
];
|
|
};
|
|
}
|