aboutsummaryrefslogtreecommitdiff
path: root/gnu/system/shadow.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-10-03 21:30:30 +0200
committerLudovic Courtès <ludo@gnu.org>2013-10-03 23:12:20 +0200
commitd9f0a23704a038640329fae6e2273e5813cdb8ab (patch)
tree149b6f0d423e8261dc59580a54b8f4f9b37f26a6 /gnu/system/shadow.scm
parentb860f382447a360ea2ce8a89d3357279cc652c3a (diff)
downloadpatches-d9f0a23704a038640329fae6e2273e5813cdb8ab.tar
patches-d9f0a23704a038640329fae6e2273e5813cdb8ab.tar.gz
gnu: vm: Rewrite helper functions as monadic functions.
* gnu/system/dmd.scm (host-name-service, nscd-service, mingetty-service, syslog-service, guix-service, static-networking-service): Rewrite as monadic functions. (dmd-configuration-file): Use 'text-file' instead of 'add-text-to-store'. * gnu/system/grub.scm (grub-configuration-file): Rewrite as a monadic function. * gnu/system/linux.scm (pam-services->directory): Likewise. * gnu/system/shadow.scm (group-file, passwd-file, guix-build-accounts): Likewise. * gnu/system/vm.scm (expression->derivation-in-linux-vm, qemu-image, union, system-qemu-image): Likewise.
Diffstat (limited to 'gnu/system/shadow.scm')
-rw-r--r--gnu/system/shadow.scm40
1 files changed, 20 insertions, 20 deletions
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 4f59b2b325..654fd4d55b 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -20,6 +20,7 @@
#:use-module (guix store)
#:use-module (guix records)
#:use-module (guix packages)
+ #:use-module (guix monads)
#:use-module ((gnu packages system)
#:select (shadow))
#:use-module (srfi srfi-1)
@@ -72,7 +73,7 @@
(id user-group-id)
(members user-group-members (default '())))
-(define (group-file store groups)
+(define (group-file groups)
"Return a /etc/group file for GROUPS, a list of <user-group> objects."
(define contents
(let loop ((groups groups)
@@ -87,9 +88,9 @@
(()
(string-join (reverse result) "\n" 'suffix)))))
- (add-text-to-store store "group" contents))
+ (text-file "group" contents))
-(define* (passwd-file store accounts #:key shadow?)
+(define* (passwd-file accounts #:key shadow?)
"Return a password file for ACCOUNTS, a list of <user-account> objects. If
SHADOW? is true, then it is a /etc/shadow file, otherwise it is a /etc/passwd
file."
@@ -114,28 +115,27 @@ file."
(()
(string-join (reverse result) "\n" 'suffix)))))
- (add-text-to-store store (if shadow? "shadow" "passwd")
- contents '()))
+ (text-file (if shadow? "shadow" "passwd") contents))
-(define* (guix-build-accounts store count #:key
+(define* (guix-build-accounts count #:key
(first-uid 30001)
(gid 30000)
(shadow shadow))
"Return a list of COUNT user accounts for Guix build users, with UIDs
starting at FIRST-UID, and under GID."
- (let* ((gid* gid)
- (no-login (string-append (package-output store shadow) "/sbin/nologin")))
- (unfold (cut > <> count)
- (lambda (n)
- (user-account
- (name (format #f "guixbuilder~2,'0d" n))
- (password "!")
- (uid (+ first-uid n -1))
- (gid gid*)
- (comment (format #f "Guix Build User ~2d" n))
- (home-directory "/var/empty")
- (shell no-login)))
- 1+
- 1)))
+ (mlet* %store-monad ((gid* -> gid)
+ (no-login (package-file shadow "sbin/nologin")))
+ (return (unfold (cut > <> count)
+ (lambda (n)
+ (user-account
+ (name (format #f "guixbuilder~2,'0d" n))
+ (password "!")
+ (uid (+ first-uid n -1))
+ (gid gid*)
+ (comment (format #f "Guix Build User ~2d" n))
+ (home-directory "/var/empty")
+ (shell no-login)))
+ 1+
+ 1))))
;;; shadow.scm ends here