diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-09-12 22:17:43 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-09-12 23:07:42 +0200 |
| commit | 5ccec77176b7e0c67ed58c8849e5e76f3dd79a88 (patch) | |
| tree | c2979713d92479d096ec4133f6b1c2457539dd2c /gnu/system/linux-container.scm | |
| parent | f58b2f38e4dfdbb8473fb2816d44fae6ad9cbc79 (diff) | |
file-systems: Add /var/run/nscd to '%network-file-mappings'.
This allows containers created by "guix environment -CN" or by
"guix system container -N" to talk to the host nscd.
* gnu/system/file-systems.scm (%network-file-mappings): Add
"/var/run/nscd".
* gnu/build/shepherd.scm (default-mounts)[nscd-socket]: Remove.
* gnu/system/linux-container.scm (container-script)[nscd-run-directory]
[nscd-mapping, nscd-os, nscd-specs]: Remove.
[script]: Filter out from SPECS bind-mounts where the device does not
exist.
* guix/scripts/environment.scm (launch-environment/container)
[optional-mapping->fs]: New procedure.
[mappings]: Remove %NETWORK-FILE-MAPPINGS.
[file-systems]: Add %NETWORK-FILE-MAPPINGS here, filtered through
'optional-mapping->fs'.
Diffstat (limited to 'gnu/system/linux-container.scm')
| -rw-r--r-- | gnu/system/linux-container.scm | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index 6273cee3d30..451a72762c7 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm | |||
| @@ -147,13 +147,6 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." | |||
| 147 | "Return a derivation of a script that runs OS as a Linux container. | 147 | "Return a derivation of a script that runs OS as a Linux container. |
| 148 | MAPPINGS is a list of <file-system> objects that specify the files/directories | 148 | MAPPINGS is a list of <file-system> objects that specify the files/directories |
| 149 | that will be shared with the host system." | 149 | that will be shared with the host system." |
| 150 | (define nscd-run-directory "/var/run/nscd") | ||
| 151 | |||
| 152 | (define nscd-mapping | ||
| 153 | (file-system-mapping | ||
| 154 | (source nscd-run-directory) | ||
| 155 | (target nscd-run-directory))) | ||
| 156 | |||
| 157 | (define (mountable-file-system? file-system) | 150 | (define (mountable-file-system? file-system) |
| 158 | ;; Return #t if FILE-SYSTEM should be mounted in the container. | 151 | ;; Return #t if FILE-SYSTEM should be mounted in the container. |
| 159 | (and (not (string=? "/" (file-system-mount-point file-system))) | 152 | (and (not (string=? "/" (file-system-mount-point file-system))) |
| @@ -168,12 +161,7 @@ that will be shared with the host system." | |||
| 168 | os (cons %store-mapping mappings) | 161 | os (cons %store-mapping mappings) |
| 169 | #:shared-network? shared-network? | 162 | #:shared-network? shared-network? |
| 170 | #:extra-file-systems %container-file-systems)) | 163 | #:extra-file-systems %container-file-systems)) |
| 171 | (nscd-os (containerized-operating-system | 164 | (specs (os-file-system-specs os))) |
| 172 | os (cons* nscd-mapping %store-mapping mappings) | ||
| 173 | #:shared-network? shared-network? | ||
| 174 | #:extra-file-systems %container-file-systems)) | ||
| 175 | (specs (os-file-system-specs os)) | ||
| 176 | (nscd-specs (os-file-system-specs nscd-os))) | ||
| 177 | 165 | ||
| 178 | (define script | 166 | (define script |
| 179 | (with-imported-modules (source-module-closure | 167 | (with-imported-modules (source-module-closure |
| @@ -182,14 +170,19 @@ that will be shared with the host system." | |||
| 182 | #~(begin | 170 | #~(begin |
| 183 | (use-modules (gnu build linux-container) | 171 | (use-modules (gnu build linux-container) |
| 184 | (gnu system file-systems) ;spec->file-system | 172 | (gnu system file-systems) ;spec->file-system |
| 185 | (guix build utils)) | 173 | (guix build utils) |
| 186 | 174 | (srfi srfi-1)) | |
| 187 | (call-with-container | 175 | |
| 188 | (map spec->file-system | 176 | (define file-systems |
| 189 | (if (and #$shared-network? | 177 | (filter-map (lambda (spec) |
| 190 | (file-exists? #$nscd-run-directory)) | 178 | (let* ((fs (spec->file-system spec)) |
| 191 | '#$nscd-specs | 179 | (flags (file-system-flags fs))) |
| 192 | '#$specs)) | 180 | (and (or (not (memq 'bind-mount flags)) |
| 181 | (file-exists? (file-system-device fs))) | ||
| 182 | fs))) | ||
| 183 | '#$specs)) | ||
| 184 | |||
| 185 | (call-with-container file-systems | ||
| 193 | (lambda () | 186 | (lambda () |
| 194 | (setenv "HOME" "/root") | 187 | (setenv "HOME" "/root") |
| 195 | (setenv "TMPDIR" "/tmp") | 188 | (setenv "TMPDIR" "/tmp") |
