mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 15:36:20 -05:00
file-systems: Add 'file-system-mapping->bind-mount'.
* gnu/system/file-systems.scm (file-system-mapping->bind-mount): New procedure. * gnu/system/linux-container.scm (mapping->file-system): Remove. (containerized-operating-system)[mapping->fs]: Use 'file-system-mapping->bind-mount' instead of 'mapping->file-system'. * guix/scripts/environment.scm (launch-environment/container): Likewise.
This commit is contained in:
parent
0f31d4f07f
commit
d2a5e6982d
3 changed files with 22 additions and 19 deletions
|
@ -63,6 +63,8 @@ (define-module (gnu system file-systems)
|
|||
file-system-mapping-target
|
||||
file-system-mapping-writable?
|
||||
|
||||
file-system-mapping->bind-mount
|
||||
|
||||
%store-mapping))
|
||||
|
||||
;;; Commentary:
|
||||
|
@ -352,6 +354,21 @@ (define-record-type* <file-system-mapping> file-system-mapping
|
|||
(writable? file-system-mapping-writable? ;Boolean
|
||||
(default #f)))
|
||||
|
||||
(define (file-system-mapping->bind-mount mapping)
|
||||
"Return a file system that realizes MAPPING, a <file-system-mapping>, using
|
||||
a bind mount."
|
||||
(match mapping
|
||||
(($ <file-system-mapping> source target writable?)
|
||||
(file-system
|
||||
(mount-point target)
|
||||
(device source)
|
||||
(type "none")
|
||||
(flags (if writable?
|
||||
'(bind-mount)
|
||||
'(bind-mount read-only)))
|
||||
(check? #f)
|
||||
(create-mount-point? #t)))))
|
||||
|
||||
(define %store-mapping
|
||||
;; Mapping of the host's store into the guest.
|
||||
(file-system-mapping
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015 David Thompson <davet@gnu.org>
|
||||
;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -30,25 +30,10 @@ (define-module (gnu system linux-container)
|
|||
#:use-module (gnu services)
|
||||
#:use-module (gnu system)
|
||||
#:use-module (gnu system file-systems)
|
||||
#:export (mapping->file-system
|
||||
system-container
|
||||
#:export (system-container
|
||||
containerized-operating-system
|
||||
container-script))
|
||||
|
||||
(define (mapping->file-system mapping)
|
||||
"Return a file system that realizes MAPPING."
|
||||
(match mapping
|
||||
(($ <file-system-mapping> source target writable?)
|
||||
(file-system
|
||||
(mount-point target)
|
||||
(device source)
|
||||
(type "none")
|
||||
(flags (if writable?
|
||||
'(bind-mount)
|
||||
'(bind-mount read-only)))
|
||||
(check? #f)
|
||||
(create-mount-point? #t)))))
|
||||
|
||||
(define (containerized-operating-system os mappings)
|
||||
"Return an operating system based on OS for use in a Linux container
|
||||
environment. MAPPINGS is a list of <file-system-mapping> to realize in the
|
||||
|
@ -66,7 +51,7 @@ (define user-file-systems
|
|||
(operating-system-file-systems os)))
|
||||
|
||||
(define (mapping->fs fs)
|
||||
(file-system (inherit (mapping->file-system fs))
|
||||
(file-system (inherit (file-system-mapping->bind-mount fs))
|
||||
(needed-for-boot? #t)))
|
||||
|
||||
(operating-system (inherit os)
|
||||
|
|
|
@ -433,7 +433,8 @@ (define* (launch-environment/container #:key command bash user-mappings
|
|||
(writable? #f)))
|
||||
reqs)))
|
||||
(file-systems (append %container-file-systems
|
||||
(map mapping->file-system mappings))))
|
||||
(map file-system-mapping->bind-mount
|
||||
mappings))))
|
||||
(exit/status
|
||||
(call-with-container file-systems
|
||||
(lambda ()
|
||||
|
|
Loading…
Reference in a new issue