gnu: vm: Add /run/current-system and /bin/sh.

* gnu/system/vm.scm (operating-system-default-contents): Populate
  /run/current-system and create /bin/sh.
* gnu/system.scm (operating-system-profile-derivation,
  operating-system-profile-directory): New procedures.
  (operating-system-derivation): Use it.
This commit is contained in:
Ludovic Courtès 2014-02-02 01:34:33 +01:00
parent 92cb2e2888
commit f6a9d0484c
2 changed files with 22 additions and 8 deletions

View File

@ -49,6 +49,7 @@
operating-system-locale operating-system-locale
operating-system-services operating-system-services
operating-system-profile-directory
operating-system-derivation)) operating-system-derivation))
;;; Commentary: ;;; Commentary:
@ -284,6 +285,17 @@ alias ll='ls -l'
("pam.d" ,pam.d)) ("pam.d" ,pam.d))
#:name "etc"))) #:name "etc")))
(define (operating-system-profile-derivation os)
"Return a derivation that builds the default profile of OS."
;; TODO: Replace with a real profile with a manifest.
(union (operating-system-packages os)
#:name "default-profile"))
(define (operating-system-profile-directory os)
"Return the directory name of the default profile of OS."
(mlet %store-monad ((drv (operating-system-profile-derivation os)))
(return (derivation->output-path drv))))
(define (operating-system-derivation os) (define (operating-system-derivation os)
"Return a derivation that builds OS." "Return a derivation that builds OS."
(mlet* %store-monad (mlet* %store-monad
@ -310,11 +322,8 @@ alias ll='ls -l'
services)))) services))))
(groups -> (append (operating-system-groups os) (groups -> (append (operating-system-groups os)
(append-map service-user-groups services))) (append-map service-user-groups services)))
(packages -> (operating-system-packages os))
;; TODO: Replace with a real profile with a manifest. (profile-drv (operating-system-profile-derivation os))
(profile-drv (union packages
#:name "default-profile"))
(profile -> (derivation->output-path profile-drv)) (profile -> (derivation->output-path profile-drv))
(etc-drv (etc-directory #:accounts accounts #:groups groups (etc-drv (etc-directory #:accounts accounts #:groups groups
#:pam-services pam-services #:pam-services pam-services

View File

@ -458,15 +458,20 @@ such as /etc files."
(define (operating-system-default-contents os) (define (operating-system-default-contents os)
"Return a list of directives suitable for 'system-qemu-image' describing the "Return a list of directives suitable for 'system-qemu-image' describing the
basic contents of the root file system of OS." basic contents of the root file system of OS."
(mlet* %store-monad ((os-drv (operating-system-derivation os)) (mlet* %store-monad ((os-drv (operating-system-derivation os))
(os-dir -> (derivation->output-path os-drv)) (os-dir -> (derivation->output-path os-drv))
(build-user-gid (operating-system-build-gid os))) (build-gid (operating-system-build-gid os))
(return `((directory "/nix/store" 0 ,(or build-user-gid 0)) (profile (operating-system-profile-directory os)))
(return `((directory "/nix/store" 0 ,(or build-gid 0))
(directory "/etc") (directory "/etc")
(directory "/var/log") ; for dmd (directory "/var/log") ; for dmd
(directory "/var/run/nscd") (directory "/var/run/nscd")
(directory "/var/nix/gcroots") (directory "/var/nix/gcroots")
("/var/nix/gcroots/system" -> ,os-dir) ("/var/nix/gcroots/system" -> ,os-dir)
(directory "/run")
("/run/current-system" -> ,profile)
(directory "/bin")
("/bin/sh" -> "/run/current-system/bin/sh")
(directory "/tmp") (directory "/tmp")
(directory "/var/nix/profiles/per-user/root" 0 0) (directory "/var/nix/profiles/per-user/root" 0 0)
(directory "/var/nix/profiles/per-user/guest" (directory "/var/nix/profiles/per-user/guest"