2022-07-31 11:03:59 +02:00
|
|
|
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
2021-02-28 18:14:01 +01:00
|
|
|
{
|
2022-07-31 11:03:59 +02:00
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.magic_rb.programs.gpg;
|
|
|
|
in {
|
2021-04-11 00:25:36 +02:00
|
|
|
options.magic_rb.programs.gpg = {
|
2022-07-31 11:03:59 +02:00
|
|
|
enable =
|
|
|
|
mkEnableOption
|
2021-04-11 00:25:36 +02:00
|
|
|
''
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
2022-07-31 11:03:59 +02:00
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = with pkgs; [
|
2022-07-31 11:03:59 +02:00
|
|
|
gpg-key-rb
|
2021-04-11 00:25:36 +02:00
|
|
|
gnupg
|
2021-07-10 23:29:51 +02:00
|
|
|
pass
|
2021-04-11 00:25:36 +02:00
|
|
|
];
|
2021-02-28 18:14:01 +01:00
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
home.file.".gpg-agent.conf".text = ''
|
|
|
|
enable-ssh-support
|
2022-07-31 11:03:59 +02:00
|
|
|
pinentry-program ${pkgs.pinentry."${cfg.pinentryFlavor}"}/bin/pinentry
|
2021-04-11 00:25:36 +02:00
|
|
|
'';
|
2021-02-28 20:00:05 +01:00
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
home.file.".profile".text = ''
|
|
|
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
|
|
|
'';
|
2021-02-28 20:10:20 +01:00
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
home.activation.gnupghome = config.lib.dag.entryAfter ["writeBoundary"] ''
|
|
|
|
if [[ ! -e ~/.gnupg ]]
|
|
|
|
then
|
2022-07-31 11:03:59 +02:00
|
|
|
ln -sf /mnt/key/gnupg ~/.gnupg
|
2021-04-11 00:25:36 +02:00
|
|
|
fi
|
2021-03-04 19:24:04 +01:00
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
if [[ ! -e ~/.gnupg/gpg-agent.conf ]] && [[ -d /mnt/key/gnupg ]]
|
|
|
|
then
|
2021-03-04 19:24:04 +01:00
|
|
|
ln -sf ~/.gpg-agent.conf /mnt/key/gnupg/gpg-agent.conf
|
2021-04-11 00:25:36 +02:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2021-02-28 18:14:01 +01:00
|
|
|
}
|