diff mbox series

[bug#72514,v1,2/2] guix-install.sh: Support perp.

Message ID d4927ad6160e8acb02b917929b587aae02b26768.1723041383.git.GNUtoo@cyberdimension.org
State New
Headers show
Series Add perp support in guix-install.sh for Dragora. | expand

Commit Message

Denis 'GNUtoo' Carikli Aug. 7, 2024, 3:39 p.m. UTC
Without this patch, it is possible to install Guix on Dragora, but then no
init system is detected and so the Guix daemon isn't started.

Thanks a lot for the help from selk on #dragora on Libera Chat for the help.

* etc/guix-install.sh
 (chk_init_sys): Detect perp.
 (sys_enable_guix_daemon): Install, configure, enable and start the perp
 service.
 (sys_delete_guix_daemon): Stop and remove the perp service.
* etc/perp/rc.log.in: New file.
* etc/perp/rc.main.in: New file.
* nix/local.mk: Add build rules.
* .gitignore: Ignore generated etc/perp/rc.log and etc/perp/rc.main.

Change-Id: I15a5229fee69ebd41ac538b25a3e68793c563144
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
 .gitignore          |  2 ++
 etc/guix-install.sh | 25 +++++++++++++++++++++++++
 etc/perp/rc.log.in  | 24 ++++++++++++++++++++++++
 etc/perp/rc.main.in | 45 +++++++++++++++++++++++++++++++++++++++++++++
 nix/local.mk        | 17 ++++++++++++++++-
 5 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 etc/perp/rc.log.in
 create mode 100644 etc/perp/rc.main.in
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index 0f74b5da3d..11f99e32db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,6 +77,8 @@ 
 /etc/guix-gc.service
 /etc/init.d/guix-daemon
 /etc/openrc/guix-daemon
+/etc/perp/rc.log
+/etc/perp/rc.main
 /guix-*
 /guix/config.scm
 /libformat.a
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 9d9c294d75..4a0b326ffa 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -232,6 +232,10 @@  chk_init_sys()
         _msg "${INF}init system is: systemd"
         INIT_SYS="systemd"
         return 0
+    elif [[ $(perpboot -V 2>&1) =~ perpboot ]]; then
+        _msg "${INF}init system is: perp"
+        INIT_SYS="perp"
+        return 0
     elif [[ -f /etc/init.d/cron && ! -h /etc/init.d/cron ]]; then
         _msg "${INF}init system is: sysv-init"
         INIT_SYS="sysv-init"
@@ -505,6 +509,20 @@  sys_enable_guix_daemon()
                   systemctl start  guix-daemon; } &&
                 _msg "${PAS}enabled Guix daemon via systemd"
             ;;
+	perp)
+            { mkdir -p /etc/perp/guix-daemon/;
+              cp ~root/.config/guix/current/etc/perp/rc.log \
+                 /etc/perp/guix-daemon/rc.log;
+              cp ~root/.config/guix/current/etc/perp/rc.main \
+                 /etc/perp/guix-daemon/rc.main;
+              chmod 775 /etc/perp/guix-daemon/rc.log;
+              chmod 775 /etc/perp/guix-daemon/rc.main;
+
+              configure_substitute_discovery /etc/perp/guix-daemon/rc.main
+
+              perpctl A guix-daemon; } &&
+                _msg "${PAS}enabled Guix daemon via perp"
+            ;;
         sysv-init)
             { mkdir -p /etc/init.d;
               cp ~root/.config/guix/current/etc/init.d/guix-daemon \
@@ -587,6 +605,13 @@  sys_delete_guix_daemon()
             systemctl daemon-reload
             ;;
 
+	perp)
+            _msg "${INF}stopping and disabling guix-daemon"
+	    perpctl X guix-daemon
+            _msg "${INF}removing guix-daemon"
+	    rm -rf /etc/perp/guix-daemon
+	    ;;
+
         sysv-init)
             update-rc.d guix-daemon disable
             service guix-daemon stop
diff --git a/etc/perp/rc.log.in b/etc/perp/rc.log.in
new file mode 100644
index 0000000000..11c3ab490e
--- /dev/null
+++ b/etc/perp/rc.log.in
@@ -0,0 +1,24 @@ 
+#!/bin/sh
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.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/>.
+
+if [ "${1}" = "start" ] ; then
+  exec tinylog_run "${2}"
+fi
+
+exit 0
diff --git a/etc/perp/rc.main.in b/etc/perp/rc.main.in
new file mode 100644
index 0000000000..cdf92763eb
--- /dev/null
+++ b/etc/perp/rc.main.in
@@ -0,0 +1,45 @@ 
+#! /bin/sh
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.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/>.
+
+start() {
+    echo "*** ${SVNAME}: starting Guix daemon..."
+
+    export GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale
+    export LC_ALL=en_US.utf8
+    exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
+         --build-users-group=guixbuild --discover=no \
+         --substitute-urls='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org' 2>&1
+}
+
+reset() {
+  case $3 in
+    "exit" )
+        echo "*** ${SVNAME}: exited status $4"
+        ;;
+    "signal" )
+        echo "*** ${SVNAME}: killed on signal $5"
+        ;;
+    * )
+        echo "*** ${SVNAME}: stopped ($3)"
+        ;;
+  esac
+  exit 0
+}
+
+eval ${TARGET} "$@"
diff --git a/nix/local.mk b/nix/local.mk
index 8a2b2b88e8..ffc57185cf 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -194,6 +194,18 @@  etc/openrc/guix-daemon: etc/openrc/guix-daemon.in	\
 	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+# The service script for perp.
+perpservicedir = $(sysconfdir)/perp
+nodist_perpservice_DATA = etc/perp/rc.log etc/perp/rc.main
+
+etc/perp/rc.%: etc/perp/rc.%.in	\
+			 $(top_builddir)/config.status
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''localstatedir''@|$(localstatedir)|' \
+	       -e 's|@''GUIX_SUBSTITUTE_URLS''@|$(GUIX_SUBSTITUTE_URLS)|' \
+	       < "$<" > "$@.tmp";		\
+	mv "$@.tmp" "$@"
+
 # The '.conf' jobs for Upstart.
 upstartjobdir = $(libdir)/upstart/system
 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -210,6 +222,7 @@  CLEANFILES +=					\
   $(nodist_systemdservice_DATA)			\
   $(nodist_upstartjob_DATA)			\
   $(nodist_sysvinitservice_DATA)		\
+  $(nodist_perpservice_DATA)			\
   $(nodist_openrcservice_DATA)
 
 EXTRA_DIST +=					\
@@ -223,7 +236,9 @@  EXTRA_DIST +=					\
   etc/guix-gc.service.in			\
   etc/guix-gc.timer				\
   etc/init.d/guix-daemon.in			\
-  etc/openrc/guix-daemon.in
+  etc/openrc/guix-daemon.in			\
+  etc/perp/rc.log.in				\
+  etc/perp/rc.main.in
 
 if CAN_RUN_TESTS