From 7e05e5ddc0101555d41885a2d65f3898b35cc1c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Sun, 29 Jun 2025 15:25:07 +0300 Subject: [PATCH] Switch to impermanence --- flake.lock | 32 ++++++++++++------------- flake.nix | 6 ++--- hosts/siit-dc/configuration.nix | 2 +- shared/base.nix | 41 ++++++++++++-------------------- shared/hardware/impermanence.nix | 2 ++ 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index 3763152..91f9ea8 100644 --- a/flake.lock +++ b/flake.lock @@ -59,6 +59,21 @@ "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" + } + }, "ixx": { "inputs": { "flake-utils": [ @@ -149,27 +164,12 @@ "type": "github" } }, - "preservation": { - "locked": { - "lastModified": 1738541138, - "narHash": "sha256-isT+jR8P8UFh5PJDzGHYXqVEHEZa0D5WvT5kfMf14AM=", - "owner": "nix-community", - "repo": "preservation", - "rev": "2f16754f9f6b766c1429375ab7417dc81cc90a63", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "preservation", - "type": "github" - } - }, "root": { "inputs": { "disko": "disko", + "impermanence": "impermanence", "nixpkgs": "nixpkgs", "nixvim": "nixvim", - "preservation": "preservation", "sops-nix": "sops-nix" } }, diff --git a/flake.nix b/flake.nix index a65faaf..66b58a9 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; }; - preservation.url = "github:nix-community/preservation"; + impermanence.url = "github:nix-community/impermanence"; sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -24,7 +24,7 @@ nixpkgs, nixvim, disko, - preservation, + impermanence, sops-nix, ... }: @@ -53,7 +53,7 @@ ./hosts/${host}/state.nix disko.nixosModules.disko - preservation.nixosModules.preservation + impermanence.nixosModules.impermanence sops-nix.nixosModules.sops ]; } diff --git a/hosts/siit-dc/configuration.nix b/hosts/siit-dc/configuration.nix index 7bf6696..51f8f3f 100644 --- a/hosts/siit-dc/configuration.nix +++ b/hosts/siit-dc/configuration.nix @@ -1,6 +1,6 @@ { lib, ... }: { - preservation.enable = true; + environment.persistence."/persist".enable = true; swapDevices = lib.mkForce [ ]; imports = [ ../../shared/base.nix diff --git a/shared/base.nix b/shared/base.nix index ff352a6..f26da08 100644 --- a/shared/base.nix +++ b/shared/base.nix @@ -34,34 +34,23 @@ ssss ]; - ######################################## Preservation ########################################### - preservation = { + ######################################## Impermanence ########################################### + environment.persistence."/persist" = { enable = lib.mkDefault false; - preserveAt."/persist" = { - files = [ - { - file = "/etc/machine-id"; - inInitrd = true; - } - { - file = "/etc/ssh/ssh_host_rsa_key"; - how = "symlink"; - inInitrd = true; # sops-nix - } - { - file = "/etc/ssh/ssh_host_ed25519_key"; - how = "symlink"; - inInitrd = true; # sops-nix - } - ]; - directories = [ - "/var/lib/systemd/timers" - "/var/lib/nixos" - "/var/log" - ]; - }; + hideMounts = true; + + files = [ + "/etc/machine-id" + "/etc/ssh/ssh_host_rsa_key" + "/etc/ssh/ssh_host_ed25519_key" + ]; + + directories = [ + "/var/lib/systemd/timers" + "/var/lib/nixos" + "/var/log" + ]; }; - systemd.suppressedSystemUnits = [ "systemd-machine-id-commit.service" ]; ######################################## ZSH configuration ###################################### users.defaultUserShell = pkgs.zsh; diff --git a/shared/hardware/impermanence.nix b/shared/hardware/impermanence.nix index a219ca5..26432ce 100644 --- a/shared/hardware/impermanence.nix +++ b/shared/hardware/impermanence.nix @@ -1,5 +1,7 @@ { lib, ... }: { + fileSystems."/persist".neededForBoot = true; + services.zfs = { autoScrub.enable = true; autoSnapshot = {