aboutsummaryrefslogtreecommitdiff
path: root/gnu/home/services/gnupg.scm
blob: 7e9e02a3cce18d57f6e9662c41ac1a6f69d85c1e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu home services gnupg)
  #:use-module (guix gexp)
  #:use-module ((guix records) #:select (match-record))
  #:use-module (gnu services)
  #:use-module (gnu services configuration)
  #:use-module (gnu home services)
  #:use-module (gnu home services shepherd)
  #:autoload   (gnu packages gnupg) (gnupg pinentry)
  #:export (home-gpg-agent-configuration
            home-gpg-agent-configuration?
            home-gpg-agent-configuration-gnupg
            home-gpg-agent-configuration-pinentry-program
            home-gpg-agent-configuration-ssh-support?
            home-gpg-agent-configuration-default-cache-ttl
            home-gpg-agent-configuration-max-cache-ttl
            home-gpg-agent-configuration-max-cache-ttl-ssh
            home-gpg-agent-configuration-extra-content

            home-gpg-agent-service-type))

(define raw-configuration-string? string?)

;; Configuration of 'gpg-agent'.
(define-configuration/no-serialization home-gpg-agent-configuration
  (gnupg
   (file-like gnupg)
   "The GnuPG package to use.")
  (pinentry-program
   (file-like (file-append pinentry "/bin/pinentry-curses"))
   "Pinentry program to use.  Pinentry is a small user interface that
@command{gpg-agent} delegates to anytime it needs user input for a passphrase
or @acronym{PIN, personal identification number} (@pxref{Top,,, pinentry,
Using the PIN-Entry}).")
  (ssh-support?
   (boolean #f)
   "Whether to enable @acronym{SSH, secure shell} support.  When true,
@command{gpg-agent} acts as a drop-in replacement for OpenSSH's
@command{ssh-agent} program, taking care of OpenSSH secret keys and directing
passphrase requests to the chosen Pinentry program.")
  (default-cache-ttl
    (integer 600)
    "Time a cache entry is valid, in seconds.")
  (max-cache-ttl
   (integer 7200)
   "Maximum time a cache entry is valid, in seconds.  After this time a cache
entry will be expired even if it has been accessed recently.")
  (default-cache-ttl-ssh
    (integer 1800)
    "Time a cache entry for SSH keys is valid, in seconds.")
  (max-cache-ttl-ssh
   (integer 7200)
   "Maximum time a cache entry for SSH keys is valid, in seconds.")
  (extra-content
   (raw-configuration-string "")
   "Raw content to add to the end of @file{~/.gnupg/gpg-agent.conf}."))

(define (home-gpg-agent-configuration-file config)
  "Return the @file{gpg-agent.conf} file for @var{config}."
  (match-record config <home-gpg-agent-configuration>
    (pinentry-program default-cache-ttl max-cache-ttl
                      default-cache-ttl-ssh max-cache-ttl-ssh
                      extra-content)
    (mixed-text-file "gpg-agent.conf"
                     "pinentry-program " pinentry-program "\n"
                     "default-cache-ttl "
                     (number->string default-cache-ttl) "\n"
                     "max-cache-ttl "
                     (number->string max-cache-ttl) "\n"
                     "default-cache-ttl-ssh "
                     (number->string default-cache-ttl-ssh) "\n"
                     "max-cache-ttl-ssh "
                     (number->string max-cache-ttl-ssh) "\n"
                     extra-content)))

(define (home-gpg-agent-shepherd-services config)
  "Return the possibly-empty list of Shepherd services for @var{config}."
  (match-record config <home-gpg-agent-configuration>
    (gnupg ssh-support?)
    ;; 'gpg-agent' is started on demand by GnuPG's programs, but it has to be
    ;; started explicitly when OpenSSH support is enabled (info "(gnupg) Agent
    ;; Options").
    (if ssh-support?
        (let ((endpoint (lambda (name socket)
                          #~(endpoint
                             (make-socket-address
                              AF_UNIX
                              (string-append %user-runtime-dir
                                             "/gnupg/" #$socket))
                             #:name #$name
                             #:socket-directory-permissions #o700))))
          (list (shepherd-service
                 (provision '(gpg-agent ssh-agent))
                 (modules '((shepherd support)))  ;for '%user-runtime-dir'
                 (start #~(make-systemd-constructor
                           (list #$(file-append gnupg "/bin/gpg-agent")
                                 "--supervised" "--enable-ssh-support")
                           (list #$(endpoint "ssh" "S.gpg-agent.ssh")
                                 #$(endpoint "browser" "S.gpg-agent.browser")
                                 #$(endpoint "extra" "S.gpg-agent.extra")
                                 ;; #$(endpoint "scdaemon" "S.scdaemon")
                                 #$(endpoint "std" "S.gpg-agent"))))
                 (stop #~(make-systemd-destructor))
                 (documentation "Start 'gpg-agent', the GnuPG passphrase
agent, with support for handling OpenSSH material."))))
        '())))

(define (home-gpg-agent-files config)
  `((".gnupg/gpg-agent.conf" ,(home-gpg-agent-configuration-file config))))

(define (home-gpg-agent-environment-variables config)
  "Return GnuPG environment variables needed for @var{config}."
  (if (home-gpg-agent-configuration-ssh-support? config)
      `(("SSH_AUTH_SOCK"
         . "$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh"))
      '()))

(define home-gpg-agent-service-type
  (service-type
   (name 'home-gpg-agent)
   (extensions
    (list (service-extension home-files-service-type
                             home-gpg-agent-files)
          (service-extension home-shepherd-service-type
                             home-gpg-agent-shepherd-services)
          (service-extension home-environment-variables-service-type
                             home-gpg-agent-environment-variables)))
   (default-value (home-gpg-agent-configuration))
   (description
    "Configure GnuPG's agent, @command{gpg-agent}, which is responsible for
managing OpenPGP and optionally SSH private keys.  When SSH support is
enabled, @command{gpg-agent} acts as a drop-in replacement for OpenSSH's
@command{ssh-agent}.")))
(kbd, sysfsutils, cpuid, libpfm4)[home-page]: Likewise. * gnu/packages/lisp-check.scm (sbcl-ptester, sbcl-xlunit)[home-page]: Likewise. * gnu/packages/lisp-xyz.scm (sbcl-html-encode, sbcl-py-configparser) (sbcl-cl-utilities, sbcl-series, sbcl-uffi, sbcl-clsql, sbcl-sycamore) (sbcl-osicat, sbcl-hu.dwim.common, sbcl-caveman, sbcl-trivial-shell) (sbcl-trivial-benchmark, sbcl-screamer, sbcl-smug)[home-page]: Likewise. * gnu/packages/lisp.scm (lush2)[home-page]: Likewise. * gnu/packages/logging.scm (log4cpp)[home-page]: Likewise. * gnu/packages/lua.scm (lua-ldoc)[home-page]: Likewise. * gnu/packages/machine-learning.scm (mcl, openfst, rxcpp)[home-page]: Likewise. * gnu/packages/mail.scm (muchsync, procmail, sendmail) (opensmtpd-filter-dkimsign, crm114)[home-page]: Likewise. * gnu/packages/man.scm (libpipeline, man-db)[home-page]: Likewise. * gnu/packages/maths.scm (lapack, scalapack, hdf-eos5, itpp, gmsh) (metamath, p4est, armadillo, suitesparse, atlas, lpsolve, wcalc, why3) (frama-c)[home-page]: Likewise. * gnu/packages/mcrypt.scm (mcrypt, libmcrypt, libmhash)[home-page]: Likewise. * gnu/packages/minetest.scm (minetest-advtrains)[home-page]: Likewise. * gnu/packages/monitoring.scm (python-whisper, python-carbon) (hostscope)[home-page]: Likewise. * gnu/packages/mp3.scm (id3lib, libmp3splt, mp3splt, mpg321) (lame)[home-page]: Likewise. * gnu/packages/multiprecision.scm (mpc)[home-page]: Likewise. * gnu/packages/music.scm (aria-maestosa, lingot, setbfree, bristol) (portmidi, python-pyportmidi, zynaddsubfx, yoshimi, aj-snapshot) (schismtracker, midicsv, midicsv, qmidiarp, qmidiroute, dssi, tap-lv2) (shiru-lv2)[home-page]: Likewise. * gnu/packages/ncurses.scm (stfl)[home-page]: Likewise. * gnu/packages/networking.scm (lksctp-tools, mbuffer, ifstatus, bird) (tunctl, traceroute)[home-page]: Likewise. * gnu/packages/node-xyz.scm (node-mersenne)[home-page]: Likewise. * gnu/packages/ntp.scm (openntpd)[home-page]: Likewise. * gnu/packages/ocaml.scm (opam, hevea, ocaml-menhir, ocaml-piqilib) (ocaml-graph, cubicle)[home-page]: Likewise. * gnu/packages/opencl.scm (python-pyopencl)[home-page]: Likewise. * gnu/packages/package-management.scm (xstow, modules)[home-page]: Likewise. * gnu/packages/parallel.scm (xjobs)[home-page]: Likewise. * gnu/packages/pdf.scm (podofo, qpdf, xournal, impressive)[home-page]: Likewise. * gnu/packages/perl.scm (perl-math-vecstat, perltidy)[home-page]: Likewise. * gnu/packages/photo.scm (libpano13, enblend-enfuse, hugin)[home-page]: Likewise. * gnu/packages/plan9.scm (drawterm)[home-page]: Likewise. * gnu/packages/plotutils.scm (guile-charting, ploticus)[home-page]: Likewise. * gnu/packages/popt.scm (argtable, popt)[home-page]: Likewise. * gnu/packages/profiling.scm (otf2)[home-page]: Likewise. * gnu/packages/pulseaudio.scm (pulseaudio)[home-page]: Likewise. * gnu/packages/python-check.scm (python-mypy)[home-page]: Likewise. * gnu/packages/python-web.scm (python-cssutils) (python-translationstring)[home-page]: Likewise. * gnu/packages/python-xyz.scm (python-diskcache, python-doxyqml) (python-docutils, python-pexpect, python-importlib-resources) (python-simplegeneric, python-urwid, python-xlrd, python-xlwt) (python-pyasn1, python-pythondialog, python-tftpy, python-random2) (python-arcp, python-pyopengl, python-sortedcollections) (python-sortedcontainers, python-yapsy, python-pydispatcher) (python-posix-ipc)[home-page]: Likewise. * gnu/packages/qt.scm (qwt, libqglviewer, signond)[home-page]: Likewise. * gnu/packages/radio.scm (unixcw, gnuais)[home-page]: Likewise. * gnu/packages/raspberry-pi.scm (bcm2835)[home-page]: Likewise. * gnu/packages/rdf.scm (clucene, rasqal, redland)[home-page]: Likewise. * gnu/packages/regex.scm (tre)[home-page]: Likewise. * gnu/packages/rsync.scm (librsync)[home-page]: Likewise. * gnu/packages/ruby.scm (ruby-packnga, ruby-nokogiri, ruby-oj, ruby-ox) (ruby-sinatra, ruby-citrus, ruby-cbor, ruby-roda)[home-page]: Likewise. * gnu/packages/scheme.scm (scheme48, tinyscheme)[home-page]: Likewise. * gnu/packages/screen.scm (dtach)[home-page]: Likewise. * gnu/packages/scsi.scm (sg3-utils)[home-page]: Likewise. * gnu/packages/sdl.scm (libmikmod, sdl-pango)[home-page]: Likewise. * gnu/packages/shellutils.scm (hstr, rig)[home-page]: Likewise. * gnu/packages/simulation.scm (python-dolfin-adjoint)[home-page]: Likewise. * gnu/packages/smalltalk.scm (smalltalk)[home-page]: Likewise. * gnu/packages/speech.scm (espeak)[home-page]: Likewise. * gnu/packages/stalonetray.scm (stalonetray)[home-page]: Likewise. * gnu/packages/statistics.scm (jags, r-mass, r-class, r-lattice) (r-matrix, r-nnet, r-spatial, r-bit, r-bit64, r-digest, r-xtable) (python-statsmodels, r-ade4, r-latticeextra, r-rcurl, r-xml, r-mvtnorm) (r-robustbase, r-minqa, r-fdrtool, java-jdistlib, xlispstat)[home-page]: Likewise. * gnu/packages/swig.scm (swig)[home-page]: Likewise. * gnu/packages/task-management.scm (wtime)[home-page]: Likewise. * gnu/packages/tcl.scm (itcl, tclxml, tclx)[home-page]: Likewise. * gnu/packages/terminals.scm (libtermkey, mlterm, libvterm) (libvterm)[home-page]: Likewise. * gnu/packages/tex.scm (texlive-lm, texlive-lm-math, texlive-cs) (texlive-csplain, biber, texmaker)[home-page]: Likewise. * gnu/packages/text-editors.scm (joe)[home-page]: Likewise. * gnu/packages/textutils.scm (drm-tools, docx2txt)[home-page]: Likewise. * gnu/packages/tv.scm (tvtime)[home-page]: Likewise. * gnu/packages/unicode.scm (libunibreak)[home-page]: Likewise. * gnu/packages/upnp.scm (libupnp)[home-page]: Likewise. * gnu/packages/version-control.scm (cvs)[home-page]: Likewise. * gnu/packages/video.scm (transcode, libquicktime, mjpegtools, aalib) (liba52, libmpeg2, x265, libdv, dvdauthor, aegisub, pitivi, gavl) (dvdbackup, guvcview, video-contact-sheet)[home-page]: Likewise. * gnu/packages/virtualization.scm (bochs)[home-page]: Likewise. * gnu/packages/w3m.scm (w3m)[home-page]: Likewise. * gnu/packages/web.scm (qjson, libquvi-scripts, libquvi, quvi) (tidy-html, htmlcxx)[home-page]: Likewise. * gnu/packages/wm.scm (evilwm, menumaker)[home-page]: Likewise. * gnu/packages/wv.scm (wv)[home-page]: Likewise. * gnu/packages/wxwidgets.scm (wxsvg)[home-page]: Likewise. * gnu/packages/xdisorg.scm (mtdev, xsel)[home-page]: Likewise. * gnu/packages/xfig.scm (xfig, transfig)[home-page]: Likewise. * gnu/packages/xml.scm (openjade, python-pyxb, xmlstarlet, xmlrpc-c) (opensp)[home-page]: Likewise. * gnu/packages/xorg.scm (xf86-video-qxl)[home-page]: Likewise. Tobias Geerinckx-Rice 2022-12-11gnu: dpkg: Update to 1.21.12....* gnu/packages/debian.scm (dpkg): Update to 1.21.12. Tobias Geerinckx-Rice 2022-08-14gnu: Remove ‘open source’ from package descriptions....Also do some (trivial) editing where appropriate. * gnu/packages/bioconductor.scm (r-anaquin, r-rcppnumerical) [description]: Remove superfluous ‘open source’. * gnu/packages/debian.scm (apt-mirror)[description]: Likewise. Add @acronym{}. Drop obscure Ubuntu for famous Trisquel. Reorder. * gnu/packages/documentation.scm (scrollkeeper)[description]: Remove superfluous ‘open systems’. Keep ‘Open Source’ in standard name. * gnu/packages/engineering.scm (freecad, cura-engine)[description]: Remove superfluous ‘open source’ and excessive puffery. * gnu/packages/firmware.scm (make-opensbi-package) [synopsis]: Remove ‘Open Source’. Use @acronym{}. [description]: Fix first sentence to follow guidelines. Use @acronym{}. * gnu/packages/game-development.scm (ioquake3, recastnavigation): [description]: Remove ‘open source’. * gnu/packages/graphics.scm (skia)[description]: Likewise. * gnu/packages/lisp-xyz.scm (sbcl-s-sysdeps)[description]: Likewise. * gnu/packages/machine-learning.scm (onnx)[description]: Likewise. Use @acronym{}. * gnu/packages/ocaml.scm (ocaml-cudf)[description]: Likewise. Tobias Geerinckx-Rice 2022-05-29gnu: Add pbuilder....* gnu/packages/debian.scm (pbuilder): New variable. Efraim Flashner 2022-05-22gnu: dpkg: Remove input labels....* gnu/packages/debian.scm (dpkg)[native-inputs]: Remove input labels. Tobias Geerinckx-Rice 2022-05-22gnu: dpkg: Run OpenPGP tests....* gnu/packages/debian.scm (dpkg)[native-inputs]: Add gnupg. Tobias Geerinckx-Rice 2022-05-22gnu: dpkg: Update to 1.21.8 [fixes CVE-2022-1664]....* gnu/packages/debian.scm (dpkg): Update to 1.21.8. Tobias Geerinckx-Rice 2022-05-23gnu: debootstrap: Add missing input....* gnu/packages/debian.scm (debootstrap)[inputs]: Add bash-minimal. Efraim Flashner 2022-05-23gnu: debootstrap: Rewrite using new style....* gnu/packages/debian.scm (debootstrap)[arguments]: Rewrite using g-exps. [inputs]: Remove input labels. Efraim Flashner 2022-05-23gnu: debootstrap: Remove trailing booleans....* gnu/packages/debian.scm (debootstrap)[arguments]: Remove trailing #t from phases. Efraim Flashner 2022-05-23gnu: debootstrap: Patch reference to dpkg....* gnu/packages/debian.scm (debootstrap)[arguments]: Adjust 'patch-source phase to also patch a reference to dpkg. [inputs]: Add dpkg. Efraim Flashner 2022-05-23gnu: dpkg: Fix calling dpkg from perl modules....* gnu/packages/debian.scm (dpkg)[arguments]: Add phase to wrap perl scripts with PERL5LIB and the path to dpkg itself. [inputs]: Add guile-3.0. Efraim Flashner