gnu: lv2-mda-piano: change source URL.
[jackhill/guix/guix.git] / gnu / system.scm
index e1ed1a2..0d510b6 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages guile)
-  #:use-module (gnu packages which)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages pciutils)
   #:use-module (gnu packages package-management)
-  #:use-module (gnu packages which)
   #:use-module (gnu packages less)
   #:use-module (gnu packages zile)
   #:use-module (gnu packages nano)
   #:use-module (gnu packages lsof)
   #:use-module (gnu packages gawk)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages firmware)
   #:autoload   (gnu packages cryptsetup) (cryptsetup)
@@ -46,6 +45,7 @@
   #:use-module (gnu services base)
   #:use-module (gnu system grub)
   #:use-module (gnu system shadow)
+  #:use-module (gnu system nss)
   #:use-module (gnu system locale)
   #:use-module (gnu system linux)
   #:use-module (gnu system linux-initrd)
@@ -69,7 +69,6 @@
             operating-system-users
             operating-system-groups
             operating-system-issue
-            operating-system-packages
             operating-system-timezone
             operating-system-locale
             operating-system-locale-definitions
             (default "en_US.utf8"))
   (locale-definitions operating-system-locale-definitions ; list of <locale-definition>
                       (default %default-locale-definitions))
+  (name-service-switch operating-system-name-service-switch ; <name-service-switch>
+                       (default %default-nss))
 
   (services operating-system-user-services        ; list of monadic services
             (default %base-services))
@@ -331,8 +332,19 @@ explicitly appear in OS."
          (@ (gnu packages admin) dmd) guix
          lsof                                 ;for Guix's 'list-runtime-roots'
          pciutils usbutils
-         util-linux inetutils isc-dhcp wireless-tools
+         util-linux inetutils isc-dhcp
+
+         ;; wireless-tools is deprecated in favor of iw, but it's still what
+         ;; many people are familiar with, so keep it around.
+         iw wireless-tools
+
          net-tools                        ; XXX: remove when Inetutils suffices
+         man-db
+
+         ;; The 'sudo' command is already in %SETUID-PROGRAMS, but we also
+         ;; want the other commands and the man pages (notably because
+         ;; auto-completion in Emacs shell relies on man pages.)
+         sudo
 
          ;; Get 'insmod' & co. from kmod, not module-init-tools, since udev
          ;; already depends on it anyway.
@@ -340,6 +352,8 @@ explicitly appear in OS."
 
          e2fsprogs kbd
 
+         bash-completion
+
          ;; The packages below are also in %FINAL-INPUTS, so take them from
          ;; there to avoid duplication.
          (map canonical-package
@@ -360,35 +374,69 @@ This is the GNU system.  Welcome.\n")
   "Return the default /etc/hosts file."
   (text-file "hosts" (local-host-aliases host-name)))
 
+(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)
+
+                 (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")))))
+
+(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* (etc-directory #:key
                         (locale "C") (timezone "Europe/Paris")
                         (issue "Hello!\n")
                         (skeletons '())
                         (pam-services '())
                         (profile "/run/current-system/profile")
-                        hosts-file
+                        hosts-file nss
                         (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     (text-file "shells"            ; used by xterm and others
+
+       ;; /etc/shells is used by xterm and other programs.   We don't check
+       ;; whether these shells are installed, should be OK.
+       (shells     (text-file "shells"
                               "\
 /bin/sh
 /run/current-system/profile/bin/sh
-/run/current-system/profile/bin/bash\n"))
+/run/current-system/profile/bin/bash
+/run/current-system/profile/bin/fish
+/run/current-system/profile/bin/tcsh
+/run/current-system/profile/bin/zsh\n"))
+       (emacs      (emacs-site-directory))
        (issue      (text-file "issue" issue))
-
-       ;; For now, generate a basic config so that /etc/hosts is honored.
        (nsswitch   (text-file "nsswitch.conf"
-                              "hosts: files dns\n"))
-
-       ;; TODO: Generate bashrc from packages' search-paths.
-       (bashrc    (text-file* "bashrc"  "
-export PS1='\\u@\\h \\w\\$ '
+                              (name-service-switch->string nss)))
 
-export LC_ALL=\"" locale "\"
+       ;; 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\"
 
@@ -397,24 +445,59 @@ export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules
 
 export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin
 export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH
-export CPATH=$HOME/.guix-profile/include:" profile "/include
-export LIBRARY_PATH=$HOME/.guix-profile/lib:" profile "/lib
+export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man
 export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
-alias ls='ls -p --color'
-alias ll='ls -l'
+
+export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share
+export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg
+
+# Append the directory of 'site-start.el' to the search path.
+export EMACSLOADPATH=:/etc/emacs
+
+# By default, applications that use D-Bus, such as Emacs, abort at startup
+# when /etc/machine-id is missing.  Make sure these warnings are non-fatal.
+export DBUS_FATAL_WARNINGS=0
+
+# 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\"
+
+# Allow Aspell to find dictionaries installed in the user profile.
+export ASPELL_CONF=\"dict-dir $HOME/.guix-profile/lib/aspell\"
+
+if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
+then
+  # Load Bash-specific initialization code.
+  source /etc/bashrc
+fi
 "))
+
+       (bashrc    (text-file "bashrc" "\
+# Bash-specific initialization.
+
+# The 'bash-completion' package.
+if [ -f /run/current-system/profile/etc/profile.d/bash_completion.sh ]
+then
+  # Bash-completion sources ~/.bash_completion.  It installs a dynamic
+  # completion loader that searches its own completion files as well
+  # as those in ~/.guix-profile and /run/current-system/profile.
+  source /run/current-system/profile/etc/profile.d/bash_completion.sh
+fi\n"))
        (skel      (skeleton-directory skeletons)))
     (file-union "etc"
                 `(("services" ,#~(string-append #$net-base "/etc/services"))
                   ("protocols" ,#~(string-append #$net-base "/etc/protocols"))
                   ("rpc" ,#~(string-append #$net-base "/etc/rpc"))
+                  ("emacs" ,#~#$emacs)
                   ("pam.d" ,#~#$pam.d)
                   ("login.defs" ,#~#$login.defs)
                   ("issue" ,#~#$issue)
                   ("nsswitch.conf" ,#~#$nsswitch)
                   ("skel" ,#~#$skel)
                   ("shells" ,#~#$shells)
-                  ("profile" ,#~#$bashrc)
+                  ("profile" ,#~#$profile)
+                  ("bashrc" ,#~#$bashrc)
                   ("hosts" ,#~#$hosts-file)
                   ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/"
                                                  #$timezone))
@@ -454,9 +537,8 @@ alias ll='ls -l'
       ((services     (operating-system-services os))
        (pam-services ->
                      ;; Services known to PAM.
-                     (delete-duplicates
-                      (append (operating-system-pam-services os)
-                              (append-map service-pam-services services))))
+                     (append (operating-system-pam-services os)
+                             (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)
@@ -465,6 +547,7 @@ alias ll='ls -l'
                   #:skeletons skeletons
                   #:issue (operating-system-issue os)
                   #:locale (operating-system-locale os)
+                  #:nss (operating-system-name-service-switch os)
                   #:timezone (operating-system-timezone os)
                   #:hosts-file /etc/hosts
                   #:sudoers (operating-system-sudoers os)