-(define (emacs-site-file)
- "Return the Emacs 'site-start.el' file. That file contains the necessary
-settings for 'guix.el' to work out-of-the-box."
- (gexp->file "site-start.el"
- #~(progn
- ;; Add the "normal" elisp directory to the search path;
- ;; guix.el may be there.
- (add-to-list
- 'load-path
- "/run/current-system/profile/share/emacs/site-lisp")
-
- ;; Attempt to load guix.el.
- (require 'guix-init nil t)
-
- ;; Attempt to load geiser.
- (require 'geiser-install nil t))))
-
-(define (emacs-site-directory)
- "Return the Emacs site directory, aka. /etc/emacs."
- (mlet %store-monad ((file (emacs-site-file)))
- (gexp->derivation "emacs"
- #~(begin
- (mkdir #$output)
- (chdir #$output)
- (symlink #$file "site-start.el")))))
-
-(define (user-shells os)
- "Return the list of all the shells used by the accounts of OS. These may be
-gexps or strings."
- (mlet %store-monad ((accounts (operating-system-accounts os)))
- (return (map user-account-shell accounts))))
-
-(define (shells-file shells)
- "Return a derivation that builds a shell list for use as /etc/shells based
-on SHELLS. /etc/shells is used by xterm, polkit, and other programs."
- (gexp->derivation "shells"
- #~(begin
- (use-modules (srfi srfi-1))
-
- (define shells
- (delete-duplicates (list #$@shells)))
-
- (call-with-output-file #$output
- (lambda (port)
- (display "\
-/bin/sh
-/run/current-system/profile/bin/sh
-/run/current-system/profile/bin/bash\n" port)
- (for-each (lambda (shell)
- (display shell port)
- (newline port))
- shells))))))
-
-(define* (etc-directory #:key
- (locale "C") (timezone "Europe/Paris")
- (issue "Hello!\n")
- (skeletons '())
- (pam-services '())
- (profile "/run/current-system/profile")
- hosts-file nss (shells '())
- (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))
- (login.defs (text-file "login.defs" "# Empty for now.\n"))
- (shells (shells-file shells))
- (emacs (emacs-site-directory))
- (issue (text-file "issue" issue))
- (nsswitch (text-file "nsswitch.conf"
- (name-service-switch->string nss)))
-
- ;; Startup file for POSIX-compliant login shells, which set system-wide
- ;; environment variables.
- (profile (text-file* "profile" "\
-export LANG=\"" locale "\"
-export TZ=\"" timezone "\"
-export TZDIR=\"" tzdata "/share/zoneinfo\"
-
-# Tell 'modprobe' & co. where to look for modules.
-export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules
-
-# These variables are honored by OpenSSL (libssl) and Git.
-export SSL_CERT_DIR=/etc/ssl/certs
-export SSL_CERT_FILE=\"$SSL_CERT_DIR/ca-certificates.crt\"
-export GIT_SSL_CAINFO=\"$SSL_CERT_FILE\"