davexunit pushed a commit to branch wip-container in repository guix. commit 87c2fdd7bf57e529aed8155b549fcab7df55cfa9 Author: David Thompson <da...@gnu.org> Date: Mon Jun 8 08:59:00 2015 -0400
gnu: Add Linux container system script. * gnu/system/linux-container.scm: New file. * gnu-system.am (GNU_SYSTEM_MODULES): Add it. --- gnu-system.am | 1 + gnu/system/linux-container.scm | 50 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/gnu-system.am b/gnu-system.am index 3bb8982..286abfa 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -346,6 +346,7 @@ GNU_SYSTEM_MODULES = \ gnu/system/grub.scm \ gnu/system/install.scm \ gnu/system/linux.scm \ + gnu/system/linux-container.scm \ gnu/system/linux-initrd.scm \ gnu/system/locale.scm \ gnu/system/nss.scm \ diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm new file mode 100644 index 0000000..bab27cf --- /dev/null +++ b/gnu/system/linux-container.scm @@ -0,0 +1,50 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2015 David Thompson <da...@gnu.org> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu system linux-container) + #:use-module (guix config) + #:use-module (guix store) + #:use-module (guix gexp) + #:use-module (guix derivations) + #:use-module (guix monads) + #:use-module (gnu build linux-container) + #:use-module (gnu system) + #:use-module (gnu services) + #:export (linux-container-script)) + +(define (linux-container-script os) + (mlet* %store-monad + ((os-drv (operating-system-derivation/container os))) + + (define script + #~(begin + (use-modules (guix build utils) + (gnu build linux-container)) + + ;; Bind-mount the store. + (call-with-container '((#$(%store-prefix) #$(%store-prefix))) + (lambda () + (for-each mkdir '("/run" "/bin" "/etc" "/home")) + (primitive-load (string-append #$os-drv "/boot")))))) + + (gexp->script "run-container" script + #:modules '((guix config) + (guix utils) + (guix build utils) + (guix build syscalls) + (gnu build linux-container)))))