diff options
| author | Thiago Jung Bauermann <bauermann@kolabnow.com> | 2021-09-15 20:36:38 -0300 |
|---|---|---|
| committer | Mathieu Othacehe <othacehe@gnu.org> | 2021-09-20 14:18:21 +0000 |
| commit | 5c4fd77097e2cecfd4780e099af7954f86779fe1 (patch) | |
| tree | a04414dfc0a56a01daf096c10aa9c52489281d5e | |
| parent | cbb76da1f6fd9a27bb1826274493cc6f33000f18 (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-- | .gitignore | 1 | ||||
| -rw-r--r-- | doc/guix.texi | 12 | ||||
| -rw-r--r-- | etc/guix-gc.service.in | 20 | ||||
| -rw-r--r-- | etc/guix-gc.timer | 15 | ||||
| -rw-r--r-- | nix/local.mk | 6 |
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 | ||
| 746 | You 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 | |||
| 755 | You may want to edit @file{guix-gc.service} to adjust the command line | ||
| 756 | options to fit your needs (@pxref{Invoking guix gc}). | ||
| 757 | |||
| 746 | If your host distro uses the Upstart init system: | 758 | If 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] | ||
| 7 | Description=Discard unused Guix store items | ||
| 8 | |||
| 9 | [Service] | ||
| 10 | Type=oneshot | ||
| 11 | # Customize the 'guix gc' arguments to fit your needs. | ||
| 12 | ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix gc -d 1m -F 10G | ||
| 13 | PrivateDevices=yes | ||
| 14 | PrivateNetwork=yes | ||
| 15 | PrivateUsers=no | ||
| 16 | ProtectKernelTunables=yes | ||
| 17 | ProtectKernelModules=yes | ||
| 18 | ProtectControlGroups=yes | ||
| 19 | MemoryDenyWriteExecute=yes | ||
| 20 | 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 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] | ||
| 6 | Description=Discard unused Guix store items | ||
| 7 | |||
| 8 | [Timer] | ||
| 9 | OnCalendar=weekly | ||
| 10 | AccuracySec=1h | ||
| 11 | Persistent=true | ||
| 12 | RandomizedDelaySec=6000 | ||
| 13 | |||
| 14 | [Install] | ||
| 15 | WantedBy=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 | |||
| 153 | nodist_systemdservice_DATA = \ | 153 | nodist_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 | ||
| 158 | etc/%.mount: etc/%.mount.in \ | 160 | etc/%.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 | ||
