From a0e13034700e6a697c1adac3050702a1d3ba0ecd Mon Sep 17 00:00:00 2001 From: sefidel Date: Thu, 11 Jan 2024 14:39:13 +0900 Subject: feat(modules)!: init persistence --- modules/persistence.nix | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 modules/persistence.nix (limited to 'modules/persistence.nix') diff --git a/modules/persistence.nix b/modules/persistence.nix new file mode 100644 index 0000000..4c11588 --- /dev/null +++ b/modules/persistence.nix @@ -0,0 +1,46 @@ +{ 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; + }; + }; + + 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; + } + ]; + }; +} -- cgit 1.4.1