diff options
author | sefidel <contact@sefidel.net> | 2024-01-24 13:29:27 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2024-01-24 18:59:54 +0900 |
commit | 8e9b074467006c76768efe04cf1fb1ef9d652c67 (patch) | |
tree | fad73c7f94a74c77714c260d1fc0a63e2d205b49 /modules/persistence.nix | |
download | infra-modules-8e9b074467006c76768efe04cf1fb1ef9d652c67.tar.gz infra-modules-8e9b074467006c76768efe04cf1fb1ef9d652c67.zip |
Diffstat (limited to 'modules/persistence.nix')
-rw-r--r-- | modules/persistence.nix | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/persistence.nix b/modules/persistence.nix new file mode 100644 index 0000000..e7a8e90 --- /dev/null +++ b/modules/persistence.nix @@ -0,0 +1,47 @@ +{ config, inputs, lib, ... }: + + +with lib; +let + cfg = config.modules.persistence; +in +{ + imports = [ + inputs.impermanence.nixosModules.impermanence + ]; + + options.modules.persistence = { + enable = mkEnableOption "impermanence persistence"; + + storagePath = lib.mkOption { + type = types.path; + description = '' + The path to persistent storage where the real + files and directories should be stored. + ''; + }; + + directories = mkOption { + type = types.listOf types.str; + default = [ ]; + }; + }; + + config = mkIf cfg.enable { + fileSystems.${cfg.storagePath}.neededForBoot = true; + + environment.persistence.${cfg.storagePath}.directories = cfg.directories; + + services.openssh.hostKeys = [ + { + path = "${cfg.storagePath}/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + } + { + path = "${cfg.storagePath}/ssh/ssh_host_rsa_key"; + type = "rsa"; + bits = 4096; + } + ]; + }; +} |