From b78ce79f895ff32f8781e47c34e016fe0f29b808 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 4 Jun 2012 21:19:12 +0200 Subject: [PATCH 1/6] Add xserver integration of i3 WM. This allows to set i3 as the default window manager in the system configuration. --- .../services/x11/window-managers/default.nix | 1 + modules/services/x11/window-managers/i3.nix | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 modules/services/x11/window-managers/i3.nix diff --git a/modules/services/x11/window-managers/default.nix b/modules/services/x11/window-managers/default.nix index 801517fdd98..8adfca3cca9 100644 --- a/modules/services/x11/window-managers/default.nix +++ b/modules/services/x11/window-managers/default.nix @@ -14,6 +14,7 @@ in ./twm.nix ./wmii.nix ./xmonad.nix + ./i3.nix ]; options = { diff --git a/modules/services/x11/window-managers/i3.nix b/modules/services/x11/window-managers/i3.nix new file mode 100644 index 00000000000..7699d064eef --- /dev/null +++ b/modules/services/x11/window-managers/i3.nix @@ -0,0 +1,30 @@ +{pkgs, config, ...}: + +let + inherit (pkgs.lib) mkOption mkIf; + cfg = config.services.xserver.windowManager.i3; +in + +{ + options = { + services.xserver.windowManager.i3 = { + enable = mkOption { + default = false; + example = true; + description = "Enable the i3 tiling window manager."; + }; + }; + }; + + config = { + services.xserver.windowManager = { + session = mkIf cfg.enable [{ + name = "i3"; + start = " + ${pkgs.i3}/bin/i3 & + waitPID=$! + "; + }]; + }; + }; +} From c9be63b83e6b669181adb34c5527e7fe9a393149 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 14 Jun 2012 21:33:59 +0000 Subject: [PATCH 2/6] =?UTF-8?q?*=20Use=20=E2=80=98nologin=E2=80=99=20as=20?= =?UTF-8?q?the=20default=20shell=20for=20user=20accounts=20that=20are=20no?= =?UTF-8?q?t=20=20=20allowed=20to=20log=20in.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/nixos/trunk/; revision=34514 --- modules/config/users-groups.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/config/users-groups.nix b/modules/config/users-groups.nix index deaa346acff..beb21734652 100644 --- a/modules/config/users-groups.nix +++ b/modules/config/users-groups.nix @@ -48,7 +48,7 @@ let shell = mkOption { type = with types; uniq string; - default = "/noshell"; + default = "/var/run/current-system/sw/sbin/nologin"; description = "The path to the user's shell."; }; From bd5b06bf862cbf3b643fdd726f470187a553d732 Mon Sep 17 00:00:00 2001 From: Mathijs Kwik Date: Sat, 16 Jun 2012 11:13:48 +0000 Subject: [PATCH 3/6] synaptics driver: accelleration factor config option svn path=/nixos/trunk/; revision=34523 --- modules/services/x11/hardware/synaptics.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/services/x11/hardware/synaptics.nix b/modules/services/x11/hardware/synaptics.nix index 752df410934..e0806499106 100644 --- a/modules/services/x11/hardware/synaptics.nix +++ b/modules/services/x11/hardware/synaptics.nix @@ -26,6 +26,11 @@ let cfg = config.services.xserver.synaptics; in ''; }; + accelFactor = mkOption { + default = "0.001"; + description = "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed)."; + }; + minSpeed = mkOption { default = "0.6"; description = "Cursor speed factor for precision finger motion."; @@ -96,7 +101,7 @@ let cfg = config.services.xserver.synaptics; in Option "MaxTapMove" "220" Option "MinSpeed" "${cfg.minSpeed}" Option "MaxSpeed" "${cfg.maxSpeed}" - Option "AccelFactor" "0.0010" + Option "AccelFactor" "${cfg.accelFactor}" Option "TapButton1" "${if cfg.tapButtons then "1" else "0"}" Option "TapButton2" "${if cfg.tapButtons then "2" else "0"}" Option "TapButton3" "${if cfg.tapButtons then "3" else "0"}" From df124ebc891b74dc9036bfe6188b012bf3e796d8 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Thu, 21 Jun 2012 12:47:44 +0200 Subject: [PATCH 4/6] * Make sure time.timeZone can only be defined once. --- modules/config/timezone.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/config/timezone.nix b/modules/config/timezone.nix index 59b4a917ebc..5dcf38c462d 100644 --- a/modules/config/timezone.nix +++ b/modules/config/timezone.nix @@ -7,6 +7,7 @@ with pkgs.lib; time.timeZone = mkOption { default = "CET"; + type = with types; uniq string; example = "America/New_York"; description = "The time zone used when displaying times and dates."; }; From 70089950d242eda44c1df9420b19344cb73bc9c9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Jun 2012 10:28:06 -0400 Subject: [PATCH 5/6] nixos-version: "pre-svn" -> "pre-git" --- modules/misc/version.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/version.nix b/modules/misc/version.nix index 95030fbd03d..319cdcb5f98 100644 --- a/modules/misc/version.nix +++ b/modules/misc/version.nix @@ -9,7 +9,7 @@ with pkgs.lib; system.nixosVersion = mkOption { default = builtins.readFile ../../.version - + (if builtins.pathExists ../../.version-suffix then builtins.readFile ../../.version-suffix else "pre-svn"); + + (if builtins.pathExists ../../.version-suffix then builtins.readFile ../../.version-suffix else "pre-git"); description = "NixOS version."; }; From 9692495df063703ffeafe53d75e8c3ca107bc68e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 21 May 2012 15:26:07 -0400 Subject: [PATCH 6/6] Use BusyBox in the initrd Using BusyBox instead of Bash plus a bunch of other tools gives us a much more feature-full, yet smaller initrd. In particular, BusyBox contains networking commands such as ip and a DHCP client, useful for NFS boots. It's also much more convenient for rescue situations because the shell has builtin readline support and there are many more tools (including vi). --- modules/module-list.nix | 1 - modules/system/boot/stage-1-extratools.nix | 54 ------------------ modules/system/boot/stage-1-init.sh | 29 +++++----- modules/system/boot/stage-1.nix | 64 +++++++--------------- modules/virtualisation/qemu-vm.nix | 4 -- 5 files changed, 34 insertions(+), 118 deletions(-) delete mode 100644 modules/system/boot/stage-1-extratools.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 48171f62150..ee326205973 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -196,7 +196,6 @@ ./system/boot/luksroot.nix ./system/boot/modprobe.nix ./system/boot/stage-1.nix - ./system/boot/stage-1-extratools.nix ./system/boot/stage-2.nix ./system/etc/etc.nix ./system/upstart-events/control-alt-delete.nix diff --git a/modules/system/boot/stage-1-extratools.nix b/modules/system/boot/stage-1-extratools.nix deleted file mode 100644 index 7cd68e6385a..00000000000 --- a/modules/system/boot/stage-1-extratools.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ config, pkgs, ...}: - -with pkgs.lib; - -let - staticBusybox = pkgs.busybox.override { - enableStatic = true; - }; -in -{ - - ###### interface - - options = { - boot.initrd.withExtraTools = mkOption { - default = false; - type = with types; bool; - description = '' - Have busybox utils in initrd, and an interactive bash. - ''; - }; - }; - - config = { - boot.initrd.extraUtilsCommands = mkIf config.boot.initrd.withExtraTools '' - cp -pv ${pkgs.ncurses}/lib/libncurses*.so.* $out/lib - cp -pv ${pkgs.readline}/lib/libreadline.so.* $out/lib - cp -pv ${pkgs.readline}/lib/libhistory.so.* $out/lib - rm $out/bin/bash - cp -pv ${pkgs.bashInteractive}/bin/bash $out/bin - - cp -pv ${staticBusybox}/bin/busybox $out/bin - shopt -s nullglob - for d in bin sbin; do - pushd ${staticBusybox}/$d - # busybox has these, but we'll put them later - GLOBIGNORE=.:..:mke2fs:ip:modprobe - for a in *; do - if [ ! -e $out/bin/$a ]; then - ln -sf busybox $out/bin/$a - fi - done - popd - done - shopt -u nullglob - unset GLOBIGNORE - ''; - - boot.initrd.extraUtilsCommandsTest = mkIf config.boot.initrd.withExtraTools '' - $out/bin/busybox - ''; - }; - -} diff --git a/modules/system/boot/stage-1-init.sh b/modules/system/boot/stage-1-init.sh index 278c68fce99..83300b0d2b8 100644 --- a/modules/system/boot/stage-1-init.sh +++ b/modules/system/boot/stage-1-init.sh @@ -3,7 +3,7 @@ targetRoot=/mnt-root export LD_LIBRARY_PATH=@extraUtils@/lib -export PATH=@extraUtils@/bin +export PATH=@extraUtils@/bin:@extraUtils@/sbin fail() { @@ -50,7 +50,7 @@ EOF esac } -trap 'fail' ERR +trap 'fail' 0 # Print a greeting. @@ -60,8 +60,9 @@ echo # Mount special file systems. -mkdir -p /etc # to shut up mount -echo -n > /etc/fstab # idem +mkdir -p /etc +touch /etc/fstab # to shut up mount +touch /etc/mtab # to shut up mke2fs mkdir -p /proc mount -t proc none /proc mkdir -p /sys @@ -120,6 +121,8 @@ done # Load the required kernel modules. +mkdir -p /lib +ln -s @modulesClosure@/lib/modules /lib/modules echo @extraUtils@/bin/modprobe > /proc/sys/kernel/modprobe for i in @kernelModules@; do echo "loading module $(basename $i)..." @@ -259,16 +262,12 @@ mountFS() { # Try to find and mount the root device. mkdir /mnt-root -mountPoints=(@mountPoints@) -devices=(@devices@) -fsTypes=(@fsTypes@) -optionss=(@optionss@) +exec 3< @fsInfo@ -for ((n = 0; n < ${#mountPoints[*]}; n++)); do - mountPoint=${mountPoints[$n]} - device=${devices[$n]} - fsType=${fsTypes[$n]} - options=${optionss[$n]} +while read -u 3 mountPoint; do + read -u 3 device + read -u 3 fsType + read -u 3 options # !!! Really quick hack to support bind mounts, i.e., where the # "device" should be taken relative to /mnt-root, not /. Assume @@ -300,7 +299,7 @@ for ((n = 0; n < ${#mountPoints[*]}; n++)); do # that we don't properly recognise. if test -z "$pseudoDevice" -a ! -e $device; then echo -n "waiting for device $device to appear..." - for ((try = 0; try < 20; try++)); do + for try in $(seq 1 20); do sleep 1 if test -e $device; then break; fi echo -n "." @@ -326,7 +325,7 @@ udevadm control --exit || true # Kill any remaining processes, just to be sure we're not taking any # with us into stage 2. -kill -9 -- -1 +pkill -9 -v 1 if test -n "$debug1mounts"; then fail; fi diff --git a/modules/system/boot/stage-1.nix b/modules/system/boot/stage-1.nix index 75f83a27db9..02a75ae21c4 100644 --- a/modules/system/boot/stage-1.nix +++ b/modules/system/boot/stage-1.nix @@ -129,7 +129,7 @@ let # work. extraUtils = pkgs.runCommand "extra-utils" { buildInputs = [pkgs.nukeReferences]; - allowedReferences = [ "out" modulesClosure ]; # prevent accidents like glibc being included in the initrd + allowedReferences = [ "out" ]; # prevent accidents like glibc being included in the initrd doublePatchelf = (pkgs.stdenv.system == "armv5tel-linux"); } '' @@ -139,28 +139,21 @@ let # Copy what we need from Glibc. cp -pv ${pkgs.glibc}/lib/ld*.so.? $out/lib cp -pv ${pkgs.glibc}/lib/libc.so.* $out/lib + cp -pv ${pkgs.glibc}/lib/libm.so.* $out/lib cp -pv ${pkgs.glibc}/lib/libpthread.so.* $out/lib cp -pv ${pkgs.glibc}/lib/librt.so.* $out/lib cp -pv ${pkgs.glibc}/lib/libdl.so.* $out/lib cp -pv ${pkgs.gcc.gcc}/lib*/libgcc_s.so.* $out/lib + # Copy BusyBox. + cp -rvd ${pkgs.busybox}/{bin,sbin} $out/ + chmod -R u+w $out + # Copy some utillinux stuff. - cp -v ${pkgs.utillinux}/bin/mount ${pkgs.utillinux}/bin/umount \ - ${pkgs.utillinux}/sbin/fsck ${pkgs.utillinux}/sbin/switch_root \ - ${pkgs.utillinux}/sbin/blkid ${pkgs.utillinux}/bin/setsid $out/bin + cp -v ${pkgs.utillinux}/sbin/blkid $out/bin cp -pdv ${pkgs.utillinux}/lib/libblkid*.so.* $out/lib cp -pdv ${pkgs.utillinux}/lib/libuuid*.so.* $out/lib - - # Copy some coreutils. - cp -v ${pkgs.coreutils}/bin/basename $out/bin - cp -v ${pkgs.coreutils}/bin/mkdir $out/bin - cp -v ${pkgs.coreutils}/bin/mknod $out/bin - cp -v ${pkgs.coreutils}/bin/chmod $out/bin - cp -v ${pkgs.coreutils}/bin/cat $out/bin - cp -v ${pkgs.coreutils}/bin/chroot $out/bin - cp -v ${pkgs.coreutils}/bin/sleep $out/bin - cp -v ${pkgs.coreutils}/bin/ln $out/bin - + # Copy dmsetup and lvm. cp -v ${pkgs.lvm2}/sbin/dmsetup $out/bin/dmsetup cp -v ${pkgs.lvm2}/sbin/lvm $out/bin/lvm @@ -174,12 +167,8 @@ let cp -v ${pkgs.udev}/lib/udev/*_id $out/bin cp -pdv ${pkgs.udev}/lib/libudev.so.* $out/lib - # Copy bash. - cp -v ${pkgs.bash}/bin/bash $out/bin - ln -sv bash $out/bin/sh - # Copy modprobe. - cp -v ${pkgs.module_init_tools}/sbin/modprobe $out/bin/modprobe.real + cp -v ${pkgs.module_init_tools}/sbin/modprobe $out/bin/modprobe # Maybe copy splashutils. ${optionalString enableSplashScreen '' @@ -188,6 +177,10 @@ let ${config.boot.initrd.extraUtilsCommands} + # Strip binaries further than normal. + chmod -R u+w $out + stripDirs "lib bin" "-s" + # 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 @@ -201,27 +194,15 @@ let fi done - # Make the modprobe wrapper that sets $MODULE_DIR. - cat > $out/bin/modprobe <&1 | grep "BusyBox" $out/bin/udevadm --version - $out/bin/blkid -v 2>&1 | tee -a $out/log | grep "blkid from util-linux" $out/bin/dmsetup --version 2>&1 | tee -a $out/log | grep "version:" LVM_SYSTEM_DIR=$out $out/bin/lvm version 2>&1 | tee -a $out/log | grep "LVM" $out/bin/mdadm --version - $out/bin/basename --version - $out/bin/modprobe --version ${config.boot.initrd.extraUtilsCommandsTest} ''; # */ @@ -291,25 +272,20 @@ let bootStage1 = pkgs.substituteAll { src = ./stage-1-init.sh; - shell = "${extraUtils}/bin/bash"; + shell = "${extraUtils}/bin/ash"; isExecutable = true; - inherit udevConf extraUtils; + inherit udevConf extraUtils modulesClosure; inherit (config.boot) resumeDevice devSize runSize; inherit (config.boot.initrd) checkJournalingFS preLVMCommands postDeviceCommands postMountCommands kernelModules; - # !!! copy&pasted from upstart-jobs/filesystems.nix. - mountPoints = - if fileSystems == [] - then abort "You must specify the fileSystems option!" - else map (fs: fs.mountPoint) fileSystems; - devices = map (fs: if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fileSystems; - fsTypes = map (fs: fs.fsType) fileSystems; - optionss = map (fs: fs.options) fileSystems; + fsInfo = + let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ]; + in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems)); }; diff --git a/modules/virtualisation/qemu-vm.nix b/modules/virtualisation/qemu-vm.nix index 098c2944c1b..dd8b457d43c 100644 --- a/modules/virtualisation/qemu-vm.nix +++ b/modules/virtualisation/qemu-vm.nix @@ -252,10 +252,6 @@ in '' # We need mke2fs in the initrd. cp ${pkgs.e2fsprogs}/sbin/mke2fs $out/bin - - # And `ip' (which needs libresolv.so). - cp ${pkgs.iproute}/sbin/ip $out/bin - cp ${pkgs.glibc}/lib/libresolv.so.* $out/lib ''; boot.initrd.postDeviceCommands =