Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ Check [traps](./windows/Multi-booting.md)
```bash
touch ~/.ssh/id_ed25519 && chmod 400 ~/.ssh/id_ed25519
hx ~/.ssh/id_ed25519
echo UPDATESTARTUPTTY | gpg-connect-agent # https://unix.stackexchange.com/a/371910
ssh-add ~/.ssh/id_ed25519
```

1. [Restore encrypted rclone.conf from STDIN](config/rclone.md)
Expand Down
15 changes: 13 additions & 2 deletions home-manager/gpg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@
# - `gpg --armor --export PUBKEY | clip.exe`
# - How to backup private key?
# - `gpg --export-secret-keys --armor > gpg-private.keys.bak`
let
# All gpg-agent timeouts numbers should be specified with the `seconds`
day = 60 * 60 * 24;
in
{
# https://github.com/nix-community/home-manager/blob/release-24.05/modules/services/gpg-agent.nix
services.gpg-agent = {
enable = pkgs.stdenv.isLinux;

# Update [darwin.nix](darwin.nix) if changed this section
#
# TODO: Reconsider the ttls with recent use
#
# https://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session
defaultCacheTtl = 60480000; # 700 days
maxCacheTtl = 60480000; # 700 days
defaultCacheTtl = day * 700;
# https://github.com/openbsd/src/blob/862f3f2587ccb85ac6d8602dd1601a861ae5a3e8/usr.bin/ssh/ssh-agent.1#L167-L173
# ssh-agent sets it as infinite by default. So I can relax here (maybe)
defaultCacheTtlSsh = day * 30;
maxCacheTtl = day * 700;

pinentryPackage = pkgs.pinentry-tty;

enableSshSupport = true;
};

# https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/gpg.nix
Expand Down
5 changes: 3 additions & 2 deletions home-manager/ssh.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ config, ... }:

let
# SSH files cannot use XDG Base Directory.
Expand All @@ -16,7 +16,8 @@ in
# - id_*.pub: I CAN register them for different services.
{
# https://github.com/nix-community/home-manager/blob/release-24.05/modules/services/ssh-agent.nix
services.ssh-agent.enable = pkgs.stdenv.isLinux;
# Prefer gpg-agent for SSH agent role
services.ssh-agent.enable = false;

# https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/ssh.nix
programs.ssh = {
Expand Down
1 change: 1 addition & 0 deletions nixos/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
programs.goldwarden = {
package = edge-pkgs.goldwarden;
enable = true;
useSshAgent = false;
};

# https://nixos.wiki/wiki/Podman
Expand Down
9 changes: 9 additions & 0 deletions nixos/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
gnome-music # does not support flac by defaults
]);

# Recommended to be uninstalled by gnupg.
# https://wiki.gnupg.org/GnomeKeyring
#
# And enabling this makes $SSH_AUTH_SOCK overriding even through enabled gpg-agent in home-manager
# https://github.com/NixOS/nixpkgs/issues/101616
#
# Using mkforce for https://discourse.nixos.org/t/gpg-smartcard-for-ssh/33689/3
services.gnome.gnome-keyring.enable = lib.mkForce false;

# Enable touchpad support (enabled default in most desktopManager).
services.libinput = {
enable = true;
Expand Down