summaryrefslogtreecommitdiff
path: root/gnu/home
diff options
context:
space:
mode:
authorLilah Tascheter <lilah@lunabee.space>2025-11-03 17:17:26 -0600
committerjgart <jgart@dismail.de>2025-12-02 12:49:38 -0600
commit26cb836c4ec695aa1282b077fde99d280f3817e0 (patch)
tree8b02ff7326013b8aad0cb1d0f25e463c6dec8a77 /gnu/home
parentb545538abe6e86c2573d4b8ae100c6dad3c5e068 (diff)
gnu: home: Add himitsu-ssh service.
* gnu/home/services/secrets.scm (remember-option?,list-of-remember-options?): New types. (himitsu-serialize-list-of-remember-options): New serializer. (home-himitsu-ssh-configuration): New configuration. (himitsu-ssh-shepherd-service,himitsu-ssh-himitsu.ini, himitsu-ssh-environment-variables): New procedures. (home-himitsu-ssh-service-type): New service. Change-Id: I051a97aec2396dd899078c594c9d0b989a0aa6f1 Signed-off-by: jgart <jgart@dismail.de>
Diffstat (limited to 'gnu/home')
-rw-r--r--gnu/home/services/secrets.scm66
1 files changed, 65 insertions, 1 deletions
diff --git a/gnu/home/services/secrets.scm b/gnu/home/services/secrets.scm
index 686876fa91a..451a9a9816b 100644
--- a/gnu/home/services/secrets.scm
+++ b/gnu/home/services/secrets.scm
@@ -27,7 +27,10 @@
27 #:use-module (srfi srfi-1) 27 #:use-module (srfi srfi-1)
28 #:export (wrap-himitsu-prompter 28 #:export (wrap-himitsu-prompter
29 home-himitsu-configuration 29 home-himitsu-configuration
30 home-himitsu-service-type)) 30 home-himitsu-service-type
31
32 home-himitsu-ssh-configuration
33 home-himitsu-ssh-service-type))
31 34
32;; 35;;
33;; himitsu 36;; himitsu
@@ -123,3 +126,64 @@ running 'himitsu-store -i' first?")))))
123 (default-value (home-himitsu-configuration)) 126 (default-value (home-himitsu-configuration))
124 (description "Run the Himitsu secret storage manager upon login. You 127 (description "Run the Himitsu secret storage manager upon login. You
125should create the Himitsu database in advance."))) 128should create the Himitsu database in advance.")))
129
130;;
131;; himitsu-ssh
132;;
133
134(define (remember-option? opt)
135 (or (number? opt) (memq opt '(session skip refuse))))
136
137(define list-of-remember-options? (list-of remember-option?))
138
139(define (himitsu-serialize-list-of-remember-options label val)
140 (himitsu-serialize-string label
141 (string-join (map (lambda (x) (cond ((number? x) (number->string x))
142 ((symbol? x) (symbol->string x))))
143 val)
144 ",")))
145
146(define-configuration home-himitsu-ssh-configuration
147 (package (file-like himitsu-ssh) "himitsu-ssh package to use."
148 empty-serializer)
149 (persist (list-of-remember-options '(session 300 refuse)) "List of options
150given when prompting to allow himitsu-ssh to see your keys. The option chosen
151decides how long himitsu-ssh has this access. Options can be either 'session,
152'refuse, 'skip, or a timeout in seconds. 'session means until the daemon
153closes, 'refuse to decline and never ask again, and 'skip means to ask again
154next use.")
155 (disclose (list-of-remember-options '(skip session 300)) "List of options
156given when prompting to allow himitsu-ssh use of your keys. The format is the
157same has persist.")
158 (prefix himitsu-))
159
160(define (himitsu-ssh-shepherd-service config)
161 (let* ((package (home-himitsu-ssh-configuration-package config))
162 (binary (file-append package "/bin/hissh-agent")))
163 (list (shepherd-service
164 (documentation "Start the Himitsu ssh-agent implementation.")
165 (provision '(himitsu-ssh ssh-agent))
166 (requirement '(himitsud))
167 (start #~(make-forkexec-constructor (list #$binary)))
168 (stop #~(make-kill-destructor))))))
169
170(define (himitsu-ssh-himitsu.ini config)
171 (list "[ssh.remember]"
172 (serialize-configuration config home-himitsu-ssh-configuration-fields)))
173
174(define (himitsu-ssh-environment-variables _)
175 '(("SSH_AUTH_SOCK" . "${XDG_RUNTIME_DIR:-/run/user/$UID}/hissh-agent")))
176
177(define home-himitsu-ssh-service-type
178 (service-type
179 (name 'himitsu-ssh)
180 (extensions (list (service-extension home-shepherd-service-type
181 himitsu-ssh-shepherd-service)
182 (service-extension home-himitsu-service-type
183 himitsu-ssh-himitsu.ini)
184 (service-extension home-environment-variables-service-type
185 himitsu-ssh-environment-variables)
186 (service-extension home-profile-service-type
187 (const (list himitsu-ssh)))))
188 (default-value (home-himitsu-ssh-configuration))
189 (description "Add support for ssh to store keys in Himitsu.")))