diff --git a/flake.lock b/flake.lock index 9b82395..9addd2c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "impermanence": { + "locked": { + "lastModified": 1661933071, + "narHash": "sha256-RFgfzldpbCvS+H2qwH+EvNejvqs+NhPVD5j1I7HQQPY=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "def994adbdfc28974e87b0e4c949e776207d5557", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1666401273, @@ -17,6 +32,7 @@ }, "root": { "inputs": { + "impermanence": "impermanence", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index aa27bd3..6936142 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,8 @@ { inputs.nixpkgs.url = "nixpkgs/nixos-22.05"; + inputs.impermanence.url = "github:nix-community/impermanence"; - outputs = { self, nixpkgs, ... }: + outputs = { self, nixpkgs, impermanence, ... }: let mypkgs = pkgs: @@ -20,7 +21,7 @@ (builtins.readDir ./pkgs)); forAllSystems = f: nixpkgs.lib.genAttrs - [ "x86_64-linux" "aarch64-linux" ] + [ "x86_64-linux" ] (system: f system); pins = { @@ -40,6 +41,7 @@ mods = { inherit pins; + inherit (impermanence.nixosModules) impermanence; pkgs.nixpkgs.overlays = [ (_: mypkgs) ]; } // nixpkgs.lib.mapAttrs' diff --git a/hosts/levi/default.nix b/hosts/levi/default.nix index 3afc7fc..183161a 100644 --- a/hosts/levi/default.nix +++ b/hosts/levi/default.nix @@ -1,6 +1,6 @@ { config, pkgs, ... }: let - persist = "/var/lib/persist-${config.networking.hostName}"; + persist = "/nix/persist"; in { imports = [ @@ -9,12 +9,8 @@ in environment.etc = { "machine-id".source = "${persist}/machine-id"; - "NetworkManager/system-connections".source = - "${persist}/network-connections"; }; - systemd.tmpfiles.rules = [ "d ${persist}/network-connections 0700" ]; - services.openssh.hostKeys = [ { type = "ed25519"; path = "${persist}/ssh_host_ed25519_key"; } ]; @@ -40,6 +36,14 @@ in wg-home = { enable = true; path = "${persist}/wireguard_home.conf"; }; }; + environment.persistence."${persist}/system".directories = [ + "/etc/NetworkManager/system-connections" + "/var/lib/nixos" + "/var/lib/systemd" + "/var/lib/upower" + "/var/log" + ]; + boot = { loader.systemd-boot.enable = true; loader.efi.canTouchEfiVariables = true; @@ -51,8 +55,6 @@ in "/boot" = { fsType = "vfat"; device = "/dev/nvme0n1p1"; }; "/nix" = { device = "levi/nix"; fsType = "zfs"; }; "/home" = { device = "levi/home"; fsType = "zfs"; }; - "/var/lib" = { device = "levi/lib"; fsType = "zfs"; }; - "/var/log" = { device = "levi/log"; fsType = "zfs"; }; }; users.mutableUsers = false;