;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015-2024 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020, 2021 Ricardo Wurmus ;;; Copyright © 2021 raid5atemyhomework ;;; Copyright © 2020 Christine Lemmer-Webber ;;; Copyright © 2020, 2021 Brice Waegeneire ;;; Copyright © 2023 Brian Cully ;;; Copyright © 2024 Nicolas Graves ;;; ;;; 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 FI
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-01-21gnu: perf: Install libraries to lib/ instead of lib64/.Ludovic Courtès
* gnu/packages/linux.scm (perf)[arguments]: Add "lib=lib" to #:make-flags.
2015-01-21gnu: perf: Build the interactive TUI.Ludovic Courtès
* gnu/packages/linux.scm (perf)[inputs]: Add SLANG.
2015-01-21gnu: perf: Build the documentation.Ludovic Courtès
* gnu/packages/linux.scm (perf)[inputs]: Uncomment documentation inputs.
2015-01-21gnu: perf: Add dependency on Python.Ludovic Courtès
* gnu/packages/linux.scm (perf)[inputs]: Add PYTHON-2.
2015-01-17gnu: linux-libre: Update to 3.18.3Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.18.3.
2015-01-16gnu: e2fsck-static: Use really statically-linked executables.Ludovic Courtès
* gnu/packages/linux.scm (e2fsprogs/static): New variable. (e2fsck/static): Use it in 'inputs'.
2015-01-16Merge branch 'core-updates'Ludovic Courtès
Conflicts: gnu/packages/bootstrap.scm
2015-01-13gnu: Add zerofree.Ludovic Courtès
* gnu/packages/linux.scm (zerofree): New variable.
2015-01-13gnu: e2fsprogs: Install libext2fs.Ludovic Courtès
* gnu/packages/linux.scm (e2fsprogs)[source]: Add 'snippet'. [arguments]: Add --enable-elf-shlibs to #:configure-flags. Add #:make-flags.
2015-01-13gnu: wireless-tools: Describe it as deprecated.Ludovic Courtès
* gnu/packages/linux.scm (wireless-tools)[description]: Explain that it is deprecated in favor of 'iw'.
2015-01-13Merge branch 'master' into core-updatesMark H Weaver
2015-01-12gnu: Add iw.Mark H Weaver
* gnu/packages/linux.scm (iw): New variable.
2015-01-12gnu: libnl: Update to 3.2.25.Mark H Weaver
* gnu/packages/linux.scm (libnl): Update to 3.2.25.
2015-01-11Merge branch 'master' into core-updatesMark H Weaver
2015-01-09gnu: linux-libre: Update to 3.18.2Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.18.2.
2015-01-06gnu: udev: Remove package, now superceded by eudev.Mark H Weaver
* gnu/packages/linux.scm (udev): Remove. (eudev): Incorporate fields formerly inherited from udev.
2015-01-06gnu: lvm2: Switch to eudev from udev.Mark H Weaver
* gnu/packages/linux.scm (lvm2)[inputs]: Use eudev, not udev.
2014-12-29gnu: Revert use of '--strip-all'.Ludovic Courtès
This reverts commits f05bdc9412135f34a1c417edc203c35cd005d0d5 and 856ae5e6c71a1283a414d33e638051f95d3cce35. This broke all sorts of things. See <http://hydra.gnu.org/eval/102058>, for example.
2014-12-27build-system/gnu: Strip with '--strip-all' instead of '--strip-debug'.Ludovic Courtès
This saves 19% on the 'bin' directory of Coreutils, and certainly helpful for things like Git's 'libexec' directory. * guix/build-system/gnu.scm (gnu-build): Change default value for #:strip-flags to '("--strip-all"). * guix/build/gnu-build-system.scm (strip): Ditto. * gnu/packages/linux.scm (linux-libre)[arguments]: Add #:strip-flags.
2014-12-27gnu: Use patch --force instead of --batch.Mark H Weaver
* gnu/packages/linux.scm (linux-libre, net-tools): Pass "--force" to patch, instead of "--batch". * gnu/packages/mit-krb5.scm (mit-krb5): Ditto.
2014-12-17gnu: linux-libre: Update to 3.18.1Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.18.1.
2014-12-07gnu: linux-libre: Update to 3.18Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.18.
2014-11-29gnu: wireless-tools: Install the manual pages under $out/share/man.宋文武
* gnu/packages/linux.scm (wireless-tools)[origin]: Add snippet. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2014-11-22gnu: linux-libre: Update to 3.17.4Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.17.4.
2014-11-20gnu: Add pflask.David Thompson
* gnu/packages/linux.scm (pflask): New variable.
2014-11-14gnu: linux-libre: Update to 3.17.3Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.17.3.
2014-10-30gnu: linux-libre: Update to 3.17.2.Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.17.2.
2014-10-26gnu: Some cleanup based on lint checkers.Eric Bavier
* gnu/packages/admin.scm, gnu/packages/aidc.scm, gnu/packages/algebra.scm, gnu/packages/apr.scm, gnu/packages/avahi.scm, gnu/packages/backup.scm, gnu/packages/base.scm, gnu/packages/calcurse.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/compression.scm, gnu/packages/cook.scm, gnu/packages/crypto.scm, gnu/packages/cryptsetup.scm, gnu/packages/curl.scm, gnu/packages/cyrus-sasl.scm, gnu/packages/databases.scm, gnu/packages/doxygen.scm, gnu/packages/dwm.scm, gnu/packages/elf.scm, gnu/packages/emacs.scm, gnu/packages/feh.scm, gnu/packages/file.scm, gnu/packages/fish.scm, gnu/packages/flex.scm, gnu/packages/fltk.scm, gnu/packages/fontutils.scm, gnu/packages/games.scm, gnu/packages/gcal.scm, gnu/packages/gcc.scm, gnu/packages/geeqie.scm, gnu/packages/ghostscript.scm, gnu/packages/gimp.scm, gnu/packages/gl.scm, gnu/packages/glib.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gperf.scm, gnu/packages/grub.scm, gnu/packages/gsasl.scm, gnu/packages/gtk.scm, gnu/packages/guile-wm.scm, gnu/packages/guile.scm, gnu/packages/hurd.scm, gnu/packages/icu4c.scm, gnu/packages/image.scm, gnu/packages/imagemagick.scm, gnu/packages/irssi.scm, gnu/packages/kde.scm, gnu/packages/libdaemon.scm, gnu/packages/libevent.scm, gnu/packages/libidn.scm, gnu/packages/libusb.scm, gnu/packages/linux.scm, gnu/packages/lout.scm, gnu/packages/lsh.scm, gnu/packages/lsof.scm, gnu/packages/lua.scm, gnu/packages/maths.scm, gnu/packages/mcrypt.scm, gnu/packages/mp3.scm, gnu/packages/netpbm.scm, gnu/packages/noweb.scm, gnu/packages/ocaml.scm, gnu/packages/openssl.scm, gnu/packages/pcre.scm, gnu/packages/pdf.scm, gnu/packages/pkg-config.scm, gnu/packages/pretty-print.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/rsync.scm, gnu/packages/scheme.scm, gnu/packages/scrot.scm, gnu/packages/sdl.scm, gnu/packages/skribilo.scm, gnu/packages/ssh.scm, gnu/packages/stalonetray.scm, gnu/packages/tcl.scm, gnu/packages/tcsh.scm, gnu/packages/telephony.scm, gnu/packages/texlive.scm, gnu/packages/tor.scm, gnu/packages/valgrind.scm, gnu/packages/version-control.scm, gnu/packages/vim.scm, gnu/packages/vpn.scm, gnu/packages/w3m.scm, gnu/packages/web.scm, gnu/packages/wordnet.scm, gnu/packages/xiph.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/packages/zile.scm, gnu/packages/zip.scm, gnu/packages/zsh.scm [synopsis, description]: Adjust according to lint checkers. * gnu/packages/fltk.scm (fltk)[source]: Wrap long line in uri. * /gnu/packages/xiph.scm (libogg, libtheora, vorbis-tools)[source]: Same.
2014-10-16gnu: linux-libre: Update to 3.17.1.Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.17.1.
2014-10-07gnu: eudev: Really update to 1.10.Ludovic Courtès
* gnu/packages/linux.scm (eudev)[version]: Fix typo. [source]: Add 'snippet'.
2014-10-06gnu: eudev: Update to 1.10.Jason Self
* gnu/packages/linux.scm (eudev): Update to version 1.10.
2014-10-06gnu: net-tools: Allow compilation with current libc and GCC.Ludovic Courtès
* gnu/packages/patches/net-tools-bitrot.patch: New file. * gnu/packages/linux.scm (net-tools): Use it. * gnu-system.am (dist_patch_DATA): Add it.
2014-10-06gnu: linux-libre: Update to 3.17.Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.17.
2014-10-05gnu: linux-libre: Update to 3.16.4.Jason Self
* gnu/packages/linux.scm (libogg): Update to version 3.16.4.
2014-09-30gnu: Add perf.Ludovic Courtès
* gnu/packages/linux.scm (perf): New variable.
2014-09-23gnu: linux-libre: Work around GCC 4.8.3 ICE.Ludovic Courtès
* gnu/packages/linux.scm (linux-libre)[inputs]: New field.
2014-09-22Merge branch 'core-updates'Ludovic Courtès
2014-09-18gnu: linux-libre: Update to 3.16.3.Jason Self
* gnu/packages/linux.scm (linux-libre): Update to version 3.16.3.
2014-09-13Merge branch 'master' into core-updatesMark H Weaver
Conflicts: gnu-system.am
2014-09-13gnu: Adjust synopses as recommended by 'guix lint'.Ludovic Courtès
Remove leading articles and trailing periods in package synopses.
2014-09-13gnu: eudev: Honor $EUDEV_RULES_DIRECTORY.Ludovic Courtès
* gnu/packages/patches/eudev-rules-directory.patch: New file. * gnu-system.am (dist_patch_DATA): Add it. * gnu/packages/linux.scm (eudev): Use it.
2014-09-13gnu: eudev: Build with libkmod support.Ludovic Courtès
* gnu/packages/linux.scm (eudev)[arguments]: New field.
2014-09-13gnu: fuse: Install udev rules in lib/udev/rules.d.Ludovic Courtès
* gnu/packages/linux.scm (fuse): Change UDEV_RULES_PATH suffix to /lib/udev/rules.d.
2014-09-12Revert "gnu: util-linux: Don't install 'logger'."Ludovic Courtès
This reverts commit c9a8ad847712dfa4811608efae2d48cb8500f72f.
2014-09-12gnu: util-linux: Don't install 'logger'.Ludovic Courtès
* gnu/packages/linux.scm (util-linux)[source]: Add 'snippet'.
2014-09-12gnu: Add eudev.Ludovic Courtès
* gnu/packages/linux.scm (eudev): New variable.
2014-09-12gnu: util-linux: Don't install 'logger'.Ludovic Courtès
* gnu/packages/linux.scm (util-linux)[source]: Add 'snippet'.
2014-09-12gnu: e2fsprogs: Build with --disable-blkid.Ludovic Courtès
* gnu/packages/linux.scm (e2fsprogs)[arguments]: Pass --disable-blkid.
2014-09-10gnu: lvm2: Programs such as 'dmsetup' now have a correct RUNPATH.Ludovic Courtès
* gnu/packages/linux.scm (alsa-utils): Add comment. (lvm2): Add LDFLAGS as a configure flag.
2014-09-08gnu: Consolidate databases in (gnu packages databases).Ludovic Courtès
* gnu/packages/databases.scm: New file, with the contents of the following deleted files. * gnu/packages/mysql.scm, gnu/packages/postgresql.scm, gnu/packages/recutils.scm, gnu/packages/sqlite.scm, gnu/packages/bdb.scm: Remove. * gnu-system.am (GNU_SYSTEM_MODULES): Adjust accordingly. * gnu/packages/apl.scm, gnu/packages/dc.scm, gnu/packages/games.scm, gnu/packages/gnunet.scm, gnu/packages/linux.scm, gnu/packages/mail.scm, gnu/packages/mpd.scm, gnu/packages/nvi.scm, gnu/packages/openldap.scm, gnu/packages/package-management.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/rdf.scm, gnu/packages/version-control.scm: Adjust to new module name.
-monad ((activate (lower-object (activation-script gexps)))) (return `(("activate" ,activate))))) (define (second-argument a b) b) (define activation-service-type (service-type (name 'activate) (extensions (list (service-extension boot-service-type gexps->activation-gexp) (service-extension system-service-type activation-profile-entry))) (compose identity) (extend second-argument) (default-value #f) (description "Run @dfn{activation} code at boot time and upon @command{guix system reconfigure} completion."))) (define %activation-service ;; The activation service produces the activation script from the gexps it ;; receives. (service activation-service-type #t)) (define %modprobe-wrapper ;; Wrapper for the 'modprobe' command that knows where modules live. ;; ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe', ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY' ;; environment variable is not set---hence the need for this wrapper. (let ((modprobe "/run/current-system/profile/bin/modprobe")) (program-file "modprobe" #~(begin (setenv "LINUX_MODULE_DIRECTORY" "/run/booted-system/kernel/lib/modules") ;; FIXME: Remove this crutch when the patch #40422, ;; updating to kmod 27 is merged. (setenv "MODPROBE_OPTIONS" "-C /etc/modprobe.d") (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))) (define %linux-kernel-activation ;; Activation of the Linux kernel running on the bare metal (as opposed to ;; running in a container.) #~(begin ;; Tell the kernel to use our 'modprobe' command. (activate-modprobe #$%modprobe-wrapper) ;; Let users debug their own processes! (activate-ptrace-attach))) (define %linux-bare-metal-service ;; The service that does things that are needed on the "bare metal", but not ;; necessary or impossible in a container. (simple-service 'linux-bare-metal activation-service-type %linux-kernel-activation)) (define %hurd-rc-script ;; The RC script to be started upon boot. (program-file "rc" (with-imported-modules (source-module-closure '((guix build utils) (gnu build hurd-boot) (guix build syscalls))) #~(begin (use-modules (guix build utils) (gnu build hurd-boot) (guix build syscalls) (ice-9 match) (system repl repl) (srfi srfi-1) (srfi srfi-26)) (boot-hurd-system))))) (define (hurd-rc-entry rc) "Return, as a monadic value, an entry for the RC script in the system directory." (mlet %store-monad ((rc (lower-object rc))) (return `(("rc" ,rc))))) (define hurd-startup-service-type ;; The service that creates the initial SYSTEM/rc startup file. (service-type (name 'startup) (extensions (list (service-extension system-service-type hurd-rc-entry))) (default-value %hurd-rc-script) (description "This service creates an @file{rc} script in the system; that script is responsible for booting the Hurd."))) (define %hurd-startup-service ;; The service that produces the RC script. (service hurd-startup-service-type %hurd-rc-script)) (define special-files-service-type ;; Service to install "special files" such as /bin/sh and /usr/bin/env. (service-type (name 'special-files) (extensions (list (service-extension activation-service-type (lambda (files) #~(activate-special-files '#$files))))) (compose concatenate) (extend append) (description "Add special files to the root file system---e.g., @file{/usr/bin/env}."))) (define (extra-special-file file target) "Use TARGET as the \"special file\" FILE. For example, TARGET might be (file-append coreutils \"/bin/env\") and FILE could be \"/usr/bin/env\"." (simple-service (string->symbol (string-append "special-file-" file)) special-files-service-type `((,file ,target)))) (define (etc-directory service) "Return the directory for SERVICE, a service of type ETC-SERVICE-TYPE." (files->etc-directory (service-value service))) (define (files->etc-directory files) (define (assert-no-duplicates files) (let loop ((files files) (seen (set))) (match files (() #t) (((file _) rest ...) (when (set-contains? seen file) (raise (formatted-message (G_ "duplicate '~a' entry for /etc") file))) (loop rest (set-insert file seen)))))) ;; Detect duplicates early instead of letting them through, eventually ;; leading to a build failure of "etc.drv". (assert-no-duplicates files) (file-union "etc" files)) (define (etc-entry files) "Return an entry for the /etc directory consisting of FILES in the system directory." (with-monad %store-monad (return `(("etc" ,(files->etc-directory files)))))) (define etc-service-type (service-type (name 'etc) (extensions (list (service-extension activation-service-type (lambda (files) (let ((etc (files->etc-directory files))) #~(activate-etc #$etc)))) (service-extension system-service-type etc-entry))) (compose concatenate) (extend append) (default-value '()) (description "Populate the @file{/etc} directory."))) (define-deprecated (etc-service files) etc-service-type "Return a new service of ETC-SERVICE-TYPE that populates /etc with FILES. FILES must be a list of name/file-like object pairs." (service etc-service-type files)) (define (setuid-program->activation-gexp programs) "Return an activation gexp for setuid-program from PROGRAMS." (let ((programs (map (lambda (program) ;; FIXME This is really ugly, I didn't managed to use ;; "inherit" (let ((program-name (setuid-program-program program)) (setuid? (setuid-program-setuid? program)) (setgid? (setuid-program-setgid? program)) (user (setuid-program-user program)) (group (setuid-program-group program)) ) #~(setuid-program (setuid? #$setuid?) (setgid? #$setgid?) (user #$user) (group #$group) (program #$program-name)))) programs))) (with-imported-modules (source-module-closure '((gnu system setuid))) #~(begin (use-modules (gnu system setuid)) (activate-setuid-programs (list #$@programs)))))) (define setuid-program-service-type (service-type (name 'setuid-program) (extensions (list (service-extension activation-service-type setuid-program->activation-gexp))) (compose concatenate) (extend (lambda (config extensions) (append config extensions))) (description "Populate @file{/run/setuid-programs} with the specified executables, making them setuid and/or setgid."))) (define (packages->profile-entry packages) "Return a system entry for the profile containing PACKAGES." ;; XXX: 'mlet' is needed here for one reason: to get the proper ;; '%current-target' and '%current-target-system' bindings when ;; 'packages->manifest' is called, and thus when the 'package-inputs' ;; etc. procedures are called on PACKAGES. That way, conditionals in those ;; inputs see the "correct" value of these two parameters. See ;; . (mlet %store-monad ((_ (current-target-system))) (return `(("profile" ,(profile (content (packages->manifest (delete-duplicates packages eq?))))))))) (define profile-service-type ;; The service that populates the system's profile---i.e., ;; /run/current-system/profile. It is extended by package lists. (service-type (name 'profile) (extensions (list (service-extension system-service-type packages->profile-entry))) (compose concatenate) (extend append) (default-value '()) (description "This is the @dfn{system profile}, available as @file{/run/current-system/profile}. It contains packages that the sysadmin wants to be globally available to all the system users."))) (define (firmware->activation-gexp firmware) "Return a gexp to make the packages listed in FIRMWARE loadable by the kernel." (let ((directory (directory-union "firmware" firmware))) ;; Tell the kernel where firmware is. #~(activate-firmware (string-append #$directory "/lib/firmware")))) (define firmware-service-type ;; The service that collects firmware. (service-type (name 'firmware) (extensions (list (service-extension activation-service-type firmware->activation-gexp))) (compose concatenate) (extend append) (description "Make ``firmware'' files loadable by the operating system kernel. Firmware may then be uploaded to some of the machine's devices, such as Wifi cards."))) (define (gc-roots->system-entry roots) "Return an entry in the system's output containing symlinks to ROOTS." (mlet %store-monad ((entry (gexp->derivation "gc-roots" #~(let ((roots '#$roots)) (mkdir #$output) (chdir #$output) (for-each symlink roots (map number->string (iota (length roots)))))))) (return (if (null? roots) '() `(("gc-roots" ,entry)))))) (define gc-root-service-type ;; A service to associate extra garbage-collector roots to the system. This ;; is a simple hack that guarantees that the system retains references to ;; the given list of roots. Roots must be "lowerable" objects like ;; packages, or derivations. (service-type (name 'gc-roots) (extensions (list (service-extension system-service-type gc-roots->system-entry))) (compose concatenate) (extend append) (description "Register garbage-collector roots---i.e., store items that will not be reclaimed by the garbage collector.") (default-value '()))) ;; Configuration for the Linux kernel builder. (define-record-type* linux-builder-configuration make-linux-builder-configuration linux-builder-configuration? this-linux-builder-configuration (kernel linux-builder-configuration-kernel) ; package (modules linux-builder-configuration-modules (default '()))) ; list of packages (define (package-for-kernel target-kernel module-package) "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if possible (that is if there's a LINUX keyword argument in the build system)." (package (inherit module-package) (arguments (substitute-keyword-arguments (package-arguments module-package) ((#:linux kernel #f) target-kernel))))) (define (linux-builder-configuration->system-entry config) "Return the kernel entry of the 'system' directory." (let* ((kernel (linux-builder-configuration-kernel config)) (modules (linux-builder-configuration-modules config)) (kernel (profile (content (packages->manifest (cons kernel (map (lambda (module) (cond ((package? module) (package-for-kernel kernel module)) ;; support (,package "kernel-module-output") ((and (list? module) (package? (car module))) (cons (package-for-kernel kernel (car module)) (cdr module))) (else module))) modules)))) (hooks (list linux-module-database))))) (with-monad %store-monad (return `(("kernel" ,kernel)))))) (define linux-builder-service-type (service-type (name 'linux-builder) (extensions (list (service-extension system-service-type linux-builder-configuration->system-entry))) (default-value '()) (compose identity) (extend (lambda (config modifiers) (if (null? modifiers) config ((apply compose modifiers) config)))) (description "Builds the linux-libre kernel profile, containing the kernel itself and any linux-loadable kernel modules. This can be extended with a function that accepts the current configuration and returns a new configuration."))) (define (linux-loadable-module-builder-modifier modules) "Extends linux-builder-service-type by appending the given MODULES to the configuration of linux-builder-service-type." (lambda (config) (linux-builder-configuration (inherit config) (modules (append (linux-builder-configuration-modules config) modules))))) (define linux-loadable-module-service-type (service-type (name 'linux-loadable-modules) (extensions (list (service-extension linux-builder-service-type linux-loadable-module-builder-modifier))) (default-value '()) (compose concatenate) (extend append) (description "Adds packages and package outputs as modules included in the booted linux-libre profile. Other services can extend this service type to add particular modules to the set of linux-loadable modules."))) ;;; ;;; Service folding. ;;; (define-condition-type &missing-target-service-error &service-error missing-target-service-error? (service missing-target-service-error-service) (target-type missing-target-service-error-target-type)) (define-condition-type &ambiguous-target-service-error &service-error ambiguous-target-service-error? (service ambiguous-target-service-error-service) (target-type ambiguous-target-service-error-target-type)) (define (missing-target-error service target-type) (raise (condition (&missing-target-service-error (service service) (target-type target-type)) (&message (message (format #f (G_ "no target of type '~a' for service '~a'") (service-type-name target-type) (service-type-name (service-kind service)))))))) (define (service-back-edges services) "Return a procedure that, when passed a , returns the list of objects that depend on it." (define (add-edges service edges) (define (add-edge extension edges) (let ((target-type (service-extension-target extension))) (match (filter (lambda (service) (eq? (service-kind service) target-type)) services) ((target) (vhash-consq target service edges)) (() (missing-target-error service target-type)) (x (raise (condition (&ambiguous-target-service-error (service service) (target-type target-type)) (&message (message (format #f (G_ "more than one target service of type '~a'") (service-type-name target-type)))))))))) (fold add-edge edges (service-type-extensions (service-kind service)))) (let ((edges (fold add-edges vlist-null services))) (lambda (node) (reverse (vhash-foldq* cons '() node edges))))) (define (instantiate-missing-services services) "Return SERVICES, a list, augmented with any services targeted by extensions and missing from SERVICES. Only service types with a default value can be instantiated; other missing services lead to a '&missing-target-service-error'." (define (adjust-service-list svc result instances) (fold2 (lambda (extension result instances) (define target-type (service-extension-target extension)) (match (vhash-assq target-type instances) (#f (let ((default (service-type-default-value target-type))) (if (eq? &no-default-value default) (missing-target-error svc target-type) (let ((new (service target-type))) (values (cons new result) (vhash-consq target-type new instances)))))) (_ (values result instances)))) result instances (service-type-extensions (service-kind svc)))) (let loop ((services services)) (define instances (fold (lambda (service result) (vhash-consq (service-kind service) service result)) vlist-null services)) (define adjusted (fold2 adjust-service-list services instances services)) ;; If we instantiated services, they might in turn depend on missing ;; services. Loop until we've reached fixed point. (if (= (length adjusted) (vlist-length instances)) adjusted (loop adjusted)))) (define* (fold-services services #:key (target-type system-service-type)) "Fold SERVICES by propagating their extensions down to the root of type TARGET-TYPE; return the root service adjusted accordingly." (define dependents (service-back-edges services)) (define (matching-extension target) (let ((target (service-kind target))) (match-lambda (($ type) (eq? type target))))) (define (apply-extension target) (lambda (service) (match (find (matching-extension target) (service-type-extensions (service-kind service))) (($ _ compute) (compute (service-value service)))))) (match (filter (lambda (service) (eq? (service-kind service) target-type)) services) ((sink) ;; Use the state monad to keep track of already-visited services in the ;; graph and to memoize their value once folded. (run-with-state (let loop ((sink sink)) (mlet %state-monad ((visited (current-state))) (match (vhash-assq sink visited) (#f (mlet* %state-monad ((dependents (mapm %state-monad loop (dependents sink))) (visited (current-state)) (extensions -> (map (apply-extension sink) dependents)) (extend -> (service-type-extend (service-kind sink))) (compose -> (service-type-compose (service-kind sink))) (params -> (service-value sink)) (service -> ;; Distinguish COMPOSE and EXTEND because PARAMS typically ;; has a different type than the elements of EXTENSIONS. (if extend (service (service-kind sink) (extend params (compose extensions))) sink))) (mbegin %state-monad (set-current-state (vhash-consq sink service visited)) (return service)))) ((_ . service) ;SINK was already visited (return service))))) vlist-null)) (() (raise (make-compound-condition (condition (&missing-target-service-error (service #f) (target-type target-type))) (formatted-message (G_ "service of type '~a' not found") (service-type-name target-type))))) (x (raise (condition (&ambiguous-target-service-error (service #f) (target-type target-type)) (&message (message (format #f (G_ "more than one target service of type '~a'") (service-type-name target-type))))))))) (define (remove-service-extensions type lst) "Return TYPE, a service type, without any of the service extensions targeting one of the types in LST." (service-type (inherit type) (extensions (remove (lambda (extension) (memq (service-extension-target extension) lst)) (service-type-extensions type))))) (define-syntax-parameter for-home? ;; Whether the configuration being defined is for a Home service. (identifier-syntax #f)) (define-syntax-rule (for-home exp ...) "Mark EXP, which typically defines a service configuration, as targeting a Home service rather than a System service." (syntax-parameterize ((for-home? (identifier-syntax #t))) exp ...)) (define-with-syntax-properties (validate-service-list (value properties)) (%validate-service-list value properties)) (define (%validate-service-list value properties) (match value (((? service?) ...) value) (_ (raise (make-compound-condition (condition (&error-location (location (source-properties->location properties)))) (formatted-message (G_ "'services' field must contain a list of services"))))))) ;;; services.scm ends here.