about summary refs log tree commit diff stats
path: root/home-manager/config/gpg/default.nix
blob: 52069c9416c856e1b11dcaa7a5f3552c2142cfd4 (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  config,
  nixosConfig,
  sysLib,
  pkgs,
  ...
}: let
  agent-program = sysLib.writeShellScriptWithLibrary {
    name = "onlykey-gpg-agent";
    src = ./agent-program;
    dependencies = with pkgs; [
      python3
      onlykey-agent
    ];
  };
  settings =
    if nixosConfig.networking.hostName == "isimud"
    then {}
    else {
      # Hardware-based GPG configuration
      agent-program = "${agent-program}/bin/onlykey-gpg-agent";

      default-key = "Soispha <soispha@vhack.eu>";
      # TODO add more
    };
  gpg-agent =
    if nixosConfig.networking.hostName == "isimud"
    then {
      enable = true;
      enableZshIntegration = true;
      enableScDaemon = true; # smartcards and such things
      pinentryFlavor = "tty";
    }
    else {
      enable = false;
      enableZshIntegration = true;
      enableScDaemon = true; # smartcards and such things
      pinentryFlavor = "tty";
    };
in {
  programs.gpg = {
    enable = true;
    homedir = "${config.xdg.dataHome}/gnupg/onlykey";
    mutableKeys = false;
    mutableTrust = false;
    inherit settings;
    publicKeys = [
      {
        source = ./keys/key_1;
        trust = "ultimate";
      }
      {
        source = ./keys/key_2;
        trust = "ultimate";
      }
      {
        source = ./keys/key_3;
        trust = "full";
      }
    ];
  };
  services = {
    inherit gpg-agent;
  };
}