aboutsummaryrefslogtreecommitdiffstats
path: root/modules/programs/pass
diff options
context:
space:
mode:
Diffstat (limited to 'modules/programs/pass')
-rw-r--r--modules/programs/pass/default.nix69
1 files changed, 69 insertions, 0 deletions
diff --git a/modules/programs/pass/default.nix b/modules/programs/pass/default.nix
new file mode 100644
index 0000000..0d11ab7
--- /dev/null
+++ b/modules/programs/pass/default.nix
@@ -0,0 +1,69 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ cfg = config.programs.pass;
+ githubMapping = ''
+ [github.com]
+ target = github/token
+ username = ${cfg.github.username}
+ username_extractor = static
+
+ [github.com/*]
+ target = github/token
+ username = ${cfg.github.username}
+ username_extractor = static
+
+ [*.github.com]
+ target = github/token
+ username = ${cfg.github.username}
+ username_extractor = static
+
+ [*.github.com/*]
+ target = github/token
+ username = ${cfg.github.username}
+ username_extractor = static
+ '';
+in
+{
+ options.programs.pass = {
+ enable = lib.mkEnableOption "pass password manager";
+
+ package = lib.mkPackageOption pkgs "pass" { };
+
+ storeDir = lib.mkOption {
+ type = lib.types.str;
+ default = "${config.home.homeDirectory}/.password-store";
+ description = "Path to the pass password store.";
+ };
+
+ github = {
+ username = lib.mkOption {
+ type = lib.types.str;
+ default = "x-access-token";
+ description = "Username returned to Git for GitHub HTTPS credentials.";
+ };
+
+ tokenEntry = lib.mkOption {
+ type = lib.types.str;
+ default = "github/token";
+ description = "Pass entry containing the GitHub token on its first line.";
+ };
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ programs.password-store = {
+ enable = true;
+ package = cfg.package;
+ settings = {
+ PASSWORD_STORE_DIR = cfg.storeDir;
+ };
+ };
+
+ home.file.".config/pass-git-helper/git-pass-mapping.ini".text = githubMapping;
+ };
+}