use nix-community/impermanence module

This commit is contained in:
Sean Buckley 2022-10-25 23:39:52 -04:00
parent 485c286984
commit f25b5e4312
3 changed files with 29 additions and 9 deletions

View file

@ -1,5 +1,20 @@
{ {
"nodes": { "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1666401273, "lastModified": 1666401273,
@ -17,6 +32,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"impermanence": "impermanence",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

@ -1,7 +1,8 @@
{ {
inputs.nixpkgs.url = "nixpkgs/nixos-22.05"; inputs.nixpkgs.url = "nixpkgs/nixos-22.05";
inputs.impermanence.url = "github:nix-community/impermanence";
outputs = { self, nixpkgs, ... }: outputs = { self, nixpkgs, impermanence, ... }:
let let
mypkgs = pkgs: mypkgs = pkgs:
@ -20,7 +21,7 @@
(builtins.readDir ./pkgs)); (builtins.readDir ./pkgs));
forAllSystems = f: nixpkgs.lib.genAttrs forAllSystems = f: nixpkgs.lib.genAttrs
[ "x86_64-linux" "aarch64-linux" ] [ "x86_64-linux" ]
(system: f system); (system: f system);
pins = { pins = {
@ -40,6 +41,7 @@
mods = mods =
{ {
inherit pins; inherit pins;
inherit (impermanence.nixosModules) impermanence;
pkgs.nixpkgs.overlays = [ (_: mypkgs) ]; pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
} // } //
nixpkgs.lib.mapAttrs' nixpkgs.lib.mapAttrs'

View file

@ -1,6 +1,6 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
persist = "/var/lib/persist-${config.networking.hostName}"; persist = "/nix/persist";
in in
{ {
imports = [ imports = [
@ -9,12 +9,8 @@ in
environment.etc = { environment.etc = {
"machine-id".source = "${persist}/machine-id"; "machine-id".source = "${persist}/machine-id";
"NetworkManager/system-connections".source =
"${persist}/network-connections";
}; };
systemd.tmpfiles.rules = [ "d ${persist}/network-connections 0700" ];
services.openssh.hostKeys = [ services.openssh.hostKeys = [
{ type = "ed25519"; path = "${persist}/ssh_host_ed25519_key"; } { type = "ed25519"; path = "${persist}/ssh_host_ed25519_key"; }
]; ];
@ -40,6 +36,14 @@ in
wg-home = { enable = true; path = "${persist}/wireguard_home.conf"; }; 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 = { boot = {
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true; loader.efi.canTouchEfiVariables = true;
@ -51,8 +55,6 @@ in
"/boot" = { fsType = "vfat"; device = "/dev/nvme0n1p1"; }; "/boot" = { fsType = "vfat"; device = "/dev/nvme0n1p1"; };
"/nix" = { device = "levi/nix"; fsType = "zfs"; }; "/nix" = { device = "levi/nix"; fsType = "zfs"; };
"/home" = { device = "levi/home"; 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; users.mutableUsers = false;