Compare commits

...

2 commits

Author SHA1 Message Date
52e3f98cb1
first impermanence config 2023-09-28 17:12:34 +02:00
977bfa7114
fixed a merge thingy in README 2023-09-25 22:03:19 +02:00
6 changed files with 65 additions and 4 deletions

View file

@ -80,10 +80,6 @@ If you have a `nixos-rebuild` available on your system it can automatize these t
`--target-host` parameters. But there are some pitfalls so look at the `nixos-rebuild` documentation beforehand. `--target-host` parameters. But there are some pitfalls so look at the `nixos-rebuild` documentation beforehand.
### On the machine ### On the machine
<<<<<<< HEAD
=======
>>>>>>> d89313e25d9c66bafdaed10bb11716589472bac3
clone this repo to `/etc/nixos/` and `nixos-rebuild boot` or `nixos-rebuild switch` that will select clone this repo to `/etc/nixos/` and `nixos-rebuild boot` or `nixos-rebuild switch` that will select
the appropriate machine based on hostname. the appropriate machine based on hostname.

View file

@ -33,6 +33,21 @@
"type": "indirect" "type": "indirect"
} }
}, },
"impermanence": {
"locked": {
"lastModified": 1694622745,
"narHash": "sha256-z397+eDhKx9c2qNafL1xv75lC0Q4nOaFlhaU1TINqb8=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "e9643d08d0d193a2e074a19d4d90c67a874d932e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "impermanence",
"type": "github"
}
},
"nixos-mailserver": { "nixos-mailserver": {
"inputs": { "inputs": {
"blobs": "blobs", "blobs": "blobs",
@ -139,6 +154,7 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"impermanence": "impermanence",
"nixos-mailserver": "nixos-mailserver", "nixos-mailserver": "nixos-mailserver",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"sops-nix": "sops-nix" "sops-nix": "sops-nix"

View file

@ -14,6 +14,9 @@
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
impermanence = {
url = "github:nix-community/impermanence";
};
}; };
outputs = inputs@{ flake-parts, ... }: outputs = inputs@{ flake-parts, ... }:

View file

@ -21,6 +21,7 @@
imports = [ imports = [
(import (./. + "/machines/${name}/configuration.nix") inputs) (import (./. + "/machines/${name}/configuration.nix") inputs)
inputs.sops-nix.nixosModules.sops inputs.sops-nix.nixosModules.sops
inputs.impermanence.nixosModules.impermanence
]; ];
}; };
in lib.genAttrs machines makeSystem); in lib.genAttrs machines makeSystem);

View file

@ -0,0 +1,42 @@
{lib, config, ...} :
let
inherit (lib)
mkEnableOption
mkIf
mkOption
types
;
cfg = config.impermanence;
in
{
imports = [ ];
options.impermanence = {
enable = mkEnableOption "impermanence";
storagePath = mkOption {
type = types.path;
default = "/persist/persist";
description = "The path where persistent data is stored";
};
name = mkOption {
type = types.str;
default = "persist";
description = "the name of the persistent data store";
};
};
config = mkIf cfg.enable {
environment.persistence.${cfg.name} = {
persistentStoragePath = cfg.storagePath;
directories = [
"/var/log"
"/etc/ssh"
"/var/lib/nixos"
];
};
environment.etc.machine-id.source = "${cfg.storagePath}/machine-id";
};
}

View file

@ -3,6 +3,7 @@
imports = [ imports = [
./admins.nix ./admins.nix
./nix_keys.nix ./nix_keys.nix
../modules/impermanence.nix
]; ];
nix = { nix = {
extraOptions = '' extraOptions = ''
@ -25,6 +26,8 @@ users = {
mutableUsers = false; mutableUsers = false;
}; };
impermanence.enable = true;
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
environment = { environment = {