From debbugs-submit-bounces@debbugs.gnu.org Thu May 14 09:49:15 2020 Received: (at submit) by debbugs.gnu.org; 14 May 2020 13:49:15 +0000 Received: from localhost ([127.0.0.1]:60699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZEEX-0003kJ-P4 for submit@debbugs.gnu.org; Thu, 14 May 2020 09:49:15 -0400 Received: from lists.gnu.org ([209.51.188.17]:59236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZEES-0003k8-C5 for submit@debbugs.gnu.org; Thu, 14 May 2020 09:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZEES-0007JR-4p for guix-patches@gnu.org; Thu, 14 May 2020 09:49:04 -0400 Received: from tobias.gr ([2a02:c205:2020:6054::1]:41504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZEEN-0006GS-7I for guix-patches@gnu.org; Thu, 14 May 2020 09:49:03 -0400 Received: by tobias.gr (OpenSMTPD) with ESMTP id 9ce5d4d9 for ; Thu, 14 May 2020 13:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tobias.gr; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=2018; i=me@tobias.gr; bh=xgc+nzsdeOC1rDBHOHqeTlft0tjSAcIlEwnc CAyVFBM=; b=RL9m0Thipb+SQ9KWvxxgTolkGGA0x1UOOrz4wC2JliM8HboxwG1k GFj2hfCh/WITEO4ohaoiYaJjlt0aJDr5vhq/JOMJrxkJWMqlxtvMkNIgjwUHHMLM yErmd2lChO00UG0VbOgNRtPyLqofvob7aeIlZ7HdcH0H+gE0VM+dz2pkW//np59J jGsA2FIXvdIXjKkRPfMyWoBwm8QQUU9qvKHeFPpRlCpmMrgsgLDnzjSnqXcK1POw mpfRcGz9gaiOf2KIF9P13FyC8kPMSuGe1+wcg0Okwijm+s+obc9P7dFfVvfxRMg6 p8LilHCehaK+LG/Pa/e2xZbesVq4Uwjq3g== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id ea89ff14 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Thu, 14 May 2020 13:48:55 +0000 (UTC) From: Tobias Geerinckx-Rice To: guix-patches@gnu.org Subject: [PATCH] etc: Add a systemd unit to bind-mount @storedir@ read-only. Date: Thu, 14 May 2020 15:48:46 +0200 Message-Id: <20200514134846.29037-1-me@tobias.gr> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a02:c205:2020:6054::1; envelope-from=me@tobias.gr; helo=tobias.gr X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) * etc/gnu-store.mount.in: New file. * nix/local.mk (nodist_systemdservice_DATA): Add it. (etc/%.mount): New rule. * etc/guix-install.sh (sys_enable_guix_daemon): Install it. * doc/guix.texi (Binary Installation): Document it. --- For . doc/guix.texi | 5 +++-- etc/gnu-store.mount.in | 14 ++++++++++++++ etc/guix-install.sh | 12 +++++++++--- nix/local.mk | 12 +++++++++++- 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 etc/gnu-store.mount.in diff --git a/doc/guix.texi b/doc/guix.texi index d6fbd85fde..5d80a7e405 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -659,9 +659,10 @@ with these commands: @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html @example -# cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \ +# cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \ + ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \ /etc/systemd/system/ -# systemctl enable --now guix-daemon +# systemctl enable --now gnu-store.mount guix-daemon @end example If your host distro uses the Upstart init system: diff --git a/etc/gnu-store.mount.in b/etc/gnu-store.mount.in new file mode 100644 index 0000000000..c94f2db72b --- /dev/null +++ b/etc/gnu-store.mount.in @@ -0,0 +1,14 @@ +[Unit] +Description=Read-only @storedir@ for GNU Guix +DefaultDependencies=no +ConditionPathExists=@storedir@ +Before=guix-daemon.service + +[Install] +WantedBy=guix-daemon.service + +[Mount] +What=@storedir@ +Where=@storedir@ +Type=none +Options=bind,ro diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 4909d3f162..d252c132fb 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -342,7 +342,13 @@ sys_enable_guix_daemon() _msg "${PAS}enabled Guix daemon via upstart" ;; systemd) - { cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/guix-daemon.service" \ + { # systemd .mount units must be named after the target directory. + # Here we assume a hard-coded name of /gnu/store. + cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/gnu-store.mount" \ + /etc/systemd/system/; + chmod 664 /etc/systemd/system/gnu-store.mount; + + cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/guix-daemon.service" \ /etc/systemd/system/; chmod 664 /etc/systemd/system/guix-daemon.service; @@ -357,8 +363,8 @@ sys_enable_guix_daemon() fi; systemctl daemon-reload && - systemctl start guix-daemon && - systemctl enable guix-daemon; } && + systemctl start gnu-store.mount guix-daemon && + systemctl enable gnu-store.mount guix-daemon; } && _msg "${PAS}enabled Guix daemon via systemd" ;; sysv-init) diff --git a/nix/local.mk b/nix/local.mk index a64bdd2137..435fdd389a 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -155,7 +155,17 @@ noinst_HEADERS = \ # The '.service' files for systemd. systemdservicedir = $(libdir)/systemd/system -nodist_systemdservice_DATA = etc/guix-daemon.service etc/guix-publish.service +nodist_systemdservice_DATA = \ + etc/gnu-store.mount \ + etc/guix-daemon.service \ + etc/guix-publish.service + +etc/%.mount: etc/%.mount.in \ + $(top_builddir)/config.status + $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \ + $(SED) -e 's|@''storedir''@|$(storedir)|' < \ + "$<" > "$@.tmp"; \ + mv "$@.tmp" "$@" etc/guix-%.service: etc/guix-%.service.in \ $(top_builddir)/config.status -- 2.26.2