summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauermann@kolabnow.com>2021-09-15 20:36:38 -0300
committerMathieu Othacehe <othacehe@gnu.org>2021-09-20 14:18:21 +0000
commit5c4fd77097e2cecfd4780e099af7954f86779fe1 (patch)
treea04414dfc0a56a01daf096c10aa9c52489281d5e
parentcbb76da1f6fd9a27bb1826274493cc6f33000f18 (diff)
etc: Add systemd files for running ‘guix gc’ periodically
* 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. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
-rw-r--r--.gitignore1
-rw-r--r--doc/guix.texi12
-rw-r--r--etc/guix-gc.service.in20
-rw-r--r--etc/guix-gc.timer15
-rw-r--r--nix/local.mk6
5 files changed, 53 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 88fe24586db..59e1460fefc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@
74/etc/guix-daemon.service 74/etc/guix-daemon.service
75/etc/guix-publish.conf 75/etc/guix-publish.conf
76/etc/guix-publish.service 76/etc/guix-publish.service
77/etc/guix-gc.service
77/etc/init.d/guix-daemon 78/etc/init.d/guix-daemon
78/etc/openrc/guix-daemon 79/etc/openrc/guix-daemon
79/guix-* 80/guix-*
diff --git a/doc/guix.texi b/doc/guix.texi
index 6436e83a7c8..cd8e249ae87 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -743,6 +743,18 @@ with these commands:
743# systemctl enable --now gnu-store.mount guix-daemon 743# systemctl enable --now gnu-store.mount guix-daemon
744@end example 744@end example
745 745
746You may also want to arrange for @command{guix gc} to run periodically:
747
748@example
749# cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
750 ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
751 /etc/systemd/system/
752# systemctl enable --now guix-gc.timer
753@end example
754
755You may want to edit @file{guix-gc.service} to adjust the command line
756options to fit your needs (@pxref{Invoking guix gc}).
757
746If your host distro uses the Upstart init system: 758If your host distro uses the Upstart init system:
747 759
748@example 760@example
diff --git a/etc/guix-gc.service.in b/etc/guix-gc.service.in
new file mode 100644
index 00000000000..2f1ca6584bb
--- /dev/null
+++ b/etc/guix-gc.service.in
@@ -0,0 +1,20 @@
1# This is a "service unit file" for the systemd init system to perform a
2# one-shot 'guix gc' operation. It is meant to be triggered by a timer.
3# Drop it in /etc/systemd/system or similar together with 'guix-gc.timer'
4# to set it up.
5
6[Unit]
7Description=Discard unused Guix store items
8
9[Service]
10Type=oneshot
11# Customize the 'guix gc' arguments to fit your needs.
12ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix gc -d 1m -F 10G
13PrivateDevices=yes
14PrivateNetwork=yes
15PrivateUsers=no
16ProtectKernelTunables=yes
17ProtectKernelModules=yes
18ProtectControlGroups=yes
19MemoryDenyWriteExecute=yes
20SystemCallFilter=@default @file-system @basic-io @system-service
diff --git a/etc/guix-gc.timer b/etc/guix-gc.timer
new file mode 100644
index 00000000000..192132fbda5
--- /dev/null
+++ b/etc/guix-gc.timer
@@ -0,0 +1,15 @@
1# This is a "timer unit file" for the systemd init system to trigger
2# 'guix-gc.service' periodically. Drop it in /etc/systemd/system or similar
3# together with 'guix-gc.service' to set it up.
4
5[Unit]
6Description=Discard unused Guix store items
7
8[Timer]
9OnCalendar=weekly
10AccuracySec=1h
11Persistent=true
12RandomizedDelaySec=6000
13
14[Install]
15WantedBy=timers.target
diff --git a/nix/local.mk b/nix/local.mk
index 7c438ea78c5..d6b4d7faeb6 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -153,7 +153,9 @@ systemdservicedir = $(libdir)/systemd/system
153nodist_systemdservice_DATA = \ 153nodist_systemdservice_DATA = \
154 etc/gnu-store.mount \ 154 etc/gnu-store.mount \
155 etc/guix-daemon.service \ 155 etc/guix-daemon.service \
156 etc/guix-publish.service 156 etc/guix-publish.service \
157 etc/guix-gc.service \
158 etc/guix-gc.timer
157 159
158etc/%.mount: etc/%.mount.in \ 160etc/%.mount: etc/%.mount.in \
159 $(top_builddir)/config.status 161 $(top_builddir)/config.status
@@ -216,6 +218,8 @@ EXTRA_DIST += \
216 etc/guix-daemon.conf.in \ 218 etc/guix-daemon.conf.in \
217 etc/guix-publish.service.in \ 219 etc/guix-publish.service.in \
218 etc/guix-publish.conf.in \ 220 etc/guix-publish.conf.in \
221 etc/guix-gc.service.in \
222 etc/guix-gc.timer \
219 etc/init.d/guix-daemon.in \ 223 etc/init.d/guix-daemon.in \
220 etc/openrc/guix-daemon.in 224 etc/openrc/guix-daemon.in
221 225