dotfiles/nix/home-manager/modules/gpg.nix

56 lines
1.2 KiB
Nix
Raw Normal View History

{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.magic_rb.programs.gpg;
inherit (config.magic_rb.pkgs) nixpkgs;
in
2021-02-28 18:14:01 +01:00
{
options.magic_rb.programs.gpg = {
enable = mkEnableOption
''
Enable gpg and gpg-key.
'';
pinentryFlavor = mkOption {
description = "Which pinentry flavor should be used.";
type = types.enum [
"curses"
"emacs"
"mac"
"gtk2"
"qt"
"gnome"
];
default = "gtk2";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
nixpkgs.magic_rb.gpg-key
gnupg
pass
];
2021-02-28 18:14:01 +01:00
home.file.".gpg-agent.conf".text = ''
enable-ssh-support
pinentry-program ${nixpkgs.pinentry."${cfg.pinentryFlavor}"}/bin/pinentry
'';
2021-02-28 20:00:05 +01:00
home.file.".profile".text = ''
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
'';
home.activation.gnupghome = config.lib.dag.entryAfter ["writeBoundary"] ''
if [[ ! -e ~/.gnupg ]]
then
ln -sf /mnt/key/gnupg ~/.gnupg
fi
if [[ ! -e ~/.gnupg/gpg-agent.conf ]] && [[ -d /mnt/key/gnupg ]]
then
ln -sf ~/.gpg-agent.conf /mnt/key/gnupg/gpg-agent.conf
fi
'';
};
2021-02-28 18:14:01 +01:00
}