From d44b9efda2d387430e63c1d6cd426c88bcde2eda Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Tue, 12 Sep 2023 19:42:21 +0200 Subject: Factor out proper Git and GnuPG service types --- tw/home.scm | 132 ------------------------------------------------------------ 1 file changed, 132 deletions(-) (limited to 'tw/home.scm') diff --git a/tw/home.scm b/tw/home.scm index 026c41d8..4065cf3b 100644 --- a/tw/home.scm +++ b/tw/home.scm @@ -48,60 +48,6 @@ zsh zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting zsh-completions)) -(export gnupg-services) ; there doesn't seem to be a `define*-public' macro -(define* (gnupg-services default-key #:key gui-pinentry?) - (list - (simple-service 'gnupg-config home-files-service-type - `(;; GnuPG config files must be in ~/.local/share/gnupg, not ~/.config, - ;; so we can't use `home-xdg-configuration-files-service-type'. - (".local/share/gnupg/dirmngr.conf" - ,(plain-file "dirmngr.conf" "keyserver hkps://keys.openpgp.org")) - (".local/share/gnupg/gpg.conf" - ,(mixed-text-file "gpg.conf" "\ -# This options file can contain any long options to GnuPG. -# See the gpg man page for a list of options. - -default-key " default-key " -default-recipient-self -use-agent -no-greeting # get rid of the copyright notice -# Always encrypt to my key as well, in addition to any recipient. -encrypt-to " default-key " -auto-key-import -auto-key-retrieve -photo-viewer \"" imv "/bin/imv %i\" - -# Because some mailers change lines starting with 'From ' to '>From ' -# it is good to handle such lines in a special way when creating -# cleartext signatures; all other PGP versions do it this way too. -# To enable full OpenPGP compliance you may want to use this option. -#no-escape-from-lines -")) - (".local/share/gnupg/gpg-agent.conf" - ,(mixed-text-file "gpg-agent.conf" "\ -pinentry-program " (if gui-pinentry? - (file-append pinentry-rofi "/bin/pinentry-rofi") - (file-append pinentry-tty "/bin/pinentry-tty")) " -# Keep passphrase cached for longer, so that mcron jobs (e.g. restic, -# vdirsyncer) can access the password store. Vdirsyncer should run every half -# hour to extend the default-cache-ttl. -default-cache-ttl 2100 # 35 min -max-cache-ttl 43200 # 12 h -# Needed if spawning lots of parallel gpg --decrypt processes. https://dev.gnupg.org/T3530 -auto-expand-secmem -")))) - - (simple-service 'gnupg-agent home-shepherd-service-type - (list - (shepherd-service - (documentation "GPG agent; caches key passwords.") - (provision '(gpg-agent)) - (start #~(lambda _ - (invoke #$(file-append gnupg "/bin/gpg-agent") - "--daemon" "--no-detach"))) - (stop #~(lambda _ - (invoke "gpg-connect-agent" "killagent" "/bye")))))))) - (define (wireguardify host) (string-replace-substring host ".twilken.net" ".wg")) @@ -277,7 +223,6 @@ auto-expand-secmem ("ELECTRUMDIR" . "$XDG_DATA_HOME/electrum") ("FG_HOME" . "$XDG_DATA_HOME/fgfs") ("GETIPLAYERUSERPREFS" . "$XDG_DATA_HOME/get_iplayer") - ("GNUPGHOME" . "$XDG_DATA_HOME/gnupg") ("GTK2_RC_FILES" . "$XDG_CONFIG_HOME/gtk-2.0/gtkrc") ("ICEAUTHORITY" . "$XDG_CACHE_HOME/ICEauthority") ("INPUTRC" . "$XDG_CONFIG_HOME/readline/inputrc") @@ -610,80 +555,3 @@ show_border=1 (".local/bin/volume" ,(local-file "home/files/volume" #:recursive? #t)) (".local/share/applications/emacsclient.desktop" ,(local-file "home/files/emacsclient.desktop")))))) - -(define gitconfig-includes - (match-lambda - (() '()) - (((name path _ _) rest ...) - ;; The relative path is relative to the gitconfig file. - (cons (format #f "[includeIf \"gitdir:~a/**\"]\n\tpath = ~aconfig" - (string-trim-right path #\/) name) - (gitconfig-includes rest))) - ((id rest ...) - (cons (format #f "# warning: ignored malformed identity: ~s" id) - (gitconfig-includes rest))))) - -(define gitconfig-otherfiles - (match-lambda - (() '()) - (((name _ email signing-key) rest ...) - `((,(string-append "git/" name "config") - ,(plain-file (string-append "git" name "config") - (string-append - "[user]\n" - (if email (string-append "\temail = " email "\n") "") - (if signing-key (string-append "\tsigningkey = " signing-key "\n") "")))) - ,@(gitconfig-otherfiles rest))) - ((id rest ...) - (format (current-error-port) "warning: ignored malformed gitconfig identity: ~s~%" id) - (gitconfig-otherfiles rest)))) - -(export gitconfig) -(define* (gitconfig default-email default-signing-key #:rest identities) - (simple-service 'gitconfig home-xdg-configuration-files-service-type - `(,@(gitconfig-otherfiles identities) - ("git/config" ,(mixed-text-file "gitconfig" "\ -# This is Git's per-user configuration file. -[user] - name = Timo Wilken - email = " default-email " - signingkey = " default-signing-key - (string-join (gitconfig-includes identities) "\n" 'prefix) " -[commit] - gpgsign = true -[url \"ssh://git@gitlab.cern.ch:7999/\"] - insteadOf = https://gitlab.cern.ch/ -[url \"ssh://git@ssh.github.com/\"] - insteadOf = gh: -[gui] - fontui = -family \\\"Fira Sans\\\" -size 10 -weight normal -slant roman -underline 0 -overstrike 0 - fontdiff = -family \\\"Hermit\\\" -size 10 -weight normal -slant roman -underline 0 -overstrike 0 - tabsize = 4 -[merge] - summary = true - conflictstyle = diff3 -[color] - ui = auto -[pull] - rebase = false - ff = only -[alias] - glog = log --decorate --graph --oneline - plog = log --decorate --graph --oneline --pretty=tformat:\\\"%C(yellow)%h %Cgreen%as %Cblue%<(10,trunc)%an%Cred%d%Creset %s\\\" -[init] - defaultBranch = master -[advice] - detachedHead = false - addEmptyPathspec = false -# https://sw.kovidgoyal.net/kitty/kittens/diff/ -[diff] - tool = kitty - guitool = kitty.gui -[difftool] - prompt = false - trustExitCode = true -[difftool \"kitty\"] - cmd = " kitty "/bin/kitty +kitten diff $LOCAL $REMOTE -[difftool \"kitty.gui\"] - cmd = " kitty "/bin/kitty " kitty "/bin/kitty +kitten diff $LOCAL $REMOTE -"))))) -- cgit v1.2.3