guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

05/08: gnu: Add Linux container system script.


From: David Thompson
Subject: 05/08: gnu: Add Linux container system script.
Date: Sat, 13 Jun 2015 03:44:26 +0000

davexunit pushed a commit to branch wip-container
in repository guix.

commit d3612f203ebea572e8edb846174786701062339c
Author: David Thompson <address@hidden>
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 |   55 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/gnu-system.am b/gnu-system.am
index 43de4c2..d3155fb 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -345,6 +345,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..265b58d
--- /dev/null
+++ b/gnu/system/linux-container.scm
@@ -0,0 +1,55 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 David Thompson <address@hidden>
+;;;
+;;; 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 #:key root-dir)
+  (mlet* %store-monad
+      ((os-drv (operating-system-derivation/container os)))
+
+    (define script
+      #~(begin
+          (use-modules (guix build utils)
+                       (gnu build linux-container))
+
+          (for-each (lambda (dir)
+                      (mkdir-p (string-append #$root-dir dir)))
+                    '("/run" "/bin" "/etc" "/home"))
+
+          (define pid
+            (call-with-container #$root-dir
+                '((#$(%store-prefix) #$(%store-prefix))) ; bind the store
+              (lambda ()
+                (primitive-load (string-append #$os-drv "/boot")))))
+
+          (display pid)
+          (newline)))
+
+    (gexp->script "run-container" script
+                  #:modules '((guix build utils)
+                              (guix build syscalls)
+                              (gnu build linux-container)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]