about summary refs log tree commit diff
path: root/home/gpg/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'home/gpg/default.nix')
-rw-r--r--home/gpg/default.nix33
1 files changed, 33 insertions, 0 deletions
diff --git a/home/gpg/default.nix b/home/gpg/default.nix
new file mode 100644
index 0000000..d96c3aa
--- /dev/null
+++ b/home/gpg/default.nix
@@ -0,0 +1,33 @@
+{ config, lib, ... }:
+let cfg = config.my.home.gpg;
+in {
+  options.my.home.gpg = with lib; {
+    enable = mkEnableOption "gpg configuration";
+    pinentry = mkOption {
+      type = types.str;
+      default = "tty";
+      example = "gnome3";
+      description = "Which pinentry interface to use";
+    };
+    defaultKey = mkOption {
+      type = types.str;
+      default = null;
+      description = "Default GPG key";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    programs.gpg = {
+      enable = true;
+      settings = { default-key = cfg.defaultKey; };
+    };
+    services.gpg-agent = {
+      enable = true;
+      enableSshSupport = true; # One agent to rule them all
+      pinentryFlavor = cfg.pinentry;
+      extraConfig = ''
+        allow-loopback-pinentry
+      '';
+    };
+  };
+}