;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
#:use-module (guix packages)
#:use-module (guix derivations)
#:use-module (guix profiles)
+ #:use-module (guix ui)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages guile)
operating-system-host-name
operating-system-hosts-file
operating-system-kernel
+ operating-system-kernel-arguments
operating-system-initrd
operating-system-users
operating-system-groups
operating-system?
(kernel operating-system-kernel ; package
(default linux-libre))
+ (kernel-arguments operating-system-kernel-arguments
+ (default '())) ; list of gexps/strings
(bootloader operating-system-bootloader) ; <grub-configuration>
(initrd operating-system-initrd ; (list fs) -> M derivation
(default %base-firmware))
(host-name operating-system-host-name) ; string
- (hosts-file operating-system-hosts-file ; M item | #f
+ (hosts-file operating-system-hosts-file ; file-like | #f
(default #f))
(mapped-devices operating-system-mapped-devices ; list of <mapped-device>
(setuid-programs operating-system-setuid-programs
(default %setuid-programs)) ; list of string-valued gexps
- (sudoers operating-system-sudoers ; /etc/sudoers contents
- (default %sudoers-specification)))
+ (sudoers-file operating-system-sudoers-file ; file-like
+ (default %sudoers-specification)))
\f
;;;
(operating-system-mapped-devices os)))
(define (requirements fs)
- (map (lambda (md)
- (symbol-append 'device-mapping-
- (string->symbol (mapped-device-target md))))
- (device-mappings fs)))
+ ;; XXX: Fiddling with dmd service names is not nice.
+ (append (map (lambda (fs)
+ (symbol-append 'file-system-
+ (string->symbol
+ (file-system-mount-point fs))))
+ (file-system-dependencies fs))
+ (map (lambda (md)
+ (symbol-append 'device-mapping-
+ (string->symbol (mapped-device-target md))))
+ (device-mappings fs))))
(sequence %store-monad
(map (lambda (fs)
(define (default-/etc/hosts host-name)
"Return the default /etc/hosts file."
- (text-file "hosts" (local-host-aliases host-name)))
+ (plain-file "hosts" (local-host-aliases host-name)))
(define (emacs-site-file)
"Return the Emacs 'site-start.el' file. That file contains the necessary
;; Attempt to load guix.el.
(require 'guix-init nil t)
- (when (require 'geiser-guile nil t)
- ;; Make sure Geiser's Scheme modules are in Guile's search
- ;; path.
- (add-to-list
- 'geiser-guile-load-path
- "/run/current-system/profile/share/geiser/guile")))))
+ ;; Attempt to load geiser.
+ (require 'geiser-install nil t))))
(define (emacs-site-directory)
"Return the Emacs site directory, aka. /etc/emacs."
(pam-services '())
(profile "/run/current-system/profile")
hosts-file nss (shells '())
- (sudoers ""))
+ (sudoers-file (plain-file "sudoers" "")))
"Return a derivation that builds the static part of the /etc directory."
(mlet* %store-monad
((pam.d (pam-services->directory pam-services))
- (sudoers (text-file "sudoers" sudoers))
(login.defs (text-file "login.defs" "# Empty for now.\n"))
(shells (shells-file shells))
(emacs (emacs-site-directory))
export SSL_CERT_FILE=\"$SSL_CERT_DIR/ca-certificates.crt\"
export GIT_SSL_CAINFO=\"$SSL_CERT_FILE\"
-# Crucial variables that could be missing the the profiles' 'etc/profile'
+# Crucial variables that could be missing in the profiles' 'etc/profile'
# because they would require combining both profiles.
# FIXME: See <http://bugs.gnu.org/20255>.
export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man
("hosts" ,#~#$hosts-file)
("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/"
#$timezone))
- ("sudoers" ,#~#$sudoers)))))
+ ("sudoers" ,sudoers-file)))))
(define (operating-system-profile os)
"Return a derivation that builds the system profile of OS."
(return (append users
(append-map service-user-accounts services)))))
+(define (maybe-string->file file-name thing)
+ "If THING is a string, return a <plain-file> with THING as its content.
+Otherwise just return THING.
+
+This is for backward-compatibility of fields that used to be strings and are
+now file-like objects.."
+ (match thing
+ ((? string?)
+ (warning (_ "using a string for file '~a' is deprecated; \
+use 'plain-file' instead~%")
+ file-name)
+ (plain-file file-name thing))
+ (x
+ x)))
+
+(define (maybe-file->monadic file-name thing)
+ "If THING is a value in %STORE-MONAD, return it as is; otherwise return
+THING in the %STORE-MONAD.
+
+This is for backward-compatibility of fields that used to be monadic values
+and are now file-like objects."
+ (with-monad %store-monad
+ (match thing
+ ((? procedure?)
+ (warning (_ "using a monadic value for '~a' is deprecated; \
+use 'plain-file' instead~%")
+ file-name)
+ thing)
+ (x
+ (return x)))))
+
(define (operating-system-etc-directory os)
"Return that static part of the /etc directory of OS."
(mlet* %store-monad
(append-map service-pam-services services)))
(profile-drv (operating-system-profile os))
(skeletons (operating-system-skeletons os))
- (/etc/hosts (or (operating-system-hosts-file os)
- (default-/etc/hosts (operating-system-host-name os))))
+ (/etc/hosts (maybe-file->monadic
+ "hosts"
+ (or (operating-system-hosts-file os)
+ (default-/etc/hosts (operating-system-host-name os)))))
(shells (user-shells os)))
(etc-directory #:pam-services pam-services
#:skeletons skeletons
#:timezone (operating-system-timezone os)
#:hosts-file /etc/hosts
#:shells shells
- #:sudoers (operating-system-sudoers os)
+ #:sudoers-file (maybe-string->file
+ "sudoers"
+ (operating-system-sudoers-file os))
#:profile profile-drv)))
(define %setuid-programs
(list #~(string-append #$shadow "/bin/passwd")
#~(string-append #$shadow "/bin/su")
#~(string-append #$inetutils "/bin/ping")
+ #~(string-append #$inetutils "/bin/ping6")
#~(string-append #$sudo "/bin/sudo")
#~(string-append #$fuse "/bin/fusermount"))))
;; group can do anything. See
;; <http://www.sudo.ws/sudo/man/1.8.10/sudoers.man.html>.
;; TODO: Add a declarative API.
- "root ALL=(ALL) ALL
-%wheel ALL=(ALL) ALL\n")
+ (plain-file "sudoers" "\
+root ALL=(ALL) ALL
+%wheel ALL=(ALL) ALL\n"))
(define (user-group->gexp group)
"Turn GROUP, a <user-group> object, into a list-valued gexp suitable for
(gnu build linux-modules)
(gnu build file-systems)
(guix build utils)
+ (guix build syscalls)
(guix elf)))
(define (service-activations services)
(label (kernel->grub-label kernel))
(linux kernel)
(linux-arguments
- (list (string-append "--root="
- (file-system-device root-fs))
- #~(string-append "--system=" #$system)
- #~(string-append "--load=" #$system
- "/boot")))
+ (cons* (string-append "--root="
+ (file-system-device root-fs))
+ #~(string-append "--system=" #$system)
+ #~(string-append "--load=" #$system
+ "/boot")
+ (operating-system-kernel-arguments os)))
(initrd #~(string-append #$system "/initrd"))))))
(grub-configuration-file (operating-system-bootloader os) entries
#:old-entries old-entries)))
(label #$label)
(root-device #$(file-system-device root))
(kernel #$(operating-system-kernel os))
+ (kernel-arguments
+ #$(operating-system-kernel-arguments os))
(initrd #$initrd)))))
(define (operating-system-derivation os)