vaultix icon indicating copy to clipboard operation
vaultix copied to clipboard

Make default vaultix.cache derive dynamically from defaultSecretDirectory

Open Malix-Labs opened this issue 3 months ago • 0 comments

Feature Request / Suggestion

Currently in flake-module.nix, both cache and defaultSecretDirectory have independent hardcoded defaults:

cache = mkOption {
  type = ...;
  default = "./secrets/cache";
};

defaultSecretDirectory = mkOption {
  type = ...;
  default = "./secrets";
};

Problem

When a user configures a custom vaultix.defaultSecretDirectory (for example, ./nix/secrets or ./nix/users/<user>/secrets), vaultix.cache remains statically pointed to ./secrets/cache.

As a consequence, running vaultix.app.<system>.renc automatically creates ./secrets/cache at the repository root unless vaultix.cache is also manually and redundantly configured.

Proposed Solution

Derive the default value of cache from submod.config.defaultSecretDirectory:

cache = mkOption {
  type = types.addCheck types.str (s: (builtins.substring 0 1 s) == ".") // {
    description = "path string relative to flake root";
  };
  default = "${submod.config.defaultSecretDirectory}/cache";
  defaultText = lib.literalExpression ''"''${defaultSecretDirectory}/cache"'';
  description = ''
    `path str` relative to flake root, used for storing host public key
    re-encrypted secrets.
  '';
};

This keeps configuration DRY and ensures changing defaultSecretDirectory automatically relocates the re-encryption cache, while keeping the default ./secrets/cache behavior when defaultSecretDirectory is unchanged.

Malix-Labs avatar Aug 19 '26 19:08 Malix-Labs