From 32adf2c5219c88d7b1fbc567bfc17ab89cc09142 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Sat, 3 Jan 2009 09:07:52 +0000 Subject: [PATCH 01/39] Option for proxy usage in Nix daemon svn path=/nixos/trunk/; revision=13689 --- system/options.nix | 10 ++++++++++ system/system.nix | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/system/options.nix b/system/options.nix index 92d6288c597..c6f9e9a0e0f 100644 --- a/system/options.nix +++ b/system/options.nix @@ -2682,6 +2682,16 @@ in "; }; + proxy = mkOption { + default = ""; + description = " + This option specifies the proxy to use for fetchurl. The real effect + is just exporting http_proxy, https_proxy and ftp_proxy with that + value. + "; + example = "http://127.0.0.1:3128"; + }; + }; diff --git a/system/system.nix b/system/system.nix index 948b9a6a345..3cbbc8ddfee 100644 --- a/system/system.nix +++ b/system/system.nix @@ -103,7 +103,15 @@ rec { export NIX_REMOTE_SYSTEMS=/etc/nix.machines export NIX_CURRENT_LOAD=/var/run/nix/current-load '' - else ""); + else "") + + + (if config.nix.proxy != "" then + '' + export http_proxy=${config.nix.proxy} + export https_proxy=${config.nix.proxy} + export ftp_proxy=${config.nix.proxy} + '' else "") + ; # The services (Upstart) configuration for the system. From aa393f816c0647d889818879792b7b298b4a109b Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Thu, 8 Jan 2009 21:50:27 +0000 Subject: [PATCH 02/39] Allowing direct package use in manual expression svn path=/nixos/trunk/; revision=13724 --- doc/manual/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/manual/default.nix b/doc/manual/default.nix index a7f51adf287..56657aec2e2 100644 --- a/doc/manual/default.nix +++ b/doc/manual/default.nix @@ -1,8 +1,10 @@ -{nixpkgsPath ? ../../../nixpkgs}: +{nixpkgsPath ? ../../../nixpkgs, pkgs ? null}: let - pkgs = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {}; + pkgs = if pkgs == null then + import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {} + else pkgs; options = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext (builtins.toXML (pkgs.lib.optionAttrSetToDocList "" From 0a1f41c7427a5e376cf02c27b6c16f61c416a303 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Thu, 8 Jan 2009 23:30:23 +0000 Subject: [PATCH 03/39] An upstart job to display manual svn path=/nixos/trunk/; revision=13728 --- doc/manual/default.nix | 6 +-- system/options.nix | 1 + system/system.nix | 5 ++- upstart-jobs/manual.nix | 87 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 upstart-jobs/manual.nix diff --git a/doc/manual/default.nix b/doc/manual/default.nix index 56657aec2e2..c46e89d0fa1 100644 --- a/doc/manual/default.nix +++ b/doc/manual/default.nix @@ -1,10 +1,10 @@ -{nixpkgsPath ? ../../../nixpkgs, pkgs ? null}: +{nixpkgsPath ? ../../../nixpkgs, nixpkgs ? null}: let - pkgs = if pkgs == null then + pkgs = if nixpkgs == null then import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {} - else pkgs; + else nixpkgs; options = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext (builtins.toXML (pkgs.lib.optionAttrSetToDocList "" diff --git a/system/options.nix b/system/options.nix index c6f9e9a0e0f..1a70a2f951c 100644 --- a/system/options.nix +++ b/system/options.nix @@ -3063,5 +3063,6 @@ root ALL=(ALL) SETENV: ALL (import ../upstart-jobs/cron.nix) (import ../upstart-jobs/fcron.nix) (import ../upstart-jobs/cron/locate.nix) + (import ../upstart-jobs/manual.nix) ]; } diff --git a/system/system.nix b/system/system.nix index 3cbbc8ddfee..bbb7d83f543 100644 --- a/system/system.nix +++ b/system/system.nix @@ -1,6 +1,7 @@ { platform ? __currentSystem , configuration , nixpkgsPath ? ../../nixpkgs +, nixpkgs ? null }: rec { @@ -26,7 +27,9 @@ rec { pkgs configComponents config; - pkgs = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {system = platform;}; + pkgs = if nixpkgs == null then + import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {system = platform;} + else nixpkgs; manifests = config.installer.manifests; # exported here because nixos-rebuild uses it diff --git a/upstart-jobs/manual.nix b/upstart-jobs/manual.nix new file mode 100644 index 00000000000..5d658ce7681 --- /dev/null +++ b/upstart-jobs/manual.nix @@ -0,0 +1,87 @@ +{pkgs, config}: + +# Show the NixOS manual on tty7 +# Originally used only by installation CD + +let + inherit (pkgs.lib) mkOption; + options = { + services = { + showManual = { + enable = mkOption { + default = false; + description = " + Whether to show the NixOS manual on the tty7 + "; + }; + ttyNumber = mkOption { + default = "7"; + description = " + TTY number name to show the manual on + "; + }; + browserPackage = mkOption { + default = pkgs.w3m; + description = " + Package containing the browser to be used + "; + }; + browserCommand = mkOption { + default = "bin/w3m"; + description = " + Command (command path is relative to browserPackage) to run the browser + "; + }; + manualFile = mkOption { + default = null; + description = " + NixOS manual HTML file + "; + }; + }; + }; + }; + +inherit(pkgs.lib) optional; + +inherit (config.services.showManual) enable ttyNumber browserPackage browserCommand + manualFile; + +realManualFile = if manualFile == null then + (import ../doc/manual {nixpkgs = pkgs;})+"/manual.html" +else manualFile; + +in + +{ + require = [ + options + ]; + + boot = { + extraTTYs = optional enable ttyNumber; + }; + + services = { + extraJobs = optional enable { + name = "showManual"; + + job = '' + description "NixOS manual" + + start on udev + stop on shutdown + respawn ${browserPackage}/${browserCommand} ${realManualFile} < /dev/tty${toString ttyNumber} > /dev/tty${toString ttyNumber} 2>&1 + ''; + }; + ttyBackgrounds = { + specificThemes = optional enable { + tty = ttyNumber; + theme = pkgs.themes "green"; + }; + }; + mingetty = { + helpLine = if enable then "\nPress for NixOS manual." else ""; + }; + }; +} From 9a46e71e7b49937c7c19c7d39d1ec5254bad450a Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Thu, 8 Jan 2009 23:49:22 +0000 Subject: [PATCH 04/39] Added rogue job used by CD svn path=/nixos/trunk/; revision=13730 --- system/options.nix | 1 + upstart-jobs/rogue.nix | 64 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 upstart-jobs/rogue.nix diff --git a/system/options.nix b/system/options.nix index 1a70a2f951c..e70bb51628c 100644 --- a/system/options.nix +++ b/system/options.nix @@ -3064,5 +3064,6 @@ root ALL=(ALL) SETENV: ALL (import ../upstart-jobs/fcron.nix) (import ../upstart-jobs/cron/locate.nix) (import ../upstart-jobs/manual.nix) + (import ../upstart-jobs/rogue.nix) ]; } diff --git a/upstart-jobs/rogue.nix b/upstart-jobs/rogue.nix new file mode 100644 index 00000000000..75b1a0a9882 --- /dev/null +++ b/upstart-jobs/rogue.nix @@ -0,0 +1,64 @@ +{pkgs, config}: + +# Show rogue game on tty8 +# Originally used only by installation CD + +let + inherit (pkgs.lib) mkOption; + options = { + services = { + rogue = { + enable = mkOption { + default = false; + description = " + Whether to run rogue + "; + }; + ttyNumber = mkOption { + default = "8"; + description = " + TTY number name to show the manual on + "; + }; + }; + }; + }; + +inherit (pkgs.lib) optional; + +inherit (config.services.rogue) enable ttyNumber; + +in + +{ + require = [ + options + ]; + + boot = { + extraTTYs = optional enable ttyNumber; + }; + + services = { + extraJobs = optional enable { + name = "rogue"; + + job = '' + description "rogue game" + + start on udev + stop on shutdown + respawn ${pkgs.rogue}/bin/rogue < /dev/tty${toString ttyNumber} > /dev/tty${toString ttyNumber} 2>&1 + ''; + }; + ttyBackgrounds = { + specificThemes = optional enable { + tty = ttyNumber; + theme = pkgs.themes "theme-gnu"; + }; + }; + mingetty = { + helpLine = if enable then "\nPress to play rogue." else ""; + }; + }; +} From 12f4fbfb4b8540bc669ab54814f048375a3d9fde Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Fri, 9 Jan 2009 00:23:07 +0000 Subject: [PATCH 05/39] Added guestUsers job for automatical adding guests svn path=/nixos/trunk/; revision=13732 --- system/options.nix | 1 + upstart-jobs/guest-users.nix | 76 ++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 upstart-jobs/guest-users.nix diff --git a/system/options.nix b/system/options.nix index e70bb51628c..402fe9c2b22 100644 --- a/system/options.nix +++ b/system/options.nix @@ -3065,5 +3065,6 @@ root ALL=(ALL) SETENV: ALL (import ../upstart-jobs/cron/locate.nix) (import ../upstart-jobs/manual.nix) (import ../upstart-jobs/rogue.nix) + (import ../upstart-jobs/guest-users.nix) ]; } diff --git a/upstart-jobs/guest-users.nix b/upstart-jobs/guest-users.nix new file mode 100644 index 00000000000..98fc8a39568 --- /dev/null +++ b/upstart-jobs/guest-users.nix @@ -0,0 +1,76 @@ +{pkgs, config}: +let + inherit(pkgs.lib) mkOption; + + options = { + services = { + guestUsers = { + enable = mkOption { + default = false; + description = " + Whether to enable automatic addition of users with empty passwords + "; + }; + users = mkOption { + default = ["guest"]; + description = " + List of usernames to add + "; + }; + includeRoot = mkOption { + default = false; + description = " + LEAVE THAT ALONE; whether to reset root password + "; + }; + extraGroups = mkOption { + default = ["audio"]; + description = " + Extra groups to grant + "; + }; + }; + }; + }; + inherit (pkgs.lib) concatStringsSep optional optionalString; + + inherit (config.services.guestUsers) enable users includeRoot extraGroups; + + userEntry = user: + { + name = user; + description = "NixOS guest user"; + home = "/home/${user}"; + createHome = true; + group = "users"; + extraGroups = extraGroups; + shell = "/bin/sh"; + }; + + nameString = (concatStringsSep " " users) + optionalString includeRoot " root"; + +in + +{ + require = options; + services = { + extraJobs = optional enable { + name = "clear-passwords"; + job = '' + description "Clear guest passwords" + start on startup + script + for i in ${nameString}; do + echo | ${pkgs.pwdutils}/bin/passwd --stdin $i + done + end script + ''; + }; + mingetty = { + helpLine = optionalString enable "\nThis users have empty passwords: ${nameString}"; + }; + }; + users = { + extraUsers = map userEntry users; + }; +} From fbe40a260e2eab7a029e598011b72ec64b093957 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 15 Jan 2009 10:35:00 +0000 Subject: [PATCH 06/39] * The Linux kernel >= 2.6.27 provides firmware, so add it to the firmware search path. svn path=/nixos/trunk/; revision=13770 --- upstart-jobs/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index ff5dc633323..af304c52574 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -97,7 +97,8 @@ let ++ pkgs.lib.optional config.networking.enableIntel4965AGNFirmware kernelPackages.iwlwifi4965ucode ++ pkgs.lib.optional config.networking.enableZydasZD1211Firmware pkgs.zd1211fw ++ pkgs.lib.optional config.hardware.enableGo7007 "${kernelPackages.wis_go7007}/firmware" - ++ config.services.udev.addFirmware; + ++ config.services.udev.addFirmware + ++ ["${kernelPackages.kernel}/lib/firmware"]; extraUdevPkgs = pkgs.lib.optional config.services.hal.enable pkgs.hal ++ pkgs.lib.optional config.hardware.enableGo7007 kernelPackages.wis_go7007 From 1603d28819dbc354b12d8259aa47ba2d7a01dab3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 15 Jan 2009 13:49:00 +0000 Subject: [PATCH 07/39] * Include tune2fs in the initrd. This is useful for (say) converting from ext3 to ext4. svn path=/nixos/trunk/; revision=13772 --- boot/boot-stage-1.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index c26c8d1a096..f5b7e90de94 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -67,7 +67,7 @@ rec { cp $lvm2/sbin/lvm.static $out/bin/lvm fi cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin - cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $out/bin + cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $e2fsprogs/sbin/tune2fs $out/bin cp $udev/sbin/udevd $udev/sbin/udevadm $out/bin cp $udev/lib/udev/*_id $out/bin nuke-refs $out/bin/* From e50e022fc6a3eb5717413dc9395284ee29f5c35d Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Fri, 16 Jan 2009 14:07:54 +0000 Subject: [PATCH 08/39] Added Apache Tomcat proxy to new Apache upstart service svn path=/nixos/trunk/; revision=13786 --- .../apache-httpd/tomcat-connector.nix | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 upstart-jobs/apache-httpd/tomcat-connector.nix diff --git a/upstart-jobs/apache-httpd/tomcat-connector.nix b/upstart-jobs/apache-httpd/tomcat-connector.nix new file mode 100644 index 00000000000..d1186da43fb --- /dev/null +++ b/upstart-jobs/apache-httpd/tomcat-connector.nix @@ -0,0 +1,91 @@ +{config, pkgs, serverInfo}: + +let + workersProperties = pkgs.writeText "workers.properties" '' +# Define list of workers that will be used +# for mapping requests +# The configuration directives are valid +# for the mod_jk version 1.2.18 and later +# +worker.list=loadbalancer,status + +# Define Node1 +# modify the host as your host IP or DNS name. +worker.node1.port=8009 +worker.node1.host=localhost +worker.node1.type=ajp13 +worker.node1.lbfactor=1 + +# Load-balancing behaviour +worker.loadbalancer.type=lb +worker.loadbalancer.balance_workers=node1 + +# Status worker for managing load balancer +worker.status.type=status + ''; +in +{ + extraModules = [ + { name = "jk"; path = "${pkgs.tomcat_connectors}/modules/mod_jk.so"; } + ]; + + extraConfig = '' +# Where to find workers.properties +JkWorkersFile ${workersProperties} + +# Where to put jk logs +JkLogFile ${config.logDir}/mod_jk.log + +# Set the jk log level [debug/error/info] +JkLogLevel info + +# Select the log format +JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" + +# JkOptions indicates to send SSK KEY SIZE +# Note: Changed from +ForwardURICompat. +# See http://tomcat.apache.org/security-jk.html +JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories + +# JkRequestLogFormat +JkRequestLogFormat "%w %V %T" + +# Mount your applications +JkMount /__application__/* loadbalancer + +# You can use external file for mount points. +# It will be checked for updates each 60 seconds. +# The format of the file is: /url=worker +# /examples/*=loadbalancer +#JkMountFile uriworkermap.properties + +# Add shared memory. +# This directive is present with 1.2.10 and +# later versions of mod_jk, and is needed for +# for load balancing to work properly +# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to +# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452 +JkShmFile ${config.stateDir}/jk.shm + +# Static files in all Tomcat webapp context directories are served by apache +JkAutoAlias /var/tomcat/webapps + +# All requests go to worker by default +JkMount /* loadbalancer +# Serve some static files using httpd +JkUnMount /*.html loadbalancer +JkUnMount /*.jpg loadbalancer +JkUnMount /*.gif loadbalancer +JkUnMount /*.css loadbalancer +JkUnMount /*.png loadbalancer +JkUnMount /*.js loadbalancer + +# Add jkstatus for managing runtime data + +JkMount status +Order deny,allow +Deny from all +Allow from 127.0.0.1 + + ''; +} From 93c19c4ae9d93faea2446b7bd4225c8481f2ed44 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 17 Jan 2009 13:10:06 +0000 Subject: [PATCH 09/39] * CUPS daemon: modprobe usblp so that CUPS can find USB printers. * CUPS daemon: use Ghostscript to support printing on non-Postscript printers. svn path=/nixos/trunk/; revision=13794 --- upstart-jobs/cupsd.nix | 19 ++++++++++++++++--- upstart-jobs/default.nix | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/upstart-jobs/cupsd.nix b/upstart-jobs/cupsd.nix index 1afd9aae4c2..d67fc384324 100644 --- a/upstart-jobs/cupsd.nix +++ b/upstart-jobs/cupsd.nix @@ -1,4 +1,4 @@ -{config, pkgs}: +{config, pkgs, modprobe}: let @@ -16,16 +16,24 @@ let bindir = pkgs.runCommand "cups-progs" {} '' ensureDir $out/lib/cups ln -s ${cups}/lib/cups/* $out/lib/cups/ - + + # Provide support for printing via SMB. rm $out/lib/cups/backend ensureDir $out/lib/cups/backend ln -s ${cups}/lib/cups/backend/* $out/lib/cups/backend/ ln -s ${pkgs.samba}/bin/smbspool $out/lib/cups/backend/smb + + # Provide Ghostscript rasterisation, necessary for non-Postscript + # printers. + rm $out/lib/cups/filter + ensureDir $out/lib/cups/filter + ln -s ${cups}/lib/cups/filter/* $out/lib/cups/filter/ + ln -s ${pkgs.ghostscript}/lib/cups/filter/* $out/lib/cups/filter/ ''; # */ cupsdConfig = pkgs.writeText "cupsd.conf" '' - LogLevel info + LogLevel debug SystemGroup root @@ -96,6 +104,8 @@ in extraPath = [ cups ]; + + job = '' description "CUPS printing daemon" @@ -107,6 +117,9 @@ in mkdir -m 0755 -p ${logDir} mkdir -m 0700 -p /var/cache/cups mkdir -m 0700 -p /var/spool/cups + + # Make USB printers show up. + ${modprobe}/sbin/modprobe usblp || true end script respawn ${cups}/sbin/cupsd -c ${cupsdConfig} -F diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index af304c52574..bd0581b5870 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -301,7 +301,7 @@ let # CUPS (printing) daemon. ++ optional config.services.printing.enable (import ../upstart-jobs/cupsd.nix { - inherit config pkgs; + inherit config pkgs modprobe; }) # Gateway6 From d532df65dd3cc0efefad31e0d9f31d42547d9dac Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 19 Jan 2009 12:34:14 +0000 Subject: [PATCH 10/39] * Quick hack to make the `info' command work properly by generating a "dir" file on the fly in a wrapper script. svn path=/nixos/trunk/; revision=13805 --- helpers/info-wrapper.nix | 29 +++++++++++++++++++++++++++++ system/system.nix | 1 + 2 files changed, 30 insertions(+) create mode 100644 helpers/info-wrapper.nix diff --git a/helpers/info-wrapper.nix b/helpers/info-wrapper.nix new file mode 100644 index 00000000000..0f482dd4c27 --- /dev/null +++ b/helpers/info-wrapper.nix @@ -0,0 +1,29 @@ +# Quick hack to make the `info' command work properly. `info' needs a +# "dir" file containing all the installed Info files, which we don't +# have (it would be impure to have a package installation update some +# global "dir" file). So this wrapper script around "info" builds a +# temporary "dir" file on the fly. This is a bit slow (on a cold +# cache) but not unacceptably so. + +{bash, texinfo, writeScriptBin}: + +writeScriptBin "info" + '' + #! ${bash}/bin/sh + + dir=$(mktemp --tmpdir -d "info.dir.XXXXXX") + + if test -z "$dir"; then exit 1; fi + + trap 'rm -rf "$dir"' EXIT + + shopt -s nullglob + + for i in $(IFS=:; echo $INFOPATH); do + for j in $i/*.info; do + ${texinfo}/bin/install-info --quiet $j $dir/dir + done + done + + INFOPATH=$dir:$INFOPATH ${texinfo}/bin/info "$@" + '' diff --git a/system/system.nix b/system/system.nix index bbb7d83f543..7d814993844 100644 --- a/system/system.nix +++ b/system/system.nix @@ -226,6 +226,7 @@ rec { pkgs.usbutils pkgs.utillinux pkgs.wirelesstools + (import ../helpers/info-wrapper.nix {inherit (pkgs) bash texinfo writeScriptBin;}) ] ++ pkgs.lib.optional config.security.sudo.enable pkgs.sudo ++ pkgs.lib.optional config.services.atd.enable pkgs.at From 788275e47cfa9db074afdcea452648ce23265adf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 20 Jan 2009 08:44:41 +0000 Subject: [PATCH 11/39] * Remove a stale lock file that may prevent the X server from starting. svn path=/nixos/trunk/; revision=13812 --- upstart-jobs/xserver.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index 58e8e434ddd..9b815ede5b8 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -414,6 +414,8 @@ rec { } rm -f /var/log/slim.log + + rm -f /tmp/.X0-lock end script From 61aa32f1749b48c64c8a0600bee919c7bd53480a Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 25 Jan 2009 15:22:17 +0000 Subject: [PATCH 12/39] Update argument syntax of configuration files. svn path=/nixos/trunk/; revision=13847 --- upstart-jobs/cron.nix | 2 +- upstart-jobs/cron/locate.nix | 2 +- upstart-jobs/dhclient.nix | 3 +-- upstart-jobs/fcron.nix | 2 +- upstart-jobs/guest-users.nix | 2 +- upstart-jobs/manual.nix | 2 +- upstart-jobs/rogue.nix | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/upstart-jobs/cron.nix b/upstart-jobs/cron.nix index 4220de6d647..8216b6baaf2 100644 --- a/upstart-jobs/cron.nix +++ b/upstart-jobs/cron.nix @@ -1,4 +1,4 @@ -{pkgs, config}: +{pkgs, config, ...}: ###### interface let diff --git a/upstart-jobs/cron/locate.nix b/upstart-jobs/cron/locate.nix index 2b26a10e91e..eace9f5129b 100644 --- a/upstart-jobs/cron/locate.nix +++ b/upstart-jobs/cron/locate.nix @@ -1,4 +1,4 @@ -{pkgs, config}: +{pkgs, config, ...}: ###### interface let diff --git a/upstart-jobs/dhclient.nix b/upstart-jobs/dhclient.nix index 061af3d8f84..5b732f42fd1 100644 --- a/upstart-jobs/dhclient.nix +++ b/upstart-jobs/dhclient.nix @@ -1,5 +1,4 @@ -{pkgs, config #, ... -}: +{pkgs, config, ...}: ###### interface let diff --git a/upstart-jobs/fcron.nix b/upstart-jobs/fcron.nix index 97d259c65e1..5dd61e669d3 100644 --- a/upstart-jobs/fcron.nix +++ b/upstart-jobs/fcron.nix @@ -1,4 +1,4 @@ -{pkgs, config}: +{pkgs, config, ...}: ###### interface let diff --git a/upstart-jobs/guest-users.nix b/upstart-jobs/guest-users.nix index 98fc8a39568..bfd83619c0e 100644 --- a/upstart-jobs/guest-users.nix +++ b/upstart-jobs/guest-users.nix @@ -1,4 +1,4 @@ -{pkgs, config}: +{pkgs, config, ...}: let inherit(pkgs.lib) mkOption; diff --git a/upstart-jobs/manual.nix b/upstart-jobs/manual.nix index 5d658ce7681..c515e95d3dd 100644 --- a/upstart-jobs/manual.nix +++ b/upstart-jobs/manual.nix @@ -1,4 +1,4 @@ -{pkgs, config}: +{pkgs, config, ...}: # Show the NixOS manual on tty7 # Originally used only by installation CD diff --git a/upstart-jobs/rogue.nix b/upstart-jobs/rogue.nix index 75b1a0a9882..0306033adc0 100644 --- a/upstart-jobs/rogue.nix +++ b/upstart-jobs/rogue.nix @@ -1,4 +1,4 @@ -{pkgs, config}: +{pkgs, config, ...}: # Show rogue game on tty8 # Originally used only by installation CD From 348afe7dc6feae294f5aa1fb13512bfb29241fd8 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 25 Jan 2009 15:26:46 +0000 Subject: [PATCH 13/39] Replace old argument syntax. svn path=/nixos/trunk/; revision=13848 --- system/options.nix | 2 +- upstart-jobs/pcmcia.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/options.nix b/system/options.nix index 402fe9c2b22..6e4f9c4ee50 100644 --- a/system/options.nix +++ b/system/options.nix @@ -1,4 +1,4 @@ -pkgs: config: +{pkgs, config, ...}: let inherit (pkgs.lib) mkOption; diff --git a/upstart-jobs/pcmcia.nix b/upstart-jobs/pcmcia.nix index 77db881856e..1337a6dcffd 100644 --- a/upstart-jobs/pcmcia.nix +++ b/upstart-jobs/pcmcia.nix @@ -1,4 +1,4 @@ -pkgs: config: +{pkgs, config, ...}: ###### interface let From c3f848e2d6c235a092d2d98e684d8b49b919c8e0 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 25 Jan 2009 20:47:30 +0000 Subject: [PATCH 14/39] Remove name arguments from obsolete options. svn path=/nixos/trunk/; revision=13864 --- system/options.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/system/options.nix b/system/options.nix index 6e4f9c4ee50..0981010aaa7 100644 --- a/system/options.nix +++ b/system/options.nix @@ -4,10 +4,10 @@ let inherit (pkgs.lib) mkOption; inherit (builtins) head tail; - obsolete = what: f: name: + obsolete = what: f: if builtins ? trace then - builtins.trace "${name}: Obsolete ${what}." f name - else f name; + builtins.trace "Obsolete ${what}." f + else f; obsoleteMerge = obsolete "option" pkgs.lib.mergeDefaultOption; @@ -15,18 +15,18 @@ let # temporary modifications. # backward here means that expression could either be a value or a # function which expects to have a pkgs argument. - optionalPkgs = name: x: + optionalPkgs = x: if builtins.isFunction x - then obsolete "notation" (name: x pkgs) name + then obsolete "notation" (x pkgs) else x; - backwardPkgsFunListMerge = name: list: - pkgs.lib.concatMap (optionalPkgs name) list; + backwardPkgsFunListMerge = list: + pkgs.lib.concatMap optionalPkgs list; - backwardPkgsFunMerge = name: list: + backwardPkgsFunMerge = list: if list != [] && tail list == [] - then optionalPkgs name (head list) - else abort "${name}: Defined at least twice."; + then optionalPkgs (head list) + else abort "Defined at least twice."; in From 7ac9e76eb6fe68089f520a70a218497e06414c22 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Tue, 27 Jan 2009 13:02:56 +0000 Subject: [PATCH 15/39] Some fixes to the Apache Tomcat connector svn path=/nixos/trunk/; revision=13879 --- upstart-jobs/apache-httpd/tomcat-connector.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/upstart-jobs/apache-httpd/tomcat-connector.nix b/upstart-jobs/apache-httpd/tomcat-connector.nix index d1186da43fb..f7662c9513f 100644 --- a/upstart-jobs/apache-httpd/tomcat-connector.nix +++ b/upstart-jobs/apache-httpd/tomcat-connector.nix @@ -73,12 +73,12 @@ JkAutoAlias /var/tomcat/webapps # All requests go to worker by default JkMount /* loadbalancer # Serve some static files using httpd -JkUnMount /*.html loadbalancer -JkUnMount /*.jpg loadbalancer -JkUnMount /*.gif loadbalancer -JkUnMount /*.css loadbalancer -JkUnMount /*.png loadbalancer -JkUnMount /*.js loadbalancer +#JkUnMount /*.html loadbalancer +#JkUnMount /*.jpg loadbalancer +#JkUnMount /*.gif loadbalancer +#JkUnMount /*.css loadbalancer +#JkUnMount /*.png loadbalancer +#JkUnMount /*.js loadbalancer # Add jkstatus for managing runtime data From 016e4dc5c332f0095ca37a26693bf4554a1f8485 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Wed, 28 Jan 2009 12:19:42 +0000 Subject: [PATCH 16/39] Increased the sleep hack on the Tomcat service svn path=/nixos/trunk/; revision=13890 --- upstart-jobs/tomcat.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstart-jobs/tomcat.nix b/upstart-jobs/tomcat.nix index ad4736386d9..233da6abe38 100644 --- a/upstart-jobs/tomcat.nix +++ b/upstart-jobs/tomcat.nix @@ -99,7 +99,7 @@ in end script - respawn ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c 'CATALINA_BASE=${cfg.baseDir} JAVA_HOME=${pkgs.jdk} JAVA_OPTS="${cfg.javaOpts}" CATALINA_OPTS="${cfg.catalinaOpts}" ${pkgs.tomcat6}/bin/startup.sh; sleep 1d' + respawn ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c 'CATALINA_BASE=${cfg.baseDir} JAVA_HOME=${pkgs.jdk} JAVA_OPTS="${cfg.javaOpts}" CATALINA_OPTS="${cfg.catalinaOpts}" ${pkgs.tomcat6}/bin/startup.sh; sleep 1000d' stop script echo "Stopping tomcat..." From a3f778c23d3336f13cdab69a0fbab99f53b10c0c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 28 Jan 2009 14:48:37 +0000 Subject: [PATCH 17/39] * CUPS: use /etc/cups rather than ${cups}/etc/cups as the ServerRoot, because CUPS modifies files in the ServerRoot directory. Most importantly, it stores printer configuration there. Previously the CUPS server modified the files under ${cups}/etc/cups, which is impure and caused all configured printers to disappear any time CUPS was upgraded. svn path=/nixos/trunk/; revision=13892 --- upstart-jobs/cupsd.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/upstart-jobs/cupsd.nix b/upstart-jobs/cupsd.nix index d67fc384324..ced164a1308 100644 --- a/upstart-jobs/cupsd.nix +++ b/upstart-jobs/cupsd.nix @@ -40,7 +40,10 @@ let Listen localhost:631 Listen /var/run/cups/cups.sock - ServerRoot ${cups}/etc/cups + # Note: we can't use ${cups}/etc/cups as the ServerRoot, since + # CUPS will write in the ServerRoot when e.g. adding new printers + # through the web interface. + ServerRoot /etc/cups ServerBin ${bindir}/lib/cups @@ -101,11 +104,17 @@ in { name = "cupsd"; - extraPath = [ - cups - ]; + extraPath = [cups]; - + extraEtc = [ + # CUPS expects the following files in its ServerRoot. + { source = "${cups}/etc/cups/mime.convs"; + target = "cups/mime.convs"; + } + { source = "${cups}/etc/cups/mime.types"; + target = "cups/mime.types"; + } + ]; job = '' description "CUPS printing daemon" From 42a83d33914c694ff17e4c8e272848119ecd64da Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 29 Jan 2009 17:50:28 +0000 Subject: [PATCH 18/39] svn path=/nixos/trunk/; revision=13906 --- boot/boot-stage-1.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index f5b7e90de94..d6702799682 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -15,7 +15,7 @@ rec { pkgsKlibc = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" { system = pkgs.stdenv.system; - bootStdenv = pkgs.useKlibc pkgs.stdenv kernelPackages.klibc; + bootStdenv = pkgs.useKlibc pkgs.stdenv pkgs.klibc; }; pkgsStatic = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" { @@ -131,7 +131,7 @@ rec { # command provided by klibc (which isn't capable of # auto-detecting FS types). extraUtils - kernelPackages.klibcShrunk + pkgs.klibcShrunk ]; }; From 2b8216bdda25f79909293917b89ed1619f12c58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 29 Jan 2009 18:28:09 +0000 Subject: [PATCH 19/39] Add Upstart job for PulseAudio as a system-wide daemon. svn path=/nixos/trunk/; revision=13907 --- system/ids.nix | 2 + system/options.nix | 1 + upstart-jobs/pulseaudio.nix | 94 +++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 upstart-jobs/pulseaudio.nix diff --git a/system/ids.nix b/system/ids.nix index 3838f7138f2..a950ec84db1 100644 --- a/system/ids.nix +++ b/system/ids.nix @@ -19,6 +19,7 @@ dovecot = 15; tomcat = 16; gnunetd = 17; + pulseaudio = 22; # must match `pulseaudio' GID nixbld = 30000; # start of range of uids nobody = 65534; @@ -45,6 +46,7 @@ uucp = 19; lp = 20; tomcat = 21; + pulseaudio = 22; # must match `pulseaudio' UID users = 100; nixbld = 30000; diff --git a/system/options.nix b/system/options.nix index 0981010aaa7..da435cfec86 100644 --- a/system/options.nix +++ b/system/options.nix @@ -3066,5 +3066,6 @@ root ALL=(ALL) SETENV: ALL (import ../upstart-jobs/manual.nix) (import ../upstart-jobs/rogue.nix) (import ../upstart-jobs/guest-users.nix) + (import ../upstart-jobs/pulseaudio.nix) ]; } diff --git a/upstart-jobs/pulseaudio.nix b/upstart-jobs/pulseaudio.nix new file mode 100644 index 00000000000..b8497ce12e7 --- /dev/null +++ b/upstart-jobs/pulseaudio.nix @@ -0,0 +1,94 @@ +{pkgs, config, ...}: + +###### interface +let + inherit (pkgs.lib) mkOption; + + uid = (import ../system/ids.nix).uids.pulseaudio; + gid = (import ../system/ids.nix).gids.pulseaudio; + + options = { + services = { + pulseaudio = { + enable = mkOption { + default = false; + description = '' + Whether to enable the PulseAudio system-wide audio server. + Note that the documentation recommends running PulseAudio + daemons per-user rather than system-wide on desktop machines. + ''; + }; + + logLevel = mkOption { + default = "notice"; + example = "debug"; + description = '' + A string denoting the log level: one of + error, warn, + notice, info, + or debug. + ''; + }; + }; + }; + }; +in + +###### implementation + +# For some reason, PulseAudio wants UID == GID. +assert uid == gid; + +{ + require = [ + options + ]; + + environment = { + + extraPackages = + pkgs.lib.optional + (!config.environment.cleanStart) + pkgs.pulseaudio; + }; + + users = { + extraUsers = [ + { name = "pulse"; + inherit uid; + group = "pulse"; + description = "PulseAudio system-wide daemon"; + home = "/var/run/pulse"; + } + ]; + + extraGroups = [ + { name = "pulse"; + inherit gid; + } + ]; + }; + + services = { + extraJobs = [{ + name = "pulseaudio"; + + job = '' + description "PulseAudio system-wide server" + + start on startup + stop on shutdown + + start script + test -d /var/run/pulse || \ + ( mkdir -p --mode 755 /var/run/pulse && \ + chown pulse:pulse /var/run/pulse ) + end script + + respawn ${pkgs.pulseaudio}/bin/pulseaudio \ + --system --daemonize \ + --log-level="${config.services.pulseaudio.logLevel}" + ''; + }]; + }; +} From 6085b298ae53f6d4f2fce46d7ef4d5a772512c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 29 Jan 2009 19:17:55 +0000 Subject: [PATCH 20/39] Mount `/dev/shm' (shared memory support). svn path=/nixos/trunk/; revision=13908 --- boot/boot-stage-2-init.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boot/boot-stage-2-init.sh b/boot/boot-stage-2-init.sh index f5fd818d3c7..3c69265b51d 100644 --- a/boot/boot-stage-2-init.sh +++ b/boot/boot-stage-2-init.sh @@ -69,6 +69,8 @@ mkdir -m 0755 -p /sys mount -t sysfs none /sys mkdir -m 0755 -p /dev mount -t tmpfs -o "mode=0755" none /dev +mkdir -m 0777 /dev/shm +mount -t tmpfs -o "rw,nosuid,nodev" tmpfs /dev/shm mkdir -m 0755 -p /dev/pts mount -t devpts none /dev/pts [ -e /proc/bus/usb ] && mount -t usbfs none /proc/bus/usb # uml doesn't have usb by default From d641e99375d9dfbbbc8fbe9ab3cb265644aa24be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 1 Feb 2009 18:35:56 +0000 Subject: [PATCH 21/39] PulseAudio Upstart job: honor `enable'. svn path=/nixos/trunk/; revision=13926 --- upstart-jobs/pulseaudio.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upstart-jobs/pulseaudio.nix b/upstart-jobs/pulseaudio.nix index b8497ce12e7..173f96db7fc 100644 --- a/upstart-jobs/pulseaudio.nix +++ b/upstart-jobs/pulseaudio.nix @@ -2,7 +2,7 @@ ###### interface let - inherit (pkgs.lib) mkOption; + inherit (pkgs.lib) mkOption mkIf; uid = (import ../system/ids.nix).uids.pulseaudio; gid = (import ../system/ids.nix).gids.pulseaudio; @@ -39,7 +39,7 @@ in # For some reason, PulseAudio wants UID == GID. assert uid == gid; -{ +mkIf config.services.pulseaudio.enable { require = [ options ]; From d98f4827393aa38361154743c7e17ffb654be164 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 1 Feb 2009 19:51:53 +0000 Subject: [PATCH 22/39] * Start mingetty after udev, otherwise /dev/tty* may not exist yet (and you get Upstart messages about the ttyN job being restarted). svn path=/nixos/trunk/; revision=13931 --- upstart-jobs/mingetty.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upstart-jobs/mingetty.nix b/upstart-jobs/mingetty.nix index 1d821e789b7..8f50ea5c9db 100644 --- a/upstart-jobs/mingetty.nix +++ b/upstart-jobs/mingetty.nix @@ -3,7 +3,7 @@ { name = "tty" + toString ttyNumber; job = " - start on startup + start on udev stop on shutdown respawn ${mingetty}/sbin/mingetty --loginprog=${loginProgram} --noclear tty${toString ttyNumber} "; From aff7fba09859bf6c0528c74c99671cf4b0903f0a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 1 Feb 2009 19:53:59 +0000 Subject: [PATCH 23/39] * Don't run fsck on journalling file systems. Instead assume that the file system driver will replay the journal at mount-time in case of an unclean shutdown. For ext3 at least this is *much* faster. svn path=/nixos/trunk/; revision=13932 --- boot/boot-stage-1-init.sh | 115 ++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/boot/boot-stage-1-init.sh b/boot/boot-stage-1-init.sh index c6d7214028c..c9930c30bbc 100644 --- a/boot/boot-stage-1-init.sh +++ b/boot/boot-stage-1-init.sh @@ -140,24 +140,69 @@ if test -n "$debug1devices"; then fail; fi # Return true if the machine is on AC power, or if we can't determine # whether it's on AC power. -onACPower () { +onACPower() { if test -d "/proc/acpi/battery"; then - if ls /proc/acpi/battery/BAT[0-9]* > /dev/null 2>&1; then - if cat /proc/acpi/battery/BAT*/state \ - | grep "^charging state" \ - | grep -q "discharg" ; then - false - else - true - fi - else - true - fi + if ls /proc/acpi/battery/BAT[0-9]* > /dev/null 2>&1; then + if cat /proc/acpi/battery/BAT*/state \ + | grep "^charging state" \ + | grep -q "discharg" ; then + false + else + true + fi + else + true + fi else - true + true fi } + +# Check the specified file system, if appropriate. +checkFS() { + # Only check block devices. + if ! test -b "$device"; then return 0; fi + + # For unclean ext3 file systems, fsck.ext3 should just replay the + # journal and exit, but in practice this takes *much* longer than + # letting the kernel recover the FS. So, don't run fsck on + # journalling file systems. + eval $(fstype "$device") + if test "$FSTYPE" = ext3 -o "$FSTYPE" = ext4 -o "$FSTYPE" = reiserfs -o "$FSTYPE" = xfs -o "$FSTYPE" = jfs; then + return 0; + fi + + # Don't run `fsck' if the machine is on battery power. !!! Is + # this a good idea? + if ! onACPower; then + echo "on battery power, so \`fsck' not run on \`$device'" + return 0 + fi + + FSTAB_FILE="/etc/mtab" fsck -V -v -C -a "$device" + fsckResult=$? + + if test $(($fsckResult | 2)) = $fsckResult; then + echo "fsck finished, rebooting..." + sleep 3 + reboot + fi + + if test $(($fsckResult | 4)) = $fsckResult; then + echo "$device has unrepaired errors, please fix them manually." + fail + fi + + if test $fsckResult -ge 8; then + echo "fsck on $device failed." + fail + fi + + return 0 +} + + # Function for mounting a file system. mountFS() { local device="$1" @@ -165,44 +210,8 @@ mountFS() { local options="$3" local fsType="$4" - # Check the root device, if . - mustCheck= - if test -b "$device"; then - mustCheck=1 - else - case $device in - LABEL=*) - mustCheck=1 - ;; - esac - fi - - if test -n "$mustCheck"; then - if onACPower; then - FSTAB_FILE="/etc/mtab" fsck -V -v -C -a "$device" - fsckResult=$? - - if test $(($fsckResult | 2)) = $fsckResult; then - echo "fsck finished, rebooting..." - sleep 3 - reboot - fi - - if test $(($fsckResult | 4)) = $fsckResult; then - echo "$device has unrepaired errors, please fix them manually." - fail - fi - - if test $fsckResult -ge 8; then - echo "fsck on $device failed." - fail - fi - else - # Don't run `fsck' if the machine is on battery power. - echo "on battery power, so \`fsck' not run on \`$device'" - fi - fi - + checkFS "$device" + # Mount read-writable. mount -t "$fsType" -o "$options" "$device" /mnt-root$mountPoint || fail } @@ -224,8 +233,8 @@ for ((n = 0; n < ${#mountPoints[*]}; n++)); do # !!! Really quick hack to support bind mounts, i.e., where the # "device" should be taken relative to /mnt-root, not /. Assume - # that every device that start with / but doesn't start with /dev - # or LABEL= is a bind mount. + # that every device that starts with / but doesn't start with /dev + # is a bind mount. case $device in /dev/*) ;; From 059ca080b1aa04cd727ce45315d6d412d2e773b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 1 Feb 2009 21:23:31 +0000 Subject: [PATCH 24/39] Making the 'via' video module available in the xserver upstart-job. svn path=/nixos/trunk/; revision=13939 --- upstart-jobs/xserver.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index 9b815ede5b8..e8c31717002 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -22,6 +22,7 @@ let intel = { modules = [xorg.xf86videointel]; }; nv = { modules = [xorg.xf86videonv]; }; ati = { modules = [xorg.xf86videoati]; }; + via = { modules = [xorg.xf86videovia]; }; }; # Get a bunch of user settings. From 9774eb579880eb109e498dfd89c99b548a139633 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Feb 2009 13:23:22 +0000 Subject: [PATCH 25/39] * Symlink fsck.ext[234] to e2fsck. This makes the initrd 600 KB smaller. svn path=/nixos/trunk/; revision=13982 --- boot/boot-stage-1.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index d6702799682..ff9522e8925 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -67,10 +67,13 @@ rec { cp $lvm2/sbin/lvm.static $out/bin/lvm fi cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin - cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $e2fsprogs/sbin/tune2fs $out/bin + cp -pd $e2fsprogs/sbin/fsck $e2fsprogs/sbin/e2fsck $e2fsprogs/sbin/tune2fs $out/bin + ln -s e2fsck $out/bin/fsck.ext2 + ln -s e2fsck $out/bin/fsck.ext3 + ln -s e2fsck $out/bin/fsck.ext4 cp $udev/sbin/udevd $udev/sbin/udevadm $out/bin cp $udev/lib/udev/*_id $out/bin - nuke-refs $out/bin/* + for i in $out/bin/*; do if ! test -L $i; then nuke-refs $i; fi; done ''; # */ From ab80d81e5497266f2a9422cea2bd576a9c16b649 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Feb 2009 15:57:07 +0000 Subject: [PATCH 26/39] * Use normal, dynamically linked binaries for e2fsck, lvm etc. in the initrd instead of a mix of dietlibc, klibc and static-glibc based binaries. This works by copying what we need from Glibc into the initrd and using patchelf to set the ELF interpreter and RPATH correctly. The resulting initrd is about 500 KB smaller, but more importantly, it's much easier to maintain - all those dietlibc/klibc/static-glibc builds frequently cause build problems. svn path=/nixos/trunk/; revision=13984 --- boot/boot-stage-1-init.sh | 15 ++--- boot/boot-stage-1.nix | 123 ++++++++++++++++++++++---------------- 2 files changed, 80 insertions(+), 58 deletions(-) diff --git a/boot/boot-stage-1-init.sh b/boot/boot-stage-1-init.sh index c9930c30bbc..b3b2292beaa 100644 --- a/boot/boot-stage-1-init.sh +++ b/boot/boot-stage-1-init.sh @@ -1,7 +1,9 @@ -#! @staticShell@ +#! @shell@ targetRoot=/mnt/root +export LD_LIBRARY_PATH=@extraUtils@/lib + errorDialog() { timeout=15 @@ -14,13 +16,13 @@ errorDialog() { read -t $timeout reply case $reply in f) - exec @staticShell@;; + exec @shell@;; i) echo echo "Quit interactive shell with exit status of" echo " 0 : to continue" echo " non-zero : to get this dialog again" - @staticShell@ || fail + @shell@ || fail ;; *) echo continuing ignoring error;; @@ -299,7 +301,6 @@ umount /proc exec run-init "$targetRoot" "$stage2Init" echo -echo $1 failed running "$stage2Init" -echo "It's your last chance to fix things manually without rebooting" -echo "finally switching to interactive shell pid 1" -export $stage2Init; exec @staticShell@ +echo "$1: failed running $stage2Init" +echo "Dropping into a root shell..." +export $stage2Init; exec @shell@ diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index ff9522e8925..ed53a3abdb9 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -8,26 +8,6 @@ rec { - pkgsDiet = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" { - system = pkgs.stdenv.system; - bootStdenv = pkgs.useDietLibC pkgs.stdenv; - }; - - pkgsKlibc = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" { - system = pkgs.stdenv.system; - bootStdenv = pkgs.useKlibc pkgs.stdenv pkgs.klibc; - }; - - pkgsStatic = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" { - system = pkgs.stdenv.system; - bootStdenv = pkgs.makeStaticBinaries pkgs.stdenv; - }; - - stdenvLinuxStuff = import "${nixpkgsPath}/pkgs/stdenv/linux" { - system = pkgs.stdenv.system; - allPackages = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix"; - }; - # Determine the set of modules that we need to mount the root FS. modulesClosure = pkgs.makeModulesClosure { @@ -39,41 +19,82 @@ rec { }; - udev = pkgsKlibc.udev; - - - # Some additional utilities needed in stage 1, notably mount. We - # don't want to bring in all of util-linux, so we just copy what we - # need. + # Some additional utilities needed in stage 1, like mount, lvm, fsck + # etc. We don't want to bring in all of those packages, so we just + # copy what we need. Instead of using statically linked binaries, + # we just copy what we need from Glibc and use patchelf to make it + # work. extraUtils = pkgs.runCommand "extra-utils" { buildInputs = [pkgs.nukeReferences]; - inherit (pkgsStatic) utillinux; - inherit udev; - e2fsprogs = pkgsDiet.e2fsprogs; - devicemapper = - if config.boot.initrd.lvm - then assert pkgs.devicemapper.enableStatic; pkgs.devicemapper - else null; - lvm2 = - if config.boot.initrd.lvm - then assert pkgs.lvm2.enableStatic; pkgs.lvm2 - else null; - allowedReferences = []; # prevent accidents like glibc being included in the initrd + devicemapper = if config.boot.initrd.lvm then pkgs.devicemapper else null; + lvm2 = if config.boot.initrd.lvm then pkgs.lvm2 else null; + allowedReferences = ["out"]; # prevent accidents like glibc being included in the initrd } '' ensureDir $out/bin - if test -n "$devicemapper"; then - cp $devicemapper/sbin/dmsetup.static $out/bin/dmsetup - cp $lvm2/sbin/lvm.static $out/bin/lvm - fi - cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin - cp -pd $e2fsprogs/sbin/fsck $e2fsprogs/sbin/e2fsck $e2fsprogs/sbin/tune2fs $out/bin + ensureDir $out/lib + + # Copy what we need from Glibc. + cp -p ${pkgs.glibc}/lib/ld-linux*.so.2 $out/lib + cp -p ${pkgs.glibc}/lib/libc.so.* $out/lib + cp -p ${pkgs.glibc}/lib/libpthread.so.* $out/lib + cp -p ${pkgs.glibc}/lib/librt.so.* $out/lib + cp -p ${pkgs.glibc}/lib/libdl.so.* $out/lib + + # Copy some utillinux stuff. + cp ${pkgs.utillinux}/bin/mount ${pkgs.utillinux}/bin/umount ${pkgs.utillinux}/sbin/pivot_root $out/bin + + # Copy e2fsck and friends. + cp ${pkgs.e2fsprogs}/sbin/e2fsck $out/bin + cp ${pkgs.e2fsprogs}/sbin/tune2fs $out/bin + cp ${pkgs.e2fsprogs}/sbin/fsck $out/bin ln -s e2fsck $out/bin/fsck.ext2 ln -s e2fsck $out/bin/fsck.ext3 ln -s e2fsck $out/bin/fsck.ext4 - cp $udev/sbin/udevd $udev/sbin/udevadm $out/bin - cp $udev/lib/udev/*_id $out/bin - for i in $out/bin/*; do if ! test -L $i; then nuke-refs $i; fi; done + + cp -pd ${pkgs.e2fsprogs}/lib/lib*.so.* $out/lib + + # Copy devicemapper and lvm, if we need it. + if test -n "$devicemapper"; then + cp $devicemapper/sbin/dmsetup $out/bin/dmsetup + cp $devicemapper/lib/libdevmapper.so.*.* $out/lib + cp $lvm2/sbin/lvm $out/bin/lvm + fi + + # Copy udev. + cp ${pkgs.udev}/sbin/udevd ${pkgs.udev}/sbin/udevadm $out/bin + cp ${pkgs.udev}/lib/udev/*_id $out/bin + cp ${pkgs.udev}/lib/libvolume_id.so.* $out/lib + + # Copy bash. + cp ${pkgs.bash}/bin/bash $out/bin + ln -s bash $out/bin/sh + + # Run patchelf to make the programs refer to the copied libraries. + for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs $i; fi; done + + for i in $out/bin/*; do + if ! test -L $i; then + echo "patching $i..." + patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib $i || true + fi + done + + # Make sure that the patchelf'ed binaries still work. + echo "testing patched programs..." + $out/bin/bash --version + export LD_LIBRARY_PATH=$out/lib + $out/bin/mount --version + $out/bin/umount --version + $out/bin/e2fsck -V + $out/bin/tune2fs 2> /dev/null | grep "tune2fs " + $out/bin/fsck -N + $out/bin/udevadm --version + $out/bin/vol_id 2>&1 | grep "no device" + if test -n "$devicemapper"; then + $out/bin/dmsetup --version | grep "version:" + LVM_SYSTEM_DIR=$out $out/bin/lvm 2>&1 | grep "LVM" + fi ''; # */ @@ -89,7 +110,7 @@ rec { name = "udev-rules"; buildCommand = '' ensureDir $out - cp ${udev}/*/udev/rules.d/60-persistent-storage.rules $out/ + cp ${pkgs.udev}/*/udev/rules.d/60-persistent-storage.rules $out/ substituteInPlace $out/60-persistent-storage.rules \ --replace ata_id ${extraUtils}/bin/ata_id \ --replace usb_id ${extraUtils}/bin/usb_id \ @@ -112,11 +133,11 @@ rec { bootStage1 = pkgs.substituteAll { src = ./boot-stage-1-init.sh; + shell = "${extraUtils}/bin/bash"; + isExecutable = true; - staticShell = stdenvLinuxStuff.bootstrapTools.bash; - - inherit modulesClosure udevConf; + inherit modulesClosure udevConf extraUtils; inherit (config.boot) isLiveCD resumeDevice; From b25ee09ceb82702a0797744e255f60b08775a086 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Feb 2009 16:19:59 +0000 Subject: [PATCH 27/39] * Remove /var/lock on startup. * Remove /etc/mtab on startup. This fixes the warning on startup when catting /proc/mount to /etc/mtab. svn path=/nixos/trunk/; revision=13986 --- boot/boot-stage-2-init.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/boot/boot-stage-2-init.sh b/boot/boot-stage-2-init.sh index 3c69265b51d..a5f94bf2ad2 100644 --- a/boot/boot-stage-2-init.sh +++ b/boot/boot-stage-2-init.sh @@ -30,8 +30,9 @@ test -e /etc/fstab || touch /etc/fstab # to shut up mount mkdir -m 0755 -p /proc mount -n -t proc none /proc [ -s /etc/mtab ] && rm /etc/mtab # while installing a symlink is created (see man mount), if it's still there for whateever reason remove it + +rm -f /etc/mtab cat /proc/mounts > /etc/mtab -mkdir -m 0755 -p /etc/nixos # Process the kernel command line. @@ -80,10 +81,12 @@ mkdir -m 0755 -p /nix/var mkdir -m 0700 -p /root mkdir -m 0755 -p /bin # for the /bin/sh symlink mkdir -m 0755 -p /home +mkdir -m 0755 -p /etc/nixos # Miscellaneous boot time cleanup. rm -rf /var/run +rm -rf /var/lock #echo -n "cleaning \`/tmp'..." #rm -rf --one-file-system /tmp/* From c83a1850905aead55b27392ccd3923094fdae116 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 10 Feb 2009 23:25:49 +0000 Subject: [PATCH 28/39] * Run the ACPI daemon. This allows the system to respond to ACPI events, like pressing the power button. The NVIDIA X11 driver also needs it to respond to the internal/external monitor switch button on laptops. The power actions should of course be made configurable. svn path=/nixos/trunk/; revision=14027 --- upstart-jobs/acpid.nix | 42 ++++++++++++++++++++++++++++++++++++++++ upstart-jobs/default.nix | 6 ++++++ 2 files changed, 48 insertions(+) create mode 100644 upstart-jobs/acpid.nix diff --git a/upstart-jobs/acpid.nix b/upstart-jobs/acpid.nix new file mode 100644 index 00000000000..5bd1fa63590 --- /dev/null +++ b/upstart-jobs/acpid.nix @@ -0,0 +1,42 @@ +{pkgs, config, ...}: + +let + + acpiConfDir = pkgs.runCommand "acpi-events" {} + '' + ensureDir $out + ln -s ${acpiConfFile} $out/events.conf + ''; + + acpiConfFile = pkgs.writeText "acpi.conf" + '' + event=button/power.* + action=${powerEventHandler} "%e" + ''; + + # Called when the power button is pressed. + powerEventHandler = pkgs.writeScript "acpi-power.sh" + '' + #! ${pkgs.bash}/bin/sh + # Suspend to RAM. + #echo mem > /sys/power/state + exit 0 + ''; + +in + +{ + name = "acpid"; + + extraPath = [pkgs.acpid]; + + job = '' + description "ACPI daemon" + + start on udev + stop on shutdown + + respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir} + ''; + +} diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index bd0581b5870..bd45dda4991 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -342,6 +342,12 @@ let inherit (pkgs) alsaUtils; }) + # ACPI daemon. + ++ optional true /* !!! need some option */ + (import ../upstart-jobs/acpid.nix { + inherit config pkgs; + }) + # D-Bus system-wide daemon. ++ optional config.services.dbus.enable (import ../upstart-jobs/dbus.nix { From cf7fcb98ecc0ae92e3c3a6e7248bcf011407c2fc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 11 Feb 2009 23:15:07 +0000 Subject: [PATCH 29/39] * Suspend when the laptop lid is closed. svn path=/nixos/trunk/; revision=14038 --- upstart-jobs/acpid.nix | 19 +++++++++++++++++++ upstart-jobs/hal.nix | 2 ++ 2 files changed, 21 insertions(+) diff --git a/upstart-jobs/acpid.nix b/upstart-jobs/acpid.nix index 5bd1fa63590..efd608e1353 100644 --- a/upstart-jobs/acpid.nix +++ b/upstart-jobs/acpid.nix @@ -12,6 +12,9 @@ let '' event=button/power.* action=${powerEventHandler} "%e" + + event=button/lid.* + action=${lidEventHandler} "%e" ''; # Called when the power button is pressed. @@ -23,6 +26,22 @@ let exit 0 ''; + # Called when the laptop lid is opened/closed. + lidEventHandler = pkgs.writeScript "acpi-lid.sh" + '' + #! ${pkgs.bash}/bin/sh + + # Suspend to RAM if the lid is closed. (We also get this event + # when the lid just opened, in which case we obviously don't + # want to suspend again.) + if grep -q closed /proc/acpi/button/lid/LID/state; then + sync + echo mem > /sys/power/state + fi + + exit 0 + ''; + in { diff --git a/upstart-jobs/hal.nix b/upstart-jobs/hal.nix index 90e8c49521b..0fa47bf5eeb 100644 --- a/upstart-jobs/hal.nix +++ b/upstart-jobs/hal.nix @@ -21,6 +21,8 @@ job = '' description "HAL daemon" + # !!! TODO: make sure that HAL starts after acpid, + # otherwise hald-addon-acpi will grab /proc/acpi/event. start on dbus stop on shutdown From 03e7f296b1a4b78a60314318f47c8a82cf1eae5c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 13 Feb 2009 12:11:42 +0000 Subject: [PATCH 30/39] * acpid: switch to the ondemand CPU scaling governer when on battery power. Disabled acpid by default because it's not configurable enough yet. svn path=/nixos/trunk/; revision=14070 --- system/options.nix | 14 ++++++++++++++ upstart-jobs/acpid.nix | 16 ++++++++++++++-- upstart-jobs/default.nix | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/system/options.nix b/system/options.nix index da435cfec86..92d17926add 100644 --- a/system/options.nix +++ b/system/options.nix @@ -3033,7 +3033,20 @@ root ALL=(ALL) SETENV: ALL }; }; + + + powerManagement = { + + enable = mkOption { + default = false; + description = " + Whether to enable power management. + "; + }; + + }; + nesting = { children = mkOption { default = []; @@ -3043,6 +3056,7 @@ root ALL=(ALL) SETENV: ALL }; }; + passthru = mkOption { default = {}; description = " diff --git a/upstart-jobs/acpid.nix b/upstart-jobs/acpid.nix index efd608e1353..3a7df58bbaf 100644 --- a/upstart-jobs/acpid.nix +++ b/upstart-jobs/acpid.nix @@ -15,6 +15,9 @@ let event=button/lid.* action=${lidEventHandler} "%e" + + event=ac_adapter.* + action=${acEventHandler} "%e" ''; # Called when the power button is pressed. @@ -23,7 +26,6 @@ let #! ${pkgs.bash}/bin/sh # Suspend to RAM. #echo mem > /sys/power/state - exit 0 ''; # Called when the laptop lid is opened/closed. @@ -38,8 +40,18 @@ let sync echo mem > /sys/power/state fi + ''; - exit 0 + # Called when the AC power is connected or disconnected. + acEventHandler = pkgs.writeScript "ac-power.sh" + '' + #! ${pkgs.bash}/bin/sh + + if grep -q "state:.*on-line" /proc/acpi/ac_adapter/AC/state; then + echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + elif grep -q "state:.*off-line" /proc/acpi/ac_adapter/AC/state; then + echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + fi ''; in diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index bd45dda4991..839769d028d 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -343,7 +343,7 @@ let }) # ACPI daemon. - ++ optional true /* !!! need some option */ + ++ optional config.powerManagement.enable (import ../upstart-jobs/acpid.nix { inherit config pkgs; }) From 4dacbc3c794fcb999535a31b0d766d46a7f3d518 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 13 Feb 2009 18:55:38 +0000 Subject: [PATCH 31/39] * Generate the acpid configuration properly: each config file can only contain one event. svn path=/nixos/trunk/; revision=14080 --- upstart-jobs/acpid.nix | 86 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/upstart-jobs/acpid.nix b/upstart-jobs/acpid.nix index 3a7df58bbaf..e2eb702bcd4 100644 --- a/upstart-jobs/acpid.nix +++ b/upstart-jobs/acpid.nix @@ -5,54 +5,64 @@ let acpiConfDir = pkgs.runCommand "acpi-events" {} '' ensureDir $out - ln -s ${acpiConfFile} $out/events.conf + ${ + # Generate a .conf file for each event. (You can't have + # multiple events in one config file...) + let f = event: + '' + fn=$out/${event.name}.conf + echo "event=${event.event}" > $fn + echo "action=${pkgs.writeScript "${event.name}.sh" event.action}" >> $fn + ''; + in pkgs.lib.concatMapStrings f events + } ''; - acpiConfFile = pkgs.writeText "acpi.conf" - '' - event=button/power.* - action=${powerEventHandler} "%e" - - event=button/lid.* - action=${lidEventHandler} "%e" - - event=ac_adapter.* - action=${acEventHandler} "%e" - ''; + events = [powerEvent lidEvent acEvent]; # Called when the power button is pressed. - powerEventHandler = pkgs.writeScript "acpi-power.sh" - '' - #! ${pkgs.bash}/bin/sh - # Suspend to RAM. - #echo mem > /sys/power/state - ''; + powerEvent = + { name = "power-button"; + event = "button/power.*"; + action = + '' + #! ${pkgs.bash}/bin/sh + ''; + }; # Called when the laptop lid is opened/closed. - lidEventHandler = pkgs.writeScript "acpi-lid.sh" - '' - #! ${pkgs.bash}/bin/sh + lidEvent = + { name = "lid"; + event = "button/lid.*"; + action = + '' + #! ${pkgs.bash}/bin/sh - # Suspend to RAM if the lid is closed. (We also get this event - # when the lid just opened, in which case we obviously don't - # want to suspend again.) - if grep -q closed /proc/acpi/button/lid/LID/state; then - sync - echo mem > /sys/power/state - fi - ''; + # Suspend to RAM if the lid is closed. (We also get this event + # when the lid just opened, in which case we obviously don't + # want to suspend again.) + if grep -q closed /proc/acpi/button/lid/LID/state; then + sync + echo mem > /sys/power/state + fi + ''; + }; # Called when the AC power is connected or disconnected. - acEventHandler = pkgs.writeScript "ac-power.sh" - '' - #! ${pkgs.bash}/bin/sh + acEvent = + { name = "ac-power"; + event = "ac_adapter.*"; + action = + '' + #! ${pkgs.bash}/bin/sh - if grep -q "state:.*on-line" /proc/acpi/ac_adapter/AC/state; then - echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - elif grep -q "state:.*off-line" /proc/acpi/ac_adapter/AC/state; then - echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - fi - ''; + if grep -q "state:.*on-line" /proc/acpi/ac_adapter/AC/state; then + echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + elif grep -q "state:.*off-line" /proc/acpi/ac_adapter/AC/state; then + echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + fi + ''; + }; in From bcba001e37211050dd81f4bf109a4aaeacc43080 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 13 Feb 2009 19:01:13 +0000 Subject: [PATCH 32/39] added hint about how to get the swap partion kernel node numbers svn path=/nixos/trunk/; revision=14081 --- system/options.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/options.nix b/system/options.nix index 92d17926add..2a6498ed80a 100644 --- a/system/options.nix +++ b/system/options.nix @@ -81,7 +81,7 @@ in example = "0:0"; description = " Device for manual resume attempt during boot. Looks like - major:minor . + major:minor. ls -l /dev/SWAP_PARTION shows them. "; }; From c87f67bd28d3ad8025f931261664e38aa94658fe Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 16 Feb 2009 23:53:18 +0000 Subject: [PATCH 33/39] * Support for KDE 4.2. Set services.xserver.sessionType to "kde4" to enable. It looks great ;-) svn path=/nixos/trunk/; revision=14089 --- upstart-jobs/xserver.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index e8c31717002..a2961137d9d 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -44,6 +44,7 @@ let if wm != "" then wm else if sessionType == "gnome" then "metacity" else if sessionType == "kde" then "none" /* started by startkde */ else + if sessionType == "kde4" then "none" /* started by startkde */ else "twm"; @@ -274,7 +275,7 @@ let ### Show a background image. # (but not if we're starting a full desktop environment that does it for us) - ${if sessionType != "kde" then '' + ${if sessionType != "kde" && sessionType != "kde4" then '' if test -e $HOME/.background-image; then ${pkgs.feh}/bin/feh --bg-scale $HOME/.background-image @@ -292,6 +293,14 @@ let export XDG_DATA_DIRS=${pkgs.kdebase}/share exec ${pkgs.kdebase}/bin/startkde + '' else if sessionType == "kde4" then '' + + # Start KDE. + export KDEDIRS=$HOME/.nix-profile:/nix/var/nix/profiles/default:${pkgs.kde42.kdelibs}:${pkgs.kde42.kdebase}:${pkgs.kde42.kdebase_runtime}:${pkgs.kde42.kdebase_workspace} + export XDG_CONFIG_DIRS=${pkgs.kde42.kdelibs}/etc/xdg:${pkgs.kde42.kdebase_runtime}/etc/xdg:${pkgs.kde42.kdebase_workspace}/etc/xdg + export XDG_DATA_DIRS=${pkgs.kde42.kdelibs}/share:${pkgs.kde42.kdebase}/share:${pkgs.kde42.kdebase_runtime}/share:${pkgs.kde42.kdebase_workspace}/share:${pkgs.shared_mime_info}/share + exec ${pkgs.kde42.kdebase_workspace}/bin/startkde + '' else '' # For all other session types, we currently just start a @@ -382,13 +391,22 @@ rec { pkgs.kdebase xorg.xset # used by startkde, non-essential ] + ++ optional (sessionType == "kde4") [ + xorg.xmessage # so that startkde can show error messages + pkgs.qt4 # needed for qdbus + pkgs.kde42.kdelibs + pkgs.kde42.kdebase + pkgs.kde42.kdebase_runtime + pkgs.kde42.kdebase_workspace + xorg.xset # used by startkde, non-essential + ] ++ optional (videoDriver == "nvidia") [ kernelPackages.nvidiaDrivers ]; extraEtc = - optional (sessionType == "kde") + optional (sessionType == "kde" || sessionType == "kde4") { source = "${pkgs.xkeyboard_config}/etc/X11/xkb"; target = "X11/xkb"; } From 53cd42dba61a9718b72974a7fc13efcdebf90c59 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 19 Feb 2009 15:12:30 +0000 Subject: [PATCH 34/39] commented out theme because url is broken svn path=/nixos/trunk/; revision=14127 --- installer/cd-dvd/rescue-cd.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/installer/cd-dvd/rescue-cd.nix b/installer/cd-dvd/rescue-cd.nix index 66c707c77a7..d069c4351f9 100644 --- a/installer/cd-dvd/rescue-cd.nix +++ b/installer/cd-dvd/rescue-cd.nix @@ -148,12 +148,14 @@ rec { sha256 = "0sdykpziij1f3w4braq8r8nqg4lnsd7i7gi1k5d7c31m2q3b9a7r"; }; } + /* url is broken { tty = 8; theme = pkgs.fetchurl { url = http://www.bootsplash.de/files/themes/Theme-GNU.tar.bz2; md5 = "61969309d23c631e57b0a311102ef034"; }; } + */ ]; }; From 018c99ec1c70b655e5501ae4cf7c4a2856af4162 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 19 Feb 2009 15:12:39 +0000 Subject: [PATCH 35/39] added sshfsFuse and screen to rescue-cd.nix sshsfsFuse so that you can get packages from another machine easily screen so that you can copy paste easily svn path=/nixos/trunk/; revision=14128 --- installer/cd-dvd/rescue-cd.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/installer/cd-dvd/rescue-cd.nix b/installer/cd-dvd/rescue-cd.nix index d069c4351f9..2b82df15fe3 100644 --- a/installer/cd-dvd/rescue-cd.nix +++ b/installer/cd-dvd/rescue-cd.nix @@ -190,6 +190,9 @@ rec { pkgs.gdb # for debugging Nix pkgs.testdisk # useful for repairing boot problems pkgs.mssys # for writing Microsoft boot sectors / MBRs + + pkgs.sshfsFuse + pkgs.screen ]; }; From a2a092db87d4902177a7d8d9db0e5503c1bce8f5 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 19 Feb 2009 15:40:53 +0000 Subject: [PATCH 36/39] added possibility make nixos-install not downlooad the manifest do so by export NIXOS_PULL=0 (same as in nixos-rebuild) svn path=/nixos/trunk/; revision=14129 --- installer/nixos-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/nixos-install.sh b/installer/nixos-install.sh index 1288304cbe0..1784b4357f1 100644 --- a/installer/nixos-install.sh +++ b/installer/nixos-install.sh @@ -131,7 +131,7 @@ export NIX_OTHER_STORES=/mnt/nix:$NIX_OTHER_STORES # Do a nix-pull to speed up building. -if test -n "@nixpkgsURL@"; then +if test -n "@nixpkgsURL@" -a ${NIXOS_PULL:-1} != 0; then chroot $mountPoint @nix@/bin/nix-pull @nixpkgsURL@/MANIFEST || true fi From e9b6d417a6eeebb3d17e9e0150d482d59070a1b8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 20 Feb 2009 11:10:17 +0000 Subject: [PATCH 37/39] * Include the SVN revision in the ISO name. svn path=/nixos/trunk/; revision=14138 --- release.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/release.nix b/release.nix index 4612e94ded9..d291e21b8dd 100644 --- a/release.nix +++ b/release.nix @@ -54,6 +54,7 @@ let platform = system; compressImage = true; nixpkgsPath = nixpkgs.path; + relName = "nixos-${builtins.readFile ./VERSION}${if !officialRelease then "pre${toString nixosSrc.rev}" else ""}"; }).rescueCD; in From 049c60e8c0656e7750b71930a559e78f5345f1cb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 20 Feb 2009 15:11:07 +0000 Subject: [PATCH 38/39] * Quick hack to make sure that acpid starts before hal. svn path=/nixos/trunk/; revision=14139 --- upstart-jobs/default.nix | 1 + upstart-jobs/hal.nix | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 839769d028d..f804240a50b 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -363,6 +363,7 @@ let ++ optional config.services.hal.enable (import ../upstart-jobs/hal.nix { inherit (pkgs) stdenv hal; + inherit config; }) ++ optional config.services.gpm.enable diff --git a/upstart-jobs/hal.nix b/upstart-jobs/hal.nix index 0fa47bf5eeb..8b59c079eb8 100644 --- a/upstart-jobs/hal.nix +++ b/upstart-jobs/hal.nix @@ -1,4 +1,4 @@ -{stdenv, hal}: +{stdenv, hal, config}: { name = "hal"; @@ -23,7 +23,7 @@ # !!! TODO: make sure that HAL starts after acpid, # otherwise hald-addon-acpi will grab /proc/acpi/event. - start on dbus + start on ${if config.powerManagement.enable then "acpid" else "dbus"} stop on shutdown start script From 311ff6c8e706c47d17cb417432060d1db79c7401 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 20 Feb 2009 16:31:42 +0000 Subject: [PATCH 39/39] * Set KDEDIRS, XDG_CONFIG_DIRS and XDG_DATA_DIRS in bashrc. This has the advantage that KDE applications work when logging in via ssh, and that you don't need to logout to have KDE upgrades take effect. On the downside, since the various KDE packages and shared-mime-info all have their own MIME databases, if we put them in one symlink tree (systemPath), we need to rerun update-mime-database on the symlink tree. Also, systemPath is getting very large. svn path=/nixos/trunk/; revision=14148 --- etc/bashrc.sh | 10 +++++++++- system/options.nix | 2 +- system/system.nix | 17 +++++++++++++---- upstart-jobs/xserver.nix | 5 ++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/etc/bashrc.sh b/etc/bashrc.sh index 4ec3b4ab415..baaed726ee1 100644 --- a/etc/bashrc.sh +++ b/etc/bashrc.sh @@ -15,6 +15,9 @@ export LANG=@defaultLocale@ export EDITOR=nano export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info export LOCATE_PATH=/var/cache/locatedb +export KDEDIRS=/var/run/current-system/sw +export XDG_CONFIG_DIRS=/var/run/current-system/sw/etc/xdg +export XDG_DATA_DIRS=/var/run/current-system/sw/share # Set up secure multi-user builds: non-root users build through the @@ -41,7 +44,7 @@ for i in $NIX_PROFILES; do # !!! reverse export PKG_CONFIG_PATH="$i/lib/pkgconfig:$PKG_CONFIG_PATH" # Automake's `aclocal' bails out if it finds non-existent directories - # in its path. + # in its path. !!! We should fix aclocal instead. if [ -d "$i/share/aclocal" ] then export ACLOCAL_PATH="$i/share/aclocal:$ACLOCAL_PATH" @@ -50,6 +53,11 @@ for i in $NIX_PROFILES; do # !!! reverse # GStreamer. export GST_PLUGIN_PATH="$i/lib/gstreamer-0.10:$GST_PLUGIN_PATH" + + # KDE/Gnome stuff. + export KDEDIRS=$i:$KDEDIRS + export XDG_CONFIG_DIRS=$i/etc/xdg:$XDG_CONFIG_DIRS + export XDG_DATA_DIRS=$i/share:$XDG_DATA_DIRS done diff --git a/system/options.nix b/system/options.nix index 2a6498ed80a..a2952b4a325 100644 --- a/system/options.nix +++ b/system/options.nix @@ -2959,7 +2959,7 @@ root ALL=(ALL) SETENV: ALL environment = { pathsToLink = mkOption { - default = ["/bin" "/sbin" "/lib" "/share" "/man" "/info"]; + default = ["/bin" "/sbin" "/lib" "/share" "/man" "/info" "/etc"]; example = ["/"]; description = " Lists directories to be symlinked in `/var/run/current-system/sw'. diff --git a/system/system.nix b/system/system.nix index 7d814993844..913913db9af 100644 --- a/system/system.nix +++ b/system/system.nix @@ -266,6 +266,15 @@ rec { inherit (config.environment) pathsToLink; ignoreCollisions = true; + + postBuild = + if config.services.xserver.sessionType == "kde4" then + # Rebuild the MIME database. Otherwise KDE won't be able to + # find many MIME types. + '' + ${pkgs.shared_mime_info}/bin/update-mime-database $out/share/mime + '' + else ""; }; @@ -301,10 +310,10 @@ rec { inherit (usersGroups) createUsersGroups usersList groupsList; path = [ - pkgs.coreutils pkgs.gnugrep pkgs.findutils - pkgs.glibc # needed for getent - pkgs.pwdutils - ]; + pkgs.coreutils pkgs.gnugrep pkgs.findutils + pkgs.glibc # needed for getent + pkgs.pwdutils + ]; adjustSetuidOwner = pkgs.lib.concatStrings (map (_entry: let entry = { diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index a2961137d9d..c889c6427a9 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -296,9 +296,6 @@ let '' else if sessionType == "kde4" then '' # Start KDE. - export KDEDIRS=$HOME/.nix-profile:/nix/var/nix/profiles/default:${pkgs.kde42.kdelibs}:${pkgs.kde42.kdebase}:${pkgs.kde42.kdebase_runtime}:${pkgs.kde42.kdebase_workspace} - export XDG_CONFIG_DIRS=${pkgs.kde42.kdelibs}/etc/xdg:${pkgs.kde42.kdebase_runtime}/etc/xdg:${pkgs.kde42.kdebase_workspace}/etc/xdg - export XDG_DATA_DIRS=${pkgs.kde42.kdelibs}/share:${pkgs.kde42.kdebase}/share:${pkgs.kde42.kdebase_runtime}/share:${pkgs.kde42.kdebase_workspace}/share:${pkgs.shared_mime_info}/share exec ${pkgs.kde42.kdebase_workspace}/bin/startkde '' else '' @@ -398,6 +395,8 @@ rec { pkgs.kde42.kdebase pkgs.kde42.kdebase_runtime pkgs.kde42.kdebase_workspace + pkgs.kde42.kdegames + pkgs.shared_mime_info xorg.xset # used by startkde, non-essential ] ++ optional (videoDriver == "nvidia") [