GNU bug report logs - #50610
[PATCH] etc: Add systemd files for running ‘guix gc’ periodically

Previous Next

Package: guix-patches;

Reported by: Thiago Jung Bauermann <bauermann <at> kolabnow.com>

Date: Wed, 15 Sep 2021 23:47:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50610 in the body.
You can then email your comments to 50610 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#50610; Package guix-patches. (Wed, 15 Sep 2021 23:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thiago Jung Bauermann <bauermann <at> kolabnow.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 15 Sep 2021 23:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: guix-patches <at> gnu.org
Cc: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Subject: [PATCH] etc: Add systemd files for running ‘guix gc’ periodically
Date: Wed, 15 Sep 2021 20:36:38 -0300
* etc/guix-gc.service.in: New file.
* etc/guix-gc.timer: Likewise.
* .gitignore: Ignore generated ‘guix-gc.service’.
* nix/local.mk (nodist_systemdservice_DATA): Add ‘guix-gc.service’ and
‘guix-gc.timer’.
(EXTRA_DIST): Add ‘guix-gc.service.in’ and ‘guix-gc.timer’.
* doc/guix.texi (Binary Installation): Mention the new systemd files.
---

Hello,

I recently added a systemd timer to run ‘guix gc’ once a day on the guixp9 CI
machine. This patch adds files similar to the ones I used there, and documents
them. The only differences are that on guixp9 the command-line used is
“guix gc -F 50G” and the timer is set to fire daily rather than weekly.

Thanks,
Thiago

 .gitignore             |  1 +
 doc/guix.texi          | 12 ++++++++++++
 etc/guix-gc.service.in | 20 ++++++++++++++++++++
 etc/guix-gc.timer      | 15 +++++++++++++++
 nix/local.mk           |  6 +++++-
 5 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 etc/guix-gc.service.in
 create mode 100644 etc/guix-gc.timer

diff --git a/.gitignore b/.gitignore
index 88fe24586db0..59e1460fefc8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@
 /etc/guix-daemon.service
 /etc/guix-publish.conf
 /etc/guix-publish.service
+/etc/guix-gc.service
 /etc/init.d/guix-daemon
 /etc/openrc/guix-daemon
 /guix-*
diff --git a/doc/guix.texi b/doc/guix.texi
index 2fc96879106b..e1e353e57e50 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -743,6 +743,18 @@ with these commands:
 # systemctl enable --now gnu-store.mount guix-daemon
 @end example
 
+You may also want to arrange for @command{guix gc} to run periodically:
+
+@example
+# cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
+     ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
+     /etc/systemd/system/
+# systemctl enable --now guix-gc.timer
+@end example
+
+You may want to edit @file{guix-gc.service} to adjust the command line
+options to fit your needs (@pxref{Invoking guix gc}).
+
 If your host distro uses the Upstart init system:
 
 @example
diff --git a/etc/guix-gc.service.in b/etc/guix-gc.service.in
new file mode 100644
index 000000000000..2f1ca6584bbc
--- /dev/null
+++ b/etc/guix-gc.service.in
@@ -0,0 +1,20 @@
+# This is a "service unit file" for the systemd init system to perform a
+# one-shot 'guix gc' operation.  It is meant to be triggered by a timer.
+# Drop it in /etc/systemd/system or similar together with 'guix-gc.timer'
+# to set it up.
+
+[Unit]
+Description=Discard unused Guix store items
+
+[Service]
+Type=oneshot
+# Customize the 'guix gc' arguments to fit your needs.
+ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix gc -d 1m -F 10G
+PrivateDevices=yes
+PrivateNetwork=yes
+PrivateUsers=no
+ProtectKernelTunables=yes
+ProtectKernelModules=yes
+ProtectControlGroups=yes
+MemoryDenyWriteExecute=yes
+SystemCallFilter=@default @file-system @basic-io @system-service
diff --git a/etc/guix-gc.timer b/etc/guix-gc.timer
new file mode 100644
index 000000000000..192132fbda51
--- /dev/null
+++ b/etc/guix-gc.timer
@@ -0,0 +1,15 @@
+# This is a "timer unit file" for the systemd init system to trigger
+# 'guix-gc.service' periodically.  Drop it in /etc/systemd/system or similar
+# together with 'guix-gc.service' to set it up.
+
+[Unit]
+Description=Discard unused Guix store items
+
+[Timer]
+OnCalendar=weekly
+AccuracySec=1h
+Persistent=true
+RandomizedDelaySec=6000
+
+[Install]
+WantedBy=timers.target
diff --git a/nix/local.mk b/nix/local.mk
index 7c438ea78c5b..d6b4d7faeb66 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -153,7 +153,9 @@ systemdservicedir = $(libdir)/systemd/system
 nodist_systemdservice_DATA =			\
   etc/gnu-store.mount				\
   etc/guix-daemon.service			\
-  etc/guix-publish.service
+  etc/guix-publish.service			\
+  etc/guix-gc.service				\
+  etc/guix-gc.timer
 
 etc/%.mount: etc/%.mount.in	\
 			 $(top_builddir)/config.status
@@ -216,6 +218,8 @@ EXTRA_DIST +=					\
   etc/guix-daemon.conf.in			\
   etc/guix-publish.service.in			\
   etc/guix-publish.conf.in			\
+  etc/guix-gc.service.in			\
+  etc/guix-gc.timer				\
   etc/init.d/guix-daemon.in			\
   etc/openrc/guix-daemon.in
 




Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Mon, 20 Sep 2021 14:20:02 GMT) Full text and rfc822 format available.

Notification sent to Thiago Jung Bauermann <bauermann <at> kolabnow.com>:
bug acknowledged by developer. (Mon, 20 Sep 2021 14:20:02 GMT) Full text and rfc822 format available.

Message #10 received at 50610-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Cc: 50610-done <at> debbugs.gnu.org
Subject: Re: bug#50610: [PATCH] etc: Add systemd files for running
 ‘guix gc’ periodically
Date: Mon, 20 Sep 2021 14:19:31 +0000
Hello Thiago,

> I recently added a systemd timer to run ‘guix gc’ once a day on the guixp9 CI
> machine. This patch adds files similar to the ones I used there, and documents
> them. The only differences are that on guixp9 the command-line used is
> “guix gc -F 50G” and the timer is set to fire daily rather than weekly.

Looks nice, pushed as 5c4fd77097e2cecfd4780e099af7954f86779fe1.

Thanks,

Mathieu




Information forwarded to guix-patches <at> gnu.org:
bug#50610; Package guix-patches. (Tue, 21 Sep 2021 01:19:02 GMT) Full text and rfc822 format available.

Message #13 received at 50610-done <at> debbugs.gnu.org (full text, mbox):

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: Mathieu Othacehe <othacehe <at> gnu.org>
Cc: 50610-done <at> debbugs.gnu.org
Subject: Re: bug#50610: [PATCH] etc: Add systemd files for running
 ‘guix gc’ periodically
Date: Mon, 20 Sep 2021 22:18:38 -0300
Hello Mathieu,

Em segunda-feira, 20 de setembro de 2021, às 11:19:31 -03, Mathieu Othacehe 
escreveu:
> Hello Thiago,
> 
> > I recently added a systemd timer to run ‘guix gc’ once a day on the
> > guixp9 CI machine. This patch adds files similar to the ones I used
> > there, and documents them. The only differences are that on guixp9 the
> > command-line used is “guix gc -F 50G” and the timer is set to fire
> > daily rather than weekly.
> Looks nice, pushed as 5c4fd77097e2cecfd4780e099af7954f86779fe1.

Thanks!

-- 
Thanks,
Thiago






bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 19 Oct 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 189 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.