aboutsummaryrefslogtreecommitdiff
path: root/modules/home/tools/gpg/default.nix
blob: 297d9d0b96b8aee689218ee33088512b1b3aa232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ options, config, lib, pkgs, namespace, ... }:

with lib; with lib.${namespace}; let
  cfg = config.${namespace}.tools.gpg;
  impermanence = config.${namespace}.impermanence;
in {
  options.${namespace}.tools.gpg = with types; {
    enable = mkEnableOption "gpg";
  };

  config = mkIf cfg.enable {
    home.persistence.${impermanence.secure.location} = {
      directories = [
        ".gnupg"
      ];
    };

    programs.gpg.enable = true;

    services.gpg-agent = {
      enable = true;
      enableSshSupport = true;
      pinentryPackage = (pkgs.writeShellScriptBin "pinentry-wrapper" ''
        if [[ -v DISPLAY ]]; then
          exec ${pkgs.pinentry-gnome3}/bin/pinentry-gnome3 "$@"
        fi
        
        exec ${pkgs.pinentry-gnome3}/bin/pinentry-tty "$@"
      '');
    };
  };
}