- (define %modules
- '((gnu build activation)
- (gnu build linux-boot)
- (gnu build linux-modules)
- (gnu build file-systems)
- (guix build utils)
- (guix elf)))
-
- (define (service-activations services)
- ;; Return the activation scripts for SERVICES.
- (let ((gexps (filter-map service-activate services)))
- (sequence %store-monad (map (cut gexp->file "activate-service.scm" <>)
- gexps))))
-
- (mlet* %store-monad ((services (operating-system-services os))
- (actions (service-activations services))
- (etc (operating-system-etc-directory os))
- (modules (imported-modules %modules))
- (compiled (compiled-modules %modules))
- (modprobe (modprobe-wrapper))
- (firmware (directory-union
- "firmware" (operating-system-firmware os)))
- (accounts (operating-system-accounts os)))
- (define setuid-progs
- (operating-system-setuid-programs os))
-
- (define user-specs
- (map user-account->gexp accounts))
-
- (define groups
- (append (operating-system-groups os)
- (append-map service-user-groups services)))
-
- (define group-specs
- (map user-group->gexp groups))
-
- (gexp->file "activate"
- #~(begin
- (eval-when (expand load eval)
- ;; Make sure 'use-modules' below succeeds.
- (set! %load-path (cons #$modules %load-path))
- (set! %load-compiled-path
- (cons #$compiled %load-compiled-path)))
-
- (use-modules (gnu build activation))
-
- ;; Make sure /bin/sh is valid and current.
- (activate-/bin/sh
- (string-append #$(canonical-package bash)
- "/bin/sh"))
-
- ;; Populate /etc.
- (activate-etc #$etc)
-
- ;; Add users and user groups.
- (setenv "PATH"
- (string-append #$(@ (gnu packages admin) shadow)
- "/sbin"))
- (activate-users+groups (list #$@user-specs)
- (list #$@group-specs))
-
- ;; Activate setuid programs.
- (activate-setuid-programs (list #$@setuid-progs))
-
- ;; Tell the kernel to use our 'modprobe' command.
- (activate-modprobe #$modprobe)
-
- ;; Tell the kernel where firmware is.
- (activate-firmware
- (string-append #$firmware "/lib/firmware"))
-
- ;; Run the services' activation snippets.
- ;; TODO: Use 'load-compiled'.
- (for-each primitive-load '#$actions)
-
- ;; Set up /run/current-system.
- (activate-current-system)))))
-
-(define (operating-system-boot-script os)