The patch does not seem to get formatted correctly, sorry. Hopefully, this should work.
Vivien
From 8dcf1a92cb6ebbc537029f88d5c7197cbf4959aa Mon Sep 17 00:00:00 2001 From: Vivien Kraus <viv...@planete-kraus.eu> Date: Fri, 29 Oct 2021 18:25:24 +0200 Subject: [PATCH] gnu: openssh-service: Collect all keys for all users. * gnu/services/ssh.scm: (authorized-key-directory)[build]: ensure that no key is forgotten. --- gnu/services/ssh.scm | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index a018052eeb..118dfdbef8 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm @@ -415,17 +415,23 @@ (define build (guix build utils)) (mkdir #$output) - (for-each (match-lambda - ((user keys ...) - (let ((file (string-append #$output "/" user))) - (call-with-output-file file - (lambda (port) - (for-each (lambda (key) - (call-with-input-file key - (cut dump-port <> port))) - keys)))))) - '#$keys)))) - + (let ((by-user (make-hash-table))) + (for-each + (match-lambda + ((user keys ...) + (hash-set! by-user user (append (hash-ref by-user user '()) keys)))) + '#$keys) + (hash-for-each + (match-lambda* + ((user keys) + (let ((file (string-append #$output "/" user))) + (call-with-output-file file + (lambda (port) + (for-each (lambda (key) + (call-with-input-file key + (cut dump-port <> port))) + keys)))))) + by-user))))) (computed-file "openssh-authorized-keys" build)) (define (openssh-config-file config) -- 2.33.1