diff --git a/boot/boot-stage-1-init.sh b/boot/boot-stage-1-init.sh index f992637184c..a3f8f8ef7e3 100644 --- a/boot/boot-stage-1-init.sh +++ b/boot/boot-stage-1-init.sh @@ -8,6 +8,16 @@ fail() { } +# Poor man's `basename'. +basename() { + local s="$1" + set -- $(IFS=/; echo $s) + local res + while test $# != 0; do res=$1; shift; done + echo $res +} + + # Print a greeting. echo echo "<<< NixOS Stage 1 >>>" @@ -34,7 +44,7 @@ mount -t sysfs none /sys # Process the kernel command line. -stage2Init= +stage2Init=/init for o in $(cat /proc/cmdline); do case $o in init=*) @@ -59,10 +69,9 @@ done # Load some kernel modules. -export MODULE_DIR=@modulesDir@/lib/modules/ -for i in @modules@; do - echo "trying to load $i..." - modprobe $i +for i in $(cat @modulesClosure@/insmod-list); do + echo "loading module $(basename $i)..." + insmod $i done @@ -84,8 +93,8 @@ echo shutdown > /sys/power/disk # Create device nodes in /dev. export UDEV_CONFIG_FILE=/udev.conf -echo 'udev_rules="/no-rules"' > $UDEV_CONFIG_FILE -echo -n > /no-rules +echo 'udev_rules="/rules"' > $UDEV_CONFIG_FILE +mkdir /rules udevd --daemon udevadm trigger udevadm settle diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index d5ab319894a..edb8dab10da 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -5,7 +5,7 @@ # is supposed to be put into an initial RAM disk (initrd). { substituteAll, staticShell, klibcShrunk -, module_init_tools, extraUtils, modules, modulesDir +, extraUtils, modulesClosure , # Whether to find root device automatically using its label. autoDetectRootDevice @@ -48,7 +48,7 @@ substituteAll { isExecutable = true; - inherit staticShell modules modulesDir; + inherit staticShell modulesClosure; inherit autoDetectRootDevice isLiveCD mountPoints devices fsTypes optionss resumeDevice; @@ -56,7 +56,6 @@ substituteAll { path = [ extraUtils - module_init_tools klibcShrunk ]; } diff --git a/configuration/rescue-cd.nix b/configuration/rescue-cd.nix index 488b2a73c88..ee2c7c2a510 100644 --- a/configuration/rescue-cd.nix +++ b/configuration/rescue-cd.nix @@ -300,6 +300,8 @@ rec { bootImage = "boot/grub/stage2_eltorito"; inherit compressImage; + + volumeID = "NIXOS_INSTALLATION_CD"; }; diff --git a/helpers/make-iso9660-image.nix b/helpers/make-iso9660-image.nix index fbabb7c0f49..0262bc653bb 100644 --- a/helpers/make-iso9660-image.nix +++ b/helpers/make-iso9660-image.nix @@ -1,7 +1,7 @@ { stdenv, perl, cdrkit, nixpkgsPath - # The file name of the resulting ISO image. -, isoName ? "cd.iso" +, # The file name of the resulting ISO image. + isoName ? "cd.iso" , # The files and directories to be placed in the ISO file system. # This is a list of attribute sets {source, target} where `source' @@ -16,18 +16,20 @@ # to `source' that will be added to the CD. storeContents ? [] -, - buildStoreContents ? [] +, buildStoreContents ? [] - # Whether this should be an El-Torito bootable CD. -, bootable ? false +, # Whether this should be an El-Torito bootable CD. + bootable ? false - # The path (in the ISO file system) of the boot image. -, bootImage ? "" +, # The path (in the ISO file system) of the boot image. + bootImage ? "" , # Whether to compress the resulting ISO image with bzip2. compressImage ? false +, # The volume ID. + volumeID ? "" + }: assert bootable -> bootImage != ""; @@ -36,7 +38,8 @@ stdenv.mkDerivation { name = "iso9660-image"; builder = ./make-iso9660-image.sh; buildInputs = [perl cdrkit]; - inherit isoName bootable bootImage compressImage; + + inherit isoName bootable bootImage compressImage volumeID; # !!! should use XML. sources = map (x: x.source) contents; diff --git a/helpers/make-iso9660-image.sh b/helpers/make-iso9660-image.sh index e4997c8112a..03f4208375c 100644 --- a/helpers/make-iso9660-image.sh +++ b/helpers/make-iso9660-image.sh @@ -61,13 +61,13 @@ cat pathlist | sed -e 's/=\(.*\)=\(.*\)=/\\=\1=\2\\=/' | tee pathlist.safer ensureDir $out/iso -genCommand="genisoimage -iso-level 4 -r -J $bootFlags -hide-rr-moved -graft-points -path-list pathlist.safer" +genCommand="genisoimage -iso-level 4 -r -J $bootFlags -hide-rr-moved -graft-points -path-list pathlist.safer ${volumeID:+-V $volumeID}" if test -z "$compressImage"; then $genCommand -o $out/iso/$isoName else $genCommand | bzip2 > $out/iso/$isoName.bz2 fi - + ensureDir $out/nix-support echo $system > $out/nix-support/system diff --git a/system/system.nix b/system/system.nix index 654a6b3181d..b4c7078b4cd 100644 --- a/system/system.nix +++ b/system/system.nix @@ -107,8 +107,7 @@ rec { # mounting the root FS). bootStage1 = import ../boot/boot-stage-1.nix { inherit (pkgs) substituteAll; - inherit (pkgsDiet) module_init_tools; - inherit extraUtils; + inherit extraUtils modulesClosure; inherit (kernelPackages) klibcShrunk; inherit (config.boot) autoDetectRootDevice isLiveCD; fileSystems = @@ -116,8 +115,6 @@ rec { (fs: fs.mountPoint == "/" || (fs ? neededForBoot && fs.neededForBoot)) config.fileSystems; rootLabel = config.boot.rootLabel; - modulesDir = modulesClosure; - modules = rootModules; staticShell = stdenvLinuxStuff.bootstrapTools.bash; resumeDevice = config.boot.resumeDevice; };