From efcce99acb45681fddd1849fd81f9fdc85471649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 17 Apr 2025 11:41:01 +0200 Subject: [PATCH] =?UTF-8?q?self:=20Install=20systemd=20=E2=80=98.service?= =?UTF-8?q?=E2=80=99=20files.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is consistent with the ‘guix’ package and will prove helpful when people want to replace /etc/systemd/system/guix*.service with newer versions thereof. * guix/self.scm (parameterized-file): New procedure, based on… (selinux-policy): … this. Use ‘parameterized-file’. (systemd-file): New procedure. (miscellaneous-files): Add systemd files. Change-Id: Ia489a955347cf648a86000cc1265769d66c3f0e8 --- guix/self.scm | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/guix/self.scm b/guix/self.scm index 28239d53f5..2a99765359 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2017-2023 Ludovic Courtès +;;; Copyright © 2017-2023, 2025 Ludovic Courtès ;;; Copyright © 2020 Martin Becze ;;; Copyright © 2023 Janneke Nieuwenhuizen ;;; Copyright © 2024 gemmaro @@ -666,24 +666,40 @@ load path." ;; Use a 'guile' variant that doesn't complain about locales. #:guile (quiet-guile guile))) -(define (selinux-policy source daemon) - "Return the SELinux policy file taken from SOURCE and adjusted to refer to -DAEMON and to the current configuration variables." +(define (parameterized-file source daemon file name) + "Return FILE taken from SOURCE (typically a '.in' file) and adjusted to +refer to DAEMON and to the current configuration variables." (define build (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) - (copy-file #+(file-append* source "/etc/guix-daemon.cil.in") - "guix-daemon.cil") - (substitute* "guix-daemon.cil" + (fluid-set! %default-port-encoding "UTF-8") + (copy-file #+(file-append* source file) #$name) + (substitute* #$name (("@guix_sysconfdir@") #$%sysconfdir) (("@guix_localstatedir@") #$%localstatedir) + (("@localstatedir@") #$%localstatedir) (("@storedir@") #$%storedir) - (("@prefix@") #$daemon)) - (copy-file "guix-daemon.cil" #$output)))) + (("@prefix@") #$daemon) + (("@GUIX_SUBSTITUTE_URLS@") + #$(string-join %default-substitute-urls))) + (copy-file #$name #$output)))) - (computed-file "guix-daemon.cil" build)) + (computed-file name build)) + +(define (selinux-policy source daemon) + "Return the SELinux policy file taken from SOURCE and adjusted to refer to +DAEMON and to the current configuration variables." + (parameterized-file source daemon + "etc/guix-daemon.cil.in" + "guix-daemon.cil")) + +(define (systemd-file source daemon file) + "Return the given systemd file from SOURCE parameterized for DAEMON." + (parameterized-file source daemon + (string-append "etc/" file ".in") + file)) (define (miscellaneous-files source daemon) "Return data files taken from SOURCE." @@ -698,6 +714,12 @@ DAEMON and to the current configuration variables." ,(file-append* source "/etc/completion/fish/guix.fish")) ("share/selinux/guix-daemon.cil" ,(selinux-policy source daemon)) + ,@(map (lambda (file) + `(,(string-append "lib/systemd/system/" file) + ,(systemd-file source daemon file))) + '("guix-gc.service" + "guix-publish.service" + "guix-daemon.service")) ("share/guix/berlin.guix.gnu.org.pub" ,(file-append* source "/etc/substitutes/berlin.guix.gnu.org.pub"))