From 93dd91a285a717e2323a4694a62c0df9f8f0047b Mon Sep 17 00:00:00 2001 From: Kenny Ballou Date: Tue, 5 Dec 2023 09:57:03 -0700 Subject: config: ssh: concatenate hosts and base config Concatenate all SSH configuration into a single file, symlinked to the usual place. Arbitrary scheme code seems wrong, but this does exactly what we want at build time. Signed-off-by: Kenny Ballou --- kbg/services/config/ssh.scm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'kbg') diff --git a/kbg/services/config/ssh.scm b/kbg/services/config/ssh.scm index af6e2212..e2902ce5 100644 --- a/kbg/services/config/ssh.scm +++ b/kbg/services/config/ssh.scm @@ -4,17 +4,29 @@ #:use-module (guix) #:use-module (gnu home services) #:use-module (kbg packages networking) + #:use-module (ice-9 ftw) + #:use-module (ice-9 textual-ports) #:export (ssh-config-service)) +(define (read-to-string file) + (call-with-input-file file get-string-all)) + +(define ssh-config-files + (map (lambda (f) (string-append %dotfiles-root "config/ssh/ssh/config.d/" f)) + (scandir (string-append %dotfiles-root "config/ssh/ssh/config.d") + (lambda (f) (string-contains f ".conf"))))) + (define ssh-config-service (list (simple-service 'ssh-config home-files-service-type `((".ssh/isup" ,(file-append isup "/bin/isup")) (".ssh/config" - ,(local-file (string-append %dotfiles-root "config/ssh/ssh/config"))) + ,(plain-file "kb-ssh-config" + (string-join (append (map read-to-string ssh-config-files) + (list (read-to-string (string-append + %dotfiles-root + "config/ssh/ssh/config")))) + "\n"))) (".ssh/authorized_keys" - ,(local-file (string-append %dotfiles-root "config/ssh/ssh/authorized_keys"))) - (".ssh/config.d" - ,(local-file (string-append %dotfiles-root "config/ssh/ssh/config.d") - #:recursive? #t)))))) + ,(local-file (string-append %dotfiles-root "config/ssh/ssh/authorized_keys"))))))) -- cgit v1.2.1