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

30 lines
757 B
Nix
Raw Normal View History

{ nixpkgs, nixpkgs-unstable, nixpkgs-master, custom, hostname, rlib, inputs }:
2021-02-28 18:14:01 +01:00
{ config, lib, ... }:
{
home.packages = [
custom.gpg-key
2021-02-28 20:00:05 +01:00
nixpkgs.gnupg
2021-02-28 18:14:01 +01:00
];
home.file.".gpg-agent.conf".text = (pinentryFlavor: ''
enable-ssh-support
pinentry-program ${nixpkgs.pinentry.${pinentryFlavor}}/bin/pinentry
'') "gtk2";
2021-02-28 20:00:05 +01:00
home.file.".profile".text = ''
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
'';
2021-02-28 18:14:01 +01:00
home.activation.gnupghome = config.lib.dag.entryAfter ["writeBoundary"] ''
if [[ ! -e ~/.gnupg ]]
2021-02-28 20:00:05 +01:00
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
2021-02-28 20:00:05 +01:00
fi
2021-02-28 18:14:01 +01:00
'';
}