{ username ? throw "username argument is required", }: { config, inputs, lib, ... }: let userConfig = config.users.users.${username}; sopsKeyPath = ".config/sops-nix/key.txt"; in { home-manager.users.${username} = { imports = [ inputs.sops-nix.homeManagerModules.sops ]; sops.age.keyFile = "/persist${userConfig.home}/${sopsKeyPath}"; home = { persistence."/persist${userConfig.home}".files = [ sopsKeyPath ]; sessionVariables.SOPS_AGE_KEY_FILE = "${userConfig.home}/${sopsKeyPath}"; }; }; }