diff options
| author | Andreas Enge <andreas@enge.fr> | 2024-07-05 15:47:13 +0200 |
|---|---|---|
| committer | Andreas Enge <andreas@enge.fr> | 2025-02-17 14:57:55 +0100 |
| commit | 9a41ec57626b63fa0efbd81483e20d541d4b068c (patch) | |
| tree | e2bd92c6064ac6fee3dbce15942079ddae25d074 /gnu | |
| parent | f0d4daa13f0b57f5c03af73d449b2c6dd3160d08 (diff) | |
gnu: guix-configuration: Add a chroot? parameter.
The parameter should take the values #t, #f or 'default.
In a container environment, 'default amounts to #f, otherwise it
amounts to #t.
* gnu/services/base.scm (guix-configuration)<chroot?>: New field.
(guix-shepherd-service): If chroot? is #f, add "--disable-chroot".
If it is #t or 'default, do nothing.
* gnu/system/linux-container.scm (containerized-operating-system):
If chroot? is 'default, replace it by #f.
* doc/guix.texi: Document the parameter.
Change-Id: I8b9c3f46ad8650fa6ed4acee947b4ae5d002d03d
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services/base.scm | 9 | ||||
| -rw-r--r-- | gnu/system/linux-container.scm | 43 |
2 files changed, 31 insertions, 21 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 4bc0433def6..0cd4d3e9cd0 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | ;;; Copyright © 2022 ( <paren@disroot.org> | 22 | ;;; Copyright © 2022 ( <paren@disroot.org> |
| 23 | ;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu> | 23 | ;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu> |
| 24 | ;;; Copyright © 2024 Zheng Junjie <873216071@qq.com> | 24 | ;;; Copyright © 2024 Zheng Junjie <873216071@qq.com> |
| 25 | ;;; Copyright © 2024 Andreas Enge <andreas@enge.fr> | ||
| 25 | ;;; | 26 | ;;; |
| 26 | ;;; This file is part of GNU Guix. | 27 | ;;; This file is part of GNU Guix. |
| 27 | ;;; | 28 | ;;; |
| @@ -224,6 +225,7 @@ | |||
| 224 | guix-configuration-build-group | 225 | guix-configuration-build-group |
| 225 | guix-configuration-build-accounts | 226 | guix-configuration-build-accounts |
| 226 | guix-configuration-build-machines | 227 | guix-configuration-build-machines |
| 228 | guix-configuration-chroot? | ||
| 227 | guix-configuration-authorize-key? | 229 | guix-configuration-authorize-key? |
| 228 | guix-configuration-authorized-keys | 230 | guix-configuration-authorized-keys |
| 229 | guix-configuration-use-substitutes? | 231 | guix-configuration-use-substitutes? |
| @@ -1924,6 +1926,8 @@ archive' public keys, with GUIX." | |||
| 1924 | (default "guixbuild")) | 1926 | (default "guixbuild")) |
| 1925 | (build-accounts guix-configuration-build-accounts ;integer | 1927 | (build-accounts guix-configuration-build-accounts ;integer |
| 1926 | (default 10)) | 1928 | (default 10)) |
| 1929 | (chroot? guix-configuration-chroot? ;Boolean | 'default | ||
| 1930 | (default 'default)) | ||
| 1927 | (authorize-key? guix-configuration-authorize-key? ;Boolean | 1931 | (authorize-key? guix-configuration-authorize-key? ;Boolean |
| 1928 | (default #t)) | 1932 | (default #t)) |
| 1929 | (authorized-keys guix-configuration-authorized-keys ;list of gexps | 1933 | (authorized-keys guix-configuration-authorized-keys ;list of gexps |
| @@ -2025,7 +2029,7 @@ proxy of 'guix-daemon'...~%") | |||
| 2025 | glibc-utf8-locales))) | 2029 | glibc-utf8-locales))) |
| 2026 | 2030 | ||
| 2027 | (match-record config <guix-configuration> | 2031 | (match-record config <guix-configuration> |
| 2028 | (guix build-group build-accounts authorize-key? authorized-keys | 2032 | (guix build-group build-accounts chroot? authorize-key? authorized-keys |
| 2029 | use-substitutes? substitute-urls max-silent-time timeout | 2033 | use-substitutes? substitute-urls max-silent-time timeout |
| 2030 | log-compression discover? extra-options log-file | 2034 | log-compression discover? extra-options log-file |
| 2031 | http-proxy tmpdir chroot-directories environment | 2035 | http-proxy tmpdir chroot-directories environment |
| @@ -2095,6 +2099,9 @@ proxy of 'guix-daemon'...~%") | |||
| 2095 | "--substitute-urls" #$(string-join substitute-urls) | 2099 | "--substitute-urls" #$(string-join substitute-urls) |
| 2096 | #$@extra-options | 2100 | #$@extra-options |
| 2097 | 2101 | ||
| 2102 | #$@(if chroot? | ||
| 2103 | '() | ||
| 2104 | '("--disable-chroot")) | ||
| 2098 | ;; Add CHROOT-DIRECTORIES and all their dependencies | 2105 | ;; Add CHROOT-DIRECTORIES and all their dependencies |
| 2099 | ;; (if these are store items) to the chroot. | 2106 | ;; (if these are store items) to the chroot. |
| 2100 | (append-map | 2107 | (append-map |
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index c780b68fba4..c1705f491cc 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | ;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net> | 7 | ;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net> |
| 8 | ;;; Copyright © 2023 Pierre Langlois <pierre.langlois@gmx.com> | 8 | ;;; Copyright © 2023 Pierre Langlois <pierre.langlois@gmx.com> |
| 9 | ;;; Copyright © 2024 Leo Nikkilä <hello@lnikki.la> | 9 | ;;; Copyright © 2024 Leo Nikkilä <hello@lnikki.la> |
| 10 | ;;; Copyright © 2024 Andreas Enge <andreas@enge.fr> | ||
| 10 | ;;; | 11 | ;;; |
| 11 | ;;; This file is part of GNU Guix. | 12 | ;;; This file is part of GNU Guix. |
| 12 | ;;; | 13 | ;;; |
| @@ -151,26 +152,28 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." | |||
| 151 | (swap-devices '()) ; disable swap | 152 | (swap-devices '()) ; disable swap |
| 152 | (services | 153 | (services |
| 153 | (append services-to-add | 154 | (append services-to-add |
| 154 | (filter-map (lambda (s) | 155 | (filter-map |
| 155 | (cond ((memq (service-kind s) services-to-drop) | 156 | (lambda (s) |
| 156 | #f) | 157 | (let ((kind (service-kind s)) |
| 157 | ((eq? nscd-service-type (service-kind s)) | 158 | (value (service-value s))) |
| 158 | (service nscd-service-type | 159 | (cond ((memq kind services-to-drop) |
| 159 | (nscd-configuration | 160 | #f) |
| 160 | (inherit (service-value s)) | 161 | ((eq? nscd-service-type kind) |
| 161 | (caches %nscd-container-caches)))) | 162 | (service nscd-service-type |
| 162 | ((eq? guix-service-type (service-kind s)) | 163 | (nscd-configuration |
| 163 | ;; Pass '--disable-chroot' so that | 164 | (inherit value) |
| 164 | ;; guix-daemon can build thing even in | 165 | (caches %nscd-container-caches)))) |
| 165 | ;; Docker without '--privileged'. | 166 | ((and (eq? guix-service-type kind) |
| 166 | (service guix-service-type | 167 | (eq? (guix-configuration-chroot? value) |
| 167 | (guix-configuration | 168 | 'default)) |
| 168 | (inherit (service-value s)) | 169 | ;; If chroot? is 'default, it should become #f |
| 169 | (extra-options | 170 | ;; so that guix-daemon can build things even in |
| 170 | (cons "--disable-chroot" | 171 | ;; Docker without '--privileged'. |
| 171 | (guix-configuration-extra-options | 172 | (service guix-service-type |
| 172 | (service-value s))))))) | 173 | (guix-configuration |
| 173 | (else s))) | 174 | (inherit value) |
| 175 | (chroot? #f)))) | ||
| 176 | (else s)))) | ||
| 174 | (operating-system-user-services os)))) | 177 | (operating-system-user-services os)))) |
| 175 | (file-systems (append (map mapping->fs | 178 | (file-systems (append (map mapping->fs |
| 176 | (if shared-network? | 179 | (if shared-network? |
