From 78ed003811a38a7a3de56316755a2808b7d87e45 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 9 Dec 2013 22:29:01 +0100 Subject: gnu: Add 'inputs' field to ; make 'shell' a monadic value. * gnu/system/shadow.scm ()[inputs]: New field. (passwd-file): Bind the 'shell' field of each account. * gnu/system/vm.scm (%demo-operating-system): Remove 'shell' field. * gnu/system/dmd.scm (guix-build-accounts): Store a monadic value in 'shell'. Add 'inputs' field. * gnu/system.scm (operating-system-derivation): Remove 'shell' field for 'root' account. Add all the 'user-account-inputs' to EXTRAS. --- gnu/system/shadow.scm | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'gnu/system/shadow.scm') diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index 2cc0b89162..ca24c3df2b 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -23,6 +23,7 @@ #:use-module (guix monads) #:use-module ((gnu packages system) #:select (shadow)) + #:use-module (gnu packages bash) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (user-account @@ -34,6 +35,7 @@ user-account-comment user-account-home-directory user-account-shell + user-account-inputs user-group user-group? @@ -61,7 +63,9 @@ (gid user-account-gid) (comment user-account-comment (default "")) (home-directory user-account-home-directory) - (shell user-account-shell (default "/bin/sh"))) + (shell user-account-shell ; monadic value + (default (package-file bash "bin/bash"))) + (inputs user-account-inputs (default `(("bash" ,bash))))) (define-record-type* user-group make-user-group @@ -93,26 +97,29 @@ SHADOW? is true, then it is a /etc/shadow file, otherwise it is a /etc/passwd file." ;; XXX: The resulting file is world-readable, so beware when SHADOW? is #t! - (define contents - (let loop ((accounts accounts) - (result '())) - (match accounts - ((($ name pass uid gid comment home-dir shell) - rest ...) - (loop rest - (cons (if shadow? - (string-append name - ":" ; XXX: use (crypt PASS …)? - ":::::::") - (string-append name - ":" "x" - ":" (number->string uid) - ":" (number->string gid) - ":" comment ":" home-dir ":" shell)) - result))) - (() - (string-join (reverse result) "\n" 'suffix))))) + (define (contents) + (with-monad %store-monad + (let loop ((accounts accounts) + (result '())) + (match accounts + ((($ name pass uid gid comment home-dir mshell) + rest ...) + (mlet %store-monad ((shell mshell)) + (loop rest + (cons (if shadow? + (string-append name + ":" ; XXX: use (crypt PASS …)? + ":::::::") + (string-append name + ":" "x" + ":" (number->string uid) + ":" (number->string gid) + ":" comment ":" home-dir ":" shell)) + result)))) + (() + (return (string-join (reverse result) "\n" 'suffix))))))) - (text-file (if shadow? "shadow" "passwd") contents)) + (mlet %store-monad ((contents (contents))) + (text-file (if shadow? "shadow" "passwd") contents))) ;;; shadow.scm ends here -- cgit v1.2.3