aboutsummaryrefslogtreecommitdiff
path: root/gnu/home/services/shepherd.scm
blob: 7a9cc064bb890f2e6b93a2ac4c23082112b0d97b (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
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 shepherd)
  #:use-module (gnu home services)
  #:use-module (gnu packages admin)
  #:use-module (gnu services shepherd)
  #:use-module (guix sets)
  #:use-module (guix gexp)
  #:use-module (guix records)

  #:use-module (srfi srfi-1)

  #:export (home-shepherd-service-type
            home-shepherd-configuration)
  #:re-export (shepherd-service
               shepherd-action))

(define-record-type* <home-shepherd-configuration>
  home-shepherd-configuration make-home-shepherd-configuration
  home-shepherd-configuration?
  (shepherd home-shepherd-configuration-shepherd
            (default shepherd)) ; package
  (auto-start? home-shepherd-configuration-auto-start?
               (default #t))
  (services home-shepherd-configuration-services
            (default '())))

(define (home-shepherd-configuration-file services shepherd)
  "Return the shepherd configuration file for SERVICES.  SHEPHERD is used
as shepherd package."
  (assert-valid-graph services)

  (let ((files (map shepherd-service-file services))
        ;; TODO: Add compilation of services, it can improve start
        ;; time.
        ;; (scm->go (cute scm->go <> shepherd))
        )
    (define config
      #~(begin
          (use-modules (srfi srfi-34)
                       (system repl error-handling))
          (apply
           register-services
           (map
            (lambda (file) (load file))
            '#$files))
          (action 'root 'daemonize)
          (format #t "Starting services...~%")
          (for-each
           (lambda (service) (start service))
           '#$(append-map shepherd-service-provision
                          (filter shepherd-service-auto-start?
                                  services)))
          (newline)))

    (scheme-file "shepherd.conf" config)))

(define (launch-shepherd-gexp config)
  (let* ((shepherd (home-shepherd-configuration-shepherd config))
         (services (home-shepherd-configuration-services config)))
    (if (home-shepherd-configuration-auto-start? config)
        (with-imported-modules '((guix build utils))
          #~(let ((log-dir (or (getenv "XDG_LOG_HOME")
                               (format #f "~a/.local/var/log" (getenv "HOME")))))
              ((@ (guix build utils) mkdir-p) log-dir)
              (system*
               #$(file-append shepherd "/bin/shepherd")
               "--logfile"
               (string-append
                log-dir
                "/shepherd.log")
               "--config"
               #$(home-shepherd-configuration-file services shepherd))))
        #~"")))

(define (reload-configuration-gexp config)
  (let* ((shepherd (home-shepherd-configuration-shepherd config))
         (services (home-shepherd-configuration-services config)))
    #~(system*
       #$(file-append shepherd "/bin/herd")
       "load" "root"
       #$(home-shepherd-configuration-file services shepherd))))

(define (ensure-shepherd-gexp config)
  #~(if (file-exists?
         (string-append
          (or (getenv "XDG_RUNTIME_DIR")
              (format #f "/run/user/~a" (getuid)))
          "/shepherd/socket"))
        #$(reload-configuration-gexp config)
        #$(launch-shepherd-gexp config)))

(define-public home-shepherd-service-type
  (service-type (name 'home-shepherd)
                (extensions
                 (list (service-extension
                        home-run-on-first-login-service-type
                        launch-shepherd-gexp)
                       (service-extension
                        home-activation-service-type
                        ensure-shepherd-gexp)
                       (service-extension
                        home-profile-service-type
                        (lambda (config)
                          `(,(home-shepherd-configuration-shepherd config))))))
                (compose concatenate)
                (extend
                 (lambda (config extra-services)
                   (home-shepherd-configuration
                    (inherit config)
                    (services
                     (append (home-shepherd-configuration-services config)
                             extra-services)))))
                (default-value (home-shepherd-configuration))
                (description "Configure and install userland Shepherd.")))


f1816fdc7fc6'>gnu: Build all Rust packages using the latest rustc.Maxim Cournoyer The older Rusts are made private variables; they shouldn't be used by users as they are not tested and are only built at stage 1, which makes them unsuitable to compile Rust applications. * gnu/packages/crates-io.scm (rust-cargo-0.53)[arguments]: Remove #:rust argument. (rust-cxx-1, rust-cxx-build-1, rust-cxx-gen-0.7): Likewise. * gnu/packages/crates-io.scm (rust-cxx-gen-0.7, rust-cxxbridge-macro-1, rust-postgres-0.19): Likewise. (rust-rust-decimal-1, rust-sized-chunks-0.6, rust-socket2-0.4): Likewise. (rust-tokio-postgres-0.7, rust-im-rc-15): Likewise. * gnu/packages/gnome.scm (librsvg): Likewise. * gnu/packages/gnuzilla.scm (mozjs-78): Likewise. * gnu/packages/rust-apps.scm (hyperfine, tectonic rust-analyzer, rust-cargo-c): Likewise. * gnu/packages/shells.scm (nushell): Likewise. * gnu/packages/syndication.scm (newsboat): Likewise. * gnu/packages/rust.scm: (rust-1.39, rust-1.40, rust-1.41, rust-1.42) (rust-1.43, rust-1.44, rust-1.45, rust-1.46, rust-1.47, rust-1.48, rust-1.49) (rust-1.50, rust-1.51, rust-1.52, rust-1.53, rust-1.54): Make variables private. 2021-11-08gnu: packages: Remove last year's deprecations.Tobias Geerinckx-Rice * gnu/packages/admin.scm (guile3.0-shepherd): Remove variable. * gnu/packages/benchmark.scm (imb-openmpi): Likewise. * gnu/packages/boost.scm (boost-with-python3): Likewise. * gnu/packages/pep.scm (python-pep-adapter)[inputs]: Adjust accordingly. * gnu/packages/cpp.scm (nlohmann-json-cpp): Likewise. * gnu/packages/games.scm (openrct2)[inputs]: Adjust accordingly. * gnu/packages/cups.scm (escpr): Likewise. * gnu/packages/django.scm (python-django-jsonfield): Likewise. * gnu/packages/emacs-xyz.scm (emacs-modus-operandi-theme) (emacs-modus-vivendi-theme): Likewise. * gnu/packages/engineering.scm (kicad-i18l): Likewise. * gnu/packages/enlightenment.scm (enlightenment-wayland): Likewise. * gnu/packages/firmware.scm (opensbi-qemu-virt, opensbi-qemu-sifive-u): Likewise. * gnu/packages/fonts.scm (font-gnu-freefont-ttf, font-open-dyslexic): Likewise. * gnu/packages/game-development.scm (guile3.0-chickadee) (python-sge-pygame): Likewise. * gnu/packages/games.scm (retux)[inputs]: Adjust accordingly. * gnu/packages/gnome-xyz.scm (numix-theme): Likewise. * gnu/packages/gnupg.scm (guile3.0-gcrypt): Likewise. * gnu/packages/gstreamer.scm (gst-transcoder): Likewise. * gnu/packages/gtk.scm (guile3.0-cairo, guile3.0-present, guile3.0-rsvg): Likewise. * gnu/packages/guile-xyz.scm (guile3.0-colorized, guile3.0-commonmark) (guile3.0-config, guile3.0-email, guile3.0-fibers, guile3.0-gi) (guile3.0-hall, guile3.0-hashing, guile3.0-haunt, guile3.0-ics) (guile3.0-irregex, guile3.0-lib, guile3.0-mcron, guile3.0-minikanren) (guile3.0-ncurses, guile3.0-ncurses/gpm, guile3.0-newt, guile3.0-parted) (guile3.0-pfds, guile3.0-picture-language, guile3.0-semver) (guile3.0-simple-zmq, guile3.0-squee, guile3.0-syntax-highlight) (guile3.0-websocket, guile3.0-wisp, guile3.0-xapian): Likewise. * gnu/packages/guile.scm (define-deprecated-guile3.0-package) (guile3.0-json, guile3.0-gdbm-ffi, guile3.0-sqlite3) (guile3.0-bytestructures, guile3.0-git): Likewise. * gnu/packages/haskell-apps.scm (ghc-stylish-haskell): Likewise. * gnu/packages/linux.scm (linux-libre-arm-veyron): Likewise. * gnu/packages/mail.scm (guile3.0-mailutils): Likewise. * gnu/packages/monitoring.scm (python2-graphite-web): Likewise. * gnu/packages/package-management.scm (guile3.0-guix): Likewise. * gnu/packages/package-management.scm (python-conda): Likewise. * gnu/packages/phabricator.scm (libphutil): Likewise. * gnu/packages/plotutils.scm (guile3.0-charting): Likewise. * gnu/packages/python-xyz.scm (python2-smmap2, python-glances) (python-smmap2): Likewise. * gnu/packages/shells.scm (oil-shell): Likewise. * gnu/packages/sqlite.scm (sqlite-with-column-metadata): Likewise. * gnu/packages/ssh.scm (guile3.0-ssh): Likewise. * gnu/packages/terminals.scm (et): Likewise. * gnu/packages/tls.scm (guile3.0-gnutls): Likewise. * gnu/packages/vlang.scm (v): Likewise. * gnu/packages/vpn.scm (wireguard): Likewise. * gnu/packages/web-browsers.scm (next, sbcl-next): Likewise. * gnu/packages/xorg.scm (transset-df): Likewise. 2021-11-03Merge remote-tracking branch 'origin/master' into core-updates-frozenEfraim Flashner 2021-11-03gnu: mksh: Update to 59c.Tobias Geerinckx-Rice * gnu/packages/shells.scm (mksh): Update to 59c. [arguments]: Don't explicitly return #t from phases. 2021-11-03gnu: oil: Update to 0.9.3.Tobias Geerinckx-Rice * gnu/packages/shells.scm (oil): Update to 0.9.3. 2021-10-23gnu: Use 'search-input-file' some more.Ludovic Courtès This patch replaces occurrences of: (string-append (assoc-ref %build-inputs "…") "/…") by: (search-input-file %build-inputs "/…") * doc/guix.texi (Miscellaneous Services): Use 'search-input-file' in R Shiny example. * gnu/packages/admin.scm (screenfetch): Use 'search-input-file'. (ufetch): Likewise. (hosts): Likewise. * gnu/packages/backup.scm (dirvish): Likewise. * gnu/packages/code.scm (colormake): Likewise. * gnu/packages/compression.scm (makeself-safeextract): Likewise. * gnu/packages/debug.scm (scanmem): Likewise. * gnu/packages/education.scm (snap): Likewise. (omnitux): Likewise. * gnu/packages/emacs-xyz.scm (epipe): Likewise. * gnu/packages/games.scm (openttd-opensfx): Likewise. (openttd-openmsx): Likewise. (openrct2-title-sequences): Likewise. (openrct2-objects): Likewise. (mrrescue): Likewise. (0ad-data): Likewise. (xonotic-data): Likewise. (drascula): Likewise. (make-lure-package): Likewise. (make-queen-package): Likewise. (sky): Likewise. * gnu/packages/gnome.scm (network-manager): Likewise. * gnu/packages/gnuzilla.scm (icedove): Likewise. * gnu/packages/guile-xyz.scm (guile-shapefile): Likewise. * gnu/packages/hurd.scm (netdde): Likewise. * gnu/packages/javascript.scm (js-context-menu): Likewise. (js-commander): Likewise. (js-xmldom-sre): Likewise. * gnu/packages/kde-frameworks.scm (krunner): Likewise. * gnu/packages/kodi.scm (kodi-cli): Likewise. * gnu/packages/libreoffice.scm (hunspell-dict-pl): Likewise. * gnu/packages/linux.scm (e2fsck/static): Likewise. * gnu/packages/markup.scm (markdown): Likewise. * gnu/packages/maths.scm (hdf-java): Likewise. * gnu/packages/multiprecision.scm (libtomcrypt): Likewise. * gnu/packages/networking.scm (batctl): Likewise. * gnu/packages/python-xyz.scm (python-pymediainfo): Likewise. * gnu/packages/shells.scm (fish-foreign-env): Likewise. * gnu/packages/tex.scm (texlive-fonts-iwona): Likewise. * gnu/packages/upnp.scm (miniupnpc): Likewise. * gnu/packages/version-control.scm (git-annex-remote-rclone): Likewise. * gnu/packages/virtualization.scm (qemu): Likewise. * gnu/packages/web.scm (icedtea-web): Likewise. * gnu/packages/wm.scm (stumpish): Likewise. 2021-10-12Merge remote-tracking branch 'origin/master' into core-updates-frozen.Mathieu Othacehe 2021-09-23gnu: oil: Update to 0.9.2.Felix Gruber * gnu/packages/shells.scm (oil): Update to 0.9.2. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> 2021-09-07Merge branch 'master' into core-updates-frozenLudovic Courtès 2021-09-03gnu: dash: Update to 0.5.11.5.Tobias Geerinckx-Rice * gnu/packages/shells.scm (dash): Update to 0.5.11.5. 2021-08-12Merge branch 'master' into core-updates-frozenMarius Bakke Conflicts: gnu/packages/algebra.scm gnu/packages/games.scm gnu/packages/golang.scm gnu/packages/kerberos.scm gnu/packages/mail.scm gnu/packages/python.scm gnu/packages/ruby.scm gnu/packages/scheme.scm gnu/packages/tex.scm gnu/packages/tls.scm gnu/packages/version-control.scm 2021-07-29Merge branch 'master' into core-updates-frozenMarius Bakke Conflicts: gnu/packages/bioinformatics.scm gnu/packages/cmake.scm gnu/packages/curl.scm gnu/packages/emacs-xyz.scm gnu/packages/gpodder.scm gnu/packages/music.scm gnu/packages/patches/glibc-bootstrap-system.patch gnu/packages/python-xyz.scm gnu/packages/shells.scm gnu/packages/statistics.scm 2021-08-26gnu: nushell: Update to 0.36.0.Nicolas Goaziou * gnu/packages/shells.scm (nushell): Update to 0.36.0. (rust-nu-ansi-term-0.36): (rust-nu-cli-0.36): (rust-nu-command-0.36): (rust-nu-completion-0.36): (rust-nu-data-0.36): (rust-nu-engine-0.36): (rust-nu-errors-0.36): (rust-nu-json-0.36): (rust-nu-parser-0.36): (rust-nu-path-0.36): (rust-nu-plugin-0.36): (rust-nu-plugin-binaryview-0.36): (rust-nu-plugin-chart-0.36): (rust-nu-plugin-fetch-0.36): (rust-nu-plugin-from-bson-0.36): (rust-nu-plugin-from-sqlite-0.36): (rust-nu-plugin-inc-0.36): (rust-nu-plugin-match-0.36): (rust-nu-plugin-post-0.36): (rust-nu-plugin-ps-0.36): (rust-nu-plugin-query-json-0.36): (rust-nu-plugin-s3-0.36): (rust-nu-plugin-selector-0.36): (rust-nu-plugin-start-0.36): (rust-nu-plugin-sys-0.36): (rust-nu-plugin-textview-0.36): (rust-nu-plugin-to-bson-0.36): (rust-nu-plugin-to-sqlite-0.36): (rust-nu-plugin-tree-0.36): (rust-nu-plugin-xpath-0.36): (rust-nu-pretty-hex-0.36): (rust-nu-protocol-0.36): (rust-nu-source-0.36): (rust-nu-stream-0.36): (rust-nu-table-0.36): (rust-nu-test-support-0.36): (rust-nu-value-ext-0.36): Update to 0.36.0. (rust-nu-serde-0.36): New variable. 2021-08-04gnu: nushell: Update to 0.35.0.Nicolas Goaziou * gnu/packages/shells.scm (nushell): (rust-nu-ansi-term-0.35): (rust-nu-cli-0.35): (rust-nu-command-0.35): (rust-nu-completion-0.35): (rust-nu-data-0.35): (rust-nu-engine-0.35): (rust-nu-errors-0.35): (rust-nu-json-0.35): (rust-nu-parser-0.35): (rust-nu-path-0.35): (rust-nu-plugin-0.35): (rust-nu-plugin-binaryview-0.35): (rust-nu-plugin-chart-0.35): (rust-nu-plugin-fetch-0.35): (rust-nu-plugin-from-bson-0.35): (rust-nu-plugin-from-sqlite-0.35): (rust-nu-plugin-inc-0.35): (rust-nu-plugin-match-0.35): (rust-nu-plugin-post-0.35): (rust-nu-plugin-ps-0.35): (rust-nu-plugin-query-json-0.35): (rust-nu-plugin-s3-0.35): (rust-nu-plugin-selector-0.35): (rust-nu-plugin-start-0.35): (rust-nu-plugin-sys-0.35): (rust-nu-plugin-textview-0.35): (rust-nu-plugin-to-bson-0.35): (rust-nu-plugin-to-sqlite-0.35): (rust-nu-plugin-tree-0.35): (rust-nu-plugin-xpath-0.35): (rust-nu-pretty-hex-0.35): (rust-nu-protocol-0.35): (rust-nu-source-0.35): (rust-nu-stream-0.35): (rust-nu-table-0.35): (rust-nu-test-support-0.35): (rust-nu-value-ext-0.35): Update to 0.35.0. 2021-07-27gnu: nushell: Update to 0.34.0.Nicolas Goaziou * gnu/packages/shells.scm (nushell): (rust-nu-ansi-term-0.34): (rust-nu-command-0.34): (rust-nu-data-0.34): (rust-nu-engine-0.34): (rust-nu-errors-0.34): (rust-nu-parser-0.34): (rust-nu-plugin-0.34): (rust-nu-plugin-binaryview-0.34): (rust-nu-plugin-chart-0.34): (rust-nu-plugin-fetch-0.34): (rust-nu-plugin-from-bson-0.34): (rust-nu-plugin-from-sqlite-0.34): (rust-nu-plugin-inc-0.34): (rust-nu-plugin-match-0.34): (rust-nu-plugin-post-0.34): (rust-nu-plugin-ps-0.34): (rust-nu-plugin-query-json-0.34): (rust-nu-plugin-sys-0.34): (rust-nu-plugin-to-bson-0.34): (rust-nu-plugin-to-sqlite-0.34): (rust-nu-plugin-tree-0.34): (rust-nu-plugin-xpath-0.34): (rust-nu-pretty-hex-0.34): (rust-nu-protocol-0.34): (rust-nu-stream-0.34): (rust-nu-test-support-0.34): (rust-nu-value-ext-0.34): Update to 0.34.0. (rust-nu-path-0.34): (rust-nu-completion-0.34): New variable. 2021-07-25gnu: oil: Respect #:tests?.Arun Isaac * gnu/packages/shells.scm (oil)[arguments]: Respect #:tests? in the custom check phase. 2021-07-25gnu: oil: Update to 0.9.0.Felix Gruber * gnu/packages/shells.scm (oil): Update to 0.9.0. Signed-off-by: Arun Isaac <arunisaac@systemreboot.net> 2021-06-29Really revert commit a8b705252bdcb642999258859ada1c2f43706092.Tobias Geerinckx-Rice I give up. 2021-06-29gnu: gnuradio: Build from Git sources.Tobias Geerinckx-Rice * gnu/packages/radio.scm (gnuradio)[source]: Use GIT-FETCH and GIT-FILE-NAME. [arguments]: Add a new 'make-source-writable phase. 2021-06-29Revert parts of "gnu: Add i7z."Tobias Geerinckx-Rice This reverts parts of commit a8b705252bdcb642999258859ada1c2f43706092, because it's apparently revert things day, and also I'm an idiot 2021-06-29gnu: Add i7z.Tobias Geerinckx-Rice * gnu/packages/hardware.scm (i7z): New public variable. 2021-06-19Merge branch 'master' into core-updatesMarius Bakke Note: this merge actually changes the 'curl' and 'python-attrs' derivations, as part of solving caf4a7a2770ef4d05a6e18f40d602e51da749ddc and 12964df69a99de6190422c752fef65ef813f3b6b respectively. 4604d43c0e (gnu: gnutls@3.6.16: Fix cross-compilation.) was ignored because it cannot currently be tested. Conflicts: gnu/local.mk gnu/packages/aidc.scm gnu/packages/boost.scm gnu/packages/curl.scm gnu/packages/nettle.scm gnu/packages/networking.scm gnu/packages/python-xyz.scm gnu/packages/tls.scm 2021-06-16gnu: nushell: Update to 0.32.0.Nicolas Goaziou * gnu/packages/shells.scm (nushell): Update to 0.32.0. (rust-nu-ansi-term-0.32): (rust-nu-cli-0.32): (rust-nu-command-0.32): (rust-nu-data-0.32): (rust-nu-engine-0.32): (rust-nu-errors-0.32): (rust-nu-json-0.32): (rust-nu-parser-0.32): (rust-nu-plugin-0.32): (rust-nu-plugin-binaryview-0.32): (rust-nu-plugin-chart-0.32): (rust-nu-plugin-fetch-0.32): (rust-nu-plugin-from-bson-0.32): (rust-nu-plugin-from-sqlite-0.32): (rust-nu-plugin-inc-0.32): (rust-nu-plugin-match-0.32): (rust-nu-plugin-post-0.32): (rust-nu-plugin-query-json-0.32): (rust-nu-plugin-sys-0.32): (rust-nu-plugin-textview-0.32): (rust-nu-plugin-to-bson-0.32): (rust-nu-plugin-to-sqlite-0.32): (rust-nu-plugin-tree-0.32): (rust-nu-plugin-xpath-0.32): (rust-nu-pretty-hex-0.32): (rust-nu-protocol-0.32): (rust-nu-stream-0.32): (rust-nu-test-support-0.32): (rust-nu-value-ext-0.32): Update to 0.32.0.