impermanence: Init module

This commit is contained in:
SebastianStork 2025-09-07 22:05:55 +02:00
parent 0209856439
commit d71748e36a
3 changed files with 58 additions and 0 deletions

16
flake.lock generated
View file

@ -192,6 +192,21 @@
"type": "github" "type": "github"
} }
}, },
"impermanence": {
"locked": {
"lastModified": 1737831083,
"narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "impermanence",
"type": "github"
}
},
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1756750488, "lastModified": 1756750488,
@ -280,6 +295,7 @@
"firefox-addons": "firefox-addons", "firefox-addons": "firefox-addons",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"impermanence": "impermanence",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",

View file

@ -8,6 +8,8 @@
nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-hardware.url = "github:NixOS/nixos-hardware/master";
impermanence.url = "github:nix-community/impermanence";
home-manager = { home-manager = {
url = "github:nix-community/home-manager/release-25.05"; url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -68,6 +70,7 @@
./flake/dev-shell.nix ./flake/dev-shell.nix
./flake/formatter.nix ./flake/formatter.nix
./flake/hosts.nix ./flake/hosts.nix
./flake/install-anywhere.nix
./flake/modules.nix ./flake/modules.nix
./flake/sops.nix ./flake/sops.nix
]; ];

View file

@ -0,0 +1,39 @@
{
config,
inputs,
lib,
...
}:
let
cfg = config.custom.impermanence;
inherit (config.custom) services;
in
{
imports = [ inputs.impermanence.nixosModules.impermanence ];
options.custom.impermanence.enable = lib.mkEnableOption "";
config = lib.mkIf cfg.enable {
fileSystems."/persist".neededForBoot = true;
environment.persistence."/persist" = {
hideMounts = true;
# See https://nixos.org/manual/nixos/stable/#ch-system-state
directories = [
"/var/lib/nixos"
"/var/lib/systemd"
"/var/log/journal"
(lib.optionalString services.tailscale.enable "/var/lib/tailscale")
];
files = [
"/etc/machine-id"
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
];
};
};
}