diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2025-01-23 09:47:22 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-03-26 17:57:45 +0100 |
| commit | 107eb8ee8f5f9192c795abeb47885b49a57bacd4 (patch) | |
| tree | f79f2c3ffab1d14b090430b1547e39d4915e3379 /etc/guix-daemon.service.in | |
| parent | 2f65438eba584c5c0181af917445bb6025d3d0c8 (diff) | |
etc: systemd services: Run ‘guix-daemon’ as an unprivileged user.
* etc/guix-daemon.service.in (ExecStart): Remove ‘--build-users-group’.
(Environment): Add ‘GUIX_STATE_DIRECTORY’.
(Before, User, AmbientCapabilities, PrivateMounts, BindPaths): New fields.
* etc/gnu-store.mount.in (Before): Remove.
(WantedBy): Change to ‘multi-user.target’.
Change-Id: Id826b8ab535844b6024d777f6bd15fd49db6d65e
Diffstat (limited to 'etc/guix-daemon.service.in')
| -rw-r--r-- | etc/guix-daemon.service.in | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/etc/guix-daemon.service.in b/etc/guix-daemon.service.in index 5c43d9b7f1b..6a5ef97f9b3 100644 --- a/etc/guix-daemon.service.in +++ b/etc/guix-daemon.service.in | |||
| @@ -5,11 +5,29 @@ | |||
| 5 | [Unit] | 5 | [Unit] |
| 6 | Description=Build daemon for GNU Guix | 6 | Description=Build daemon for GNU Guix |
| 7 | 7 | ||
| 8 | # Start before 'gnu-store.mount' to get a writable view of the store. | ||
| 9 | Before=gnu-store.mount | ||
| 10 | |||
| 8 | [Service] | 11 | [Service] |
| 9 | ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \ | 12 | ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \ |
| 10 | --build-users-group=guixbuild --discover=no \ | 13 | --discover=no \ |
| 11 | --substitute-urls='@GUIX_SUBSTITUTE_URLS@' | 14 | --substitute-urls='@GUIX_SUBSTITUTE_URLS@' |
| 12 | Environment='GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale' LC_ALL=en_US.utf8 | 15 | Environment='GUIX_STATE_DIRECTORY=@localstatedir@/guix' 'GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale' LC_ALL=en_US.utf8 |
| 16 | |||
| 17 | # Run under a dedicated unprivileged user account. | ||
| 18 | User=guix-daemon | ||
| 19 | |||
| 20 | # Bind-mount the store read-write in a private namespace, to counter the | ||
| 21 | # effect of 'gnu-store.mount'. | ||
| 22 | PrivateMounts=true | ||
| 23 | BindPaths=@storedir@ | ||
| 24 | |||
| 25 | # Provide the CAP_CHOWN capability so that guix-daemon can create and chown | ||
| 26 | # /var/guix/profiles/per-user/$USER and also chown failed build directories | ||
| 27 | # when using '--keep-failed'. Note that guix-daemon explicitly drops ambient | ||
| 28 | # capabilities before executing build processes so they don't inherit them. | ||
| 29 | AmbientCapabilities=CAP_CHOWN | ||
| 30 | |||
| 13 | StandardOutput=journal | 31 | StandardOutput=journal |
| 14 | StandardError=journal | 32 | StandardError=journal |
| 15 | 33 | ||
