diff --git a/hosts/common/configs/system/impermanence/options.nix b/hosts/common/configs/system/impermanence/options.nix index 76c27d4..e1fb9ee 100644 --- a/hosts/common/configs/system/impermanence/options.nix +++ b/hosts/common/configs/system/impermanence/options.nix @@ -91,9 +91,9 @@ in ''; }; - _path = mkOption { + path = mkOption { type = str; - internal = true; + readOnly = true; default = name; }; @@ -102,9 +102,9 @@ in internal = true; }; - _source = mkOption { + source = mkOption { type = str; - internal = true; + readOnly = true; }; _targetRoot = mkOption { @@ -112,9 +112,9 @@ in internal = true; }; - _target = mkOption { + target = mkOption { type = str; - internal = true; + readOnly = true; }; }; } @@ -129,18 +129,18 @@ in builtins.mapAttrs ( _: config: let - _path = config._path; + path = config.path; _sourceRoot = persistence; - _source = mergePaths [ + source = mergePaths [ _sourceRoot - _path + path ]; _targetRoot = let - parents = lists.reverseList (parentsOf _path); + parents = lists.reverseList (parentsOf path); in lists.foldl' ( acc: parent: @@ -152,21 +152,21 @@ in acc ) "/" parents; - _target = mergePaths [ + target = mergePaths [ _targetRoot - _path + path ]; in config // { inherit _sourceRoot - _source + source _targetRoot - _target + target ; - service = "${utils.escapeSystemdPath _target}.service"; - mount = "${utils.escapeSystemdPath _target}.mount"; + service = "${utils.escapeSystemdPath target}.service"; + mount = "${utils.escapeSystemdPath target}.mount"; } ) items ) ps; @@ -184,14 +184,14 @@ in systemd = { mounts = builtins.map (c: { - description = c._path; + description = c.path; requiredBy = [ "local-fs.target" ]; requires = [ c.service ]; bindsTo = [ c.service ]; after = [ c.service ]; - unitConfig.ConditionPathExists = [ (lib.strings.escape [ " " ] c._source) ]; - what = c._source; - where = c._target; + unitConfig.ConditionPathExists = [ (lib.strings.escape [ " " ] c.source) ]; + what = c.source; + where = c.target; options = lib.strings.concatStringsSep "," ([ "bind" "X-fstrim.notrim" @@ -201,9 +201,9 @@ in services = builtins.listToAttrs ( builtins.map (c: { - name = utils.escapeSystemdPath c._target; + name = utils.escapeSystemdPath c.target; value = { - description = c._path; + description = c.path; after = [ "local-fs-pre.target" ]; requiredBy = [ "local-fs.target" @@ -227,14 +227,14 @@ in script = '' source=${lib.strings.escapeShellArg c._sourceRoot} target=${lib.strings.escapeShellArg c._targetRoot} - path=${lib.strings.escapeShellArg c._path} + path=${lib.strings.escapeShellArg c.path} ${builtins.readFile ./scripts/start.sh} ''; preStop = '' source=${lib.strings.escapeShellArg c._sourceRoot} target=${lib.strings.escapeShellArg c._targetRoot} - path=${lib.strings.escapeShellArg c._path} + path=${lib.strings.escapeShellArg c.path} ${builtins.readFile ./scripts/stop.sh} ''; @@ -245,7 +245,7 @@ in assertions = let - paths = builtins.map (c: c._path) all; + paths = builtins.map (c: c.path) all; duplicates = lib.lists.filter (t: lib.lists.count (o: o == t) paths > 1) (lib.lists.unique paths); in [ diff --git a/hosts/common/configs/system/sops/default.nix b/hosts/common/configs/system/sops/default.nix index ab7b83d..b2daef7 100644 --- a/hosts/common/configs/system/sops/default.nix +++ b/hosts/common/configs/system/sops/default.nix @@ -1,4 +1,9 @@ -{ inputs, pkgs, ... }: +{ + config, + inputs, + pkgs, + ... +}: { imports = [ inputs.sops-nix.nixosModules.sops ]; @@ -9,7 +14,7 @@ sops.age = { generateKey = true; - sshKeyPaths = [ "/persist/etc/ssh/ssh_host_ed25519_key" ]; + sshKeyPaths = [ config.environment.persistence."/persist"."/etc/ssh/ssh_host_ed25519_key".source ]; keyFile = "/var/lib/sops-nix/key.txt"; }; } diff --git a/hosts/common/configs/user/console/sops/default.nix b/hosts/common/configs/user/console/sops/default.nix index 8b20e86..5023dc2 100644 --- a/hosts/common/configs/user/console/sops/default.nix +++ b/hosts/common/configs/user/console/sops/default.nix @@ -9,10 +9,9 @@ home-manager.users.${user} = { imports = [ inputs.sops-nix.homeManagerModules.sops ]; - sops.age.keyFile = "${home}/.config/sops-nix/key.txt"; - home.sessionVariables.SOPS_AGE_KEY_FILE = "${home}/.config/sops-nix/key.txt"; - systemd.user.services.sops-nix.Unit.After = [ - config.environment.persistence."/persist"."${home}/.config/sops-nix/key.txt".mount - ]; + sops.age.keyFile = + config.environment.persistence."/persist"."${home}/.config/sops-nix/key.txt".source; + home.sessionVariables.SOPS_AGE_KEY_FILE = + config.environment.persistence."/persist"."${home}/.config/sops-nix/key.txt".source; }; }