-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
138 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
function load_keys --description 'Load keys from .ssh folder starting with id_' | ||
if status --is-login | ||
for key in (ls $HOME/.ssh/id_* | grep -v pub) | ||
ssh-add -q $key | ||
end | ||
end | ||
end | ||
#function load_keys --description 'Load keys from .ssh folder starting with id_' | ||
# if status --is-login | ||
# for key in (ls $HOME/.ssh/id_* | grep -v pub) | ||
# ssh-add -q $key | ||
# end | ||
# end | ||
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
options, | ||
config, | ||
pkgs, | ||
lib, | ||
inputs, | ||
... | ||
}: | ||
with lib; | ||
with lib.custom; let | ||
cfg = config.system.security.gpg; | ||
|
||
gpgConf = '' | ||
use-agent | ||
pinentry-mode loopback | ||
''; | ||
|
||
gpgAgentConf = '' | ||
enable-ssh-support | ||
default-cache-ttl 28800 | ||
max-cache-ttl 28800 | ||
allow-loopback-pinentry | ||
''; | ||
in { | ||
options.system.security.gpg = with types; { | ||
enable = mkBoolOpt false "Whether or not to enable GPG."; | ||
agentTimeout = mkOpt int 5 "The amount of time to wait before continuing with shell init."; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
# NOTE: This should already have been added by programs.gpg, but | ||
# keeping it here for now just in case. | ||
environment.shellInit = '' | ||
export GPG_TTY="$(tty)" | ||
export SSH_AUTH_SOCK=$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket) | ||
${pkgs.coreutils}/bin/timeout ${builtins.toString cfg.agentTimeout} ${pkgs.gnupg}/bin/gpgconf --launch gpg-agent | ||
gpg_agent_timeout_status=$? | ||
if [ "$gpg_agent_timeout_status" = 124 ]; then | ||
# Command timed out... | ||
echo "GPG Agent timed out..." | ||
echo 'Run "gpgconf --launch gpg-agent" to try and launch it again.' | ||
fi | ||
''; | ||
|
||
environment.systemPackages = with pkgs; [ | ||
gnupg | ||
pinentry-curses | ||
pinentry-qt | ||
]; | ||
|
||
programs = { | ||
ssh.startAgent = false; | ||
|
||
gnupg.agent = { | ||
enable = true; | ||
enableSSHSupport = true; | ||
enableExtraSocket = true; | ||
}; | ||
}; | ||
|
||
home.file = { | ||
".gnupg/.keep".text = ""; | ||
|
||
".gnupg/gpg.conf".text = gpgConf; | ||
".gnupg/gpg-agent.conf".text = gpgAgentConf; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
options, | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
with lib; | ||
with lib.custom; let | ||
cfg = config.custom.security.keyring; | ||
in { | ||
options.custom.security.keyring = with types; { | ||
enable = mkBoolOpt false "Whether to enable gnome keyring."; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = with pkgs; [ | ||
gnome.gnome-keyring | ||
gnome.libgnome-keyring | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters