2024-03-21 05:23:38 +00:00
{ lib , pkgs , . . . }:
2024-02-23 07:19:14 +00:00
{
sane . programs . gnome-keyring = {
2024-02-23 09:09:54 +00:00
packageUnwrapped = pkgs . rmDbusServices pkgs . gnome . gnome-keyring ;
2024-02-23 09:49:35 +00:00
sandbox . method = " b w r a p " ;
sandbox . whitelistDbus = [ " u s e r " ] ;
sandbox . extraRuntimePaths = [
2024-03-16 09:21:28 +00:00
" k e y r i n g " #< only needs keyring/control, but has to *create* that.
# "keyring/control"
2024-02-23 09:49:35 +00:00
] ;
sandbox . capabilities = [
# ipc_lock: used to `mlock` the secrets so they don't get swapped out.
# this is optional, and systemd likely doesn't propagate it anyway
" i p c _ l o c k "
] ;
2024-02-23 07:19:14 +00:00
persist . byStore . private = [
2024-02-23 09:49:35 +00:00
# N.B.: BE CAREFUL WITH THIS.
# gnome-keyring-daemon likes to turn symlinks into dirs. i.e. if it detects that `~/.local/share/keyrings` is a symlink
# it WILL try to `unlink` it and recreate it as an empty directory.
# the only reason i can get away with a symlink here is because gkd is sandboxed... with ~/.local/share/keyrings as an explicit mountpoint instead of as a symlink.
# remove the sandbox, and this breaks.
2024-02-23 07:19:14 +00:00
" . l o c a l / s h a r e / k e y r i n g s "
] ;
2024-02-23 09:49:35 +00:00
fs . " . l o c a l / s h a r e / k e y r i n g s / d e f a u l t " = {
file . text = " D e f a u l t _ k e y r i n g . k e y r i n g " ; #< no trailing newline
2024-02-28 14:19:45 +00:00
# wantedBy = [ config.sane.fs."${config.sane.persist.stores.private.origin}".unit ];
2024-03-21 16:02:06 +00:00
# wantedBeforeBy = [ #< don't create this as part of `multi-user.target`
# "gnome-keyring.service" # TODO: sane.programs should declare this dependency for us
# ];
2024-02-23 09:49:35 +00:00
} ;
# N.B.: certain keyring names have special significance
# `login.keyring` is forcibly encrypted to the user's password, so that pam gnome-keyring can unlock it on login.
# - it does this re-encryption forcibly, any time it wants to write to the keyring.
2024-02-23 08:14:09 +00:00
fs . " . l o c a l / s h a r e / k e y r i n g s / D e f a u l t _ k e y r i n g . k e y r i n g " = {
2024-02-23 08:57:41 +00:00
file . text = ''
[ keyring ]
display-name = Default keyring
lock-on-idle = false
lock-after = false
'' ;
2024-02-28 14:19:45 +00:00
# wantedBy = [ config.sane.fs."${config.sane.persist.stores.private.origin}".unit ];
2024-03-21 16:02:06 +00:00
# wantedBeforeBy = [ #< don't create this as part of `multi-user.target`
# "gnome-keyring.service"
# ];
2024-02-23 07:19:14 +00:00
} ;
2024-02-23 09:09:54 +00:00
services . gnome-keyring = {
description = " g n o m e - k e y r i n g - d a e m o n : s e c r e t p r o v i d e r " ;
2024-03-21 16:02:06 +00:00
partOf = [ " g r a p h i c a l - s e s s i o n " ] ;
2024-03-21 15:05:23 +00:00
command = let
2024-03-21 10:39:42 +00:00
gkr-start = pkgs . writeShellScriptBin " g n o m e - k e y r i n g - d a e m o n - s t a r t " ''
2024-03-21 15:05:23 +00:00
mkdir - m 0700 - p $ XDG_RUNTIME_DIR/keyring
2024-03-21 10:39:42 +00:00
exec gnome-keyring-daemon - - start - - foreground - - components = secrets
'' ;
in " ${ gkr-start } / b i n / g n o m e - k e y r i n g - d a e m o n - s t a r t " ;
2024-02-23 09:09:54 +00:00
} ;
2024-02-23 07:19:14 +00:00
} ;
}