diff --git a/boot/make-initrd.nix b/boot/make-initrd.nix deleted file mode 100644 index 3e5133be08b..00000000000 --- a/boot/make-initrd.nix +++ /dev/null @@ -1,31 +0,0 @@ -# Create an initial ramdisk containing the closure of the specified -# file system objects. An initial ramdisk is used during the initial -# stages of booting a Linux system. It is loaded by the boot loader -# along with the kernel image. It's supposed to contain everything -# (such as kernel modules) necessary to allow us to mount the root -# file system. Once the root file system is mounted, the `real' boot -# script can be called. -# -# An initrd is really just a gzipped cpio archive. -# -# Symlinks are created for each top-level file system object. E.g., -# `contents = {object = ...; symlink = /init;}' is a typical -# argument. - -{stdenv, perl, cpio, contents}: - -stdenv.mkDerivation { - name = "initrd"; - builder = ./make-initrd.sh; - buildInputs = [perl cpio]; - - # !!! should use XML. - objects = map (x: x.object) contents; - symlinks = map (x: x.symlink) contents; - suffices = map (x: if x ? suffix then x.suffix else "none") contents; - - # For obtaining the closure of `contents'. - exportReferencesGraph = - map (x: [("closure-" + baseNameOf x.symlink) x.object]) contents; - pathsFromGraph = ../helpers/paths-from-graph.pl; -} diff --git a/boot/make-initrd.sh b/boot/make-initrd.sh deleted file mode 100644 index d930e51a03f..00000000000 --- a/boot/make-initrd.sh +++ /dev/null @@ -1,39 +0,0 @@ -source $stdenv/setup - -set -o pipefail - -objects=($objects) -symlinks=($symlinks) -suffices=($suffices) - -mkdir root - -# Needed for splash_helper, which gets run before init. -mkdir root/dev -mkdir root/sys -mkdir root/proc - - -for ((n = 0; n < ${#objects[*]}; n++)); do - object=${objects[$n]} - symlink=${symlinks[$n]} - suffix=${suffices[$n]} - if test "$suffix" = none; then suffix=; fi - - mkdir -p $(dirname root/$symlink) - ln -s $object$suffix root/$symlink -done - - -# Get the paths in the closure of `object'. -storePaths=$(perl $pathsFromGraph closure-*) - - -# Paths in cpio archives *must* be relative, otherwise the kernel -# won't unpack 'em. -(cd root && cp -prd --parents $storePaths .) - - -# Put the closure in a gzipped cpio archive. -ensureDir $out -(cd root && find * -print0 | cpio -ov -H newc --null | gzip -9 > $out/initrd) diff --git a/helpers/make-iso9660-image.nix b/helpers/make-iso9660-image.nix index c4ddfe6bceb..d2ecf5e1a90 100644 --- a/helpers/make-iso9660-image.nix +++ b/helpers/make-iso9660-image.nix @@ -48,5 +48,5 @@ stdenv.mkDerivation { map (x: [("closure-" + baseNameOf x.object) x.object]) storeContents; exportBuildReferencesGraph = map (x: [("closure-build-" + baseNameOf x.object) x.object]) buildStoreContents; - pathsFromGraph = ./paths-from-graph.pl; + pathsFromGraph = ../../nixpkgs/pkgs/build-support/kernel/paths-from-graph.pl; } diff --git a/helpers/modules-closure.nix b/helpers/modules-closure.nix deleted file mode 100644 index 86015a8b182..00000000000 --- a/helpers/modules-closure.nix +++ /dev/null @@ -1,13 +0,0 @@ -# Given a kernel build (with modules in $kernel/lib/modules/VERSION), -# produce a module tree in $out/lib/modules/VERSION that contains only -# the modules identified by `rootModules', plus their dependencies. -# Also generate an appropriate modules.dep. - -{stdenv, kernel, rootModules, module_init_tools}: - -stdenv.mkDerivation { - name = kernel.name + "-shrunk"; - builder = ./modules-closure.sh; - inherit kernel rootModules module_init_tools; - allowedReferences = ["out"]; -} diff --git a/helpers/modules-closure.sh b/helpers/modules-closure.sh deleted file mode 100644 index d16ff46ecb9..00000000000 --- a/helpers/modules-closure.sh +++ /dev/null @@ -1,36 +0,0 @@ -source $stdenv/setup - -set -o pipefail - -PATH=$module_init_tools/sbin:$PATH - -version=$(cd $kernel/lib/modules && ls -d *) - -echo "kernel version is $version" - -export MODULE_DIR=$kernel/lib/modules/ - -# Determine the dependencies of each root module. -closure= -for module in $rootModules; do - echo "root module: $module" - deps=$(modprobe --config /dev/null --set-version "$version" --show-depends "$module" \ - | sed 's/^insmod //') - #for i in $deps; do echo $i; done - closure="$closure $deps" -done - -echo "closure:" -ensureDir $out -for module in $closure; do - target=$(echo $module | sed "s^$kernel^$out^") - if test -e "$target"; then continue; fi - echo $module - mkdir -p $(dirname $target) - cp $module $target - grep "^$module" $kernel/lib/modules/$version/modules.dep \ - | sed "s^$kernel^$out^g" \ - >> $out/lib/modules/$version/modules.dep - echo $target >> $out/insmod-list -done - diff --git a/helpers/paths-from-graph.pl b/helpers/paths-from-graph.pl deleted file mode 100644 index 43ce4e68db4..00000000000 --- a/helpers/paths-from-graph.pl +++ /dev/null @@ -1,68 +0,0 @@ -use strict; -use File::Basename; - -my %storePaths; -my %refs; - -foreach my $graph (@ARGV) { - open GRAPH, "<$graph" or die; - - while () { - chomp; - my $storePath = "$_"; - $storePaths{$storePath} = 1; - - my $deriver = ; chomp $deriver; - my $count = ; chomp $count; - - my @refs = (); - for (my $i = 0; $i < $count; ++$i) { - my $ref = ; chomp $ref; - push @refs, $ref; - } - $refs{$storePath} = \@refs; - - } - - close GRAPH; -} - - -if ($ENV{"printManifest"} eq "1") { - print "version {\n"; - print " ManifestVersion: 3\n"; - print "}\n"; - - foreach my $storePath (sort (keys %storePaths)) { - my $base = basename $storePath; - print "localPath {\n"; - print " StorePath: $storePath\n"; - print " CopyFrom: /tmp/inst-store/$base\n"; - print " References: "; - foreach my $ref (@{$refs{$storePath}}) { - print "$ref "; - } - print "\n"; - print "}\n"; - } -} - -elsif ($ENV{"printRegistration"} eq "1") { - # This is the format used by `nix-store --register-validity - # --hash-given' / `nix-store --load-db'. - foreach my $storePath (sort (keys %storePaths)) { - print "$storePath\n"; - print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix - print "\n"; # don't care about preserving the deriver - print scalar(@{$refs{$storePath}}), "\n"; - foreach my $ref (@{$refs{$storePath}}) { - print "$ref\n"; - } - } -} - -else { - foreach my $storePath (sort (keys %storePaths)) { - print "$storePath\n"; - } -} diff --git a/installer/default.nix b/installer/default.nix index 617210f4487..2196890f842 100644 --- a/installer/default.nix +++ b/installer/default.nix @@ -19,7 +19,7 @@ in inherit nix; nixpkgsURL = config.installer.nixpkgsURL; - pathsFromGraph = ../helpers/paths-from-graph.pl; + pathsFromGraph = ../../nixpkgs/pkgs/build-support/kernel/paths-from-graph.pl; nixClosure = pkgs.runCommand "closure" {exportReferencesGraph = ["refs" nix];} diff --git a/system/system.nix b/system/system.nix index 87792041295..24806222772 100644 --- a/system/system.nix +++ b/system/system.nix @@ -41,8 +41,7 @@ rec { # Determine the set of modules that we need to mount the root FS. - modulesClosure = import ../helpers/modules-closure.nix { - inherit (pkgs) stdenv module_init_tools; + modulesClosure = pkgs.makeModulesClosure { inherit rootModules; kernel = modulesTree; }; @@ -60,9 +59,9 @@ rec { lvm2 = if config.boot.initrd.lvm then pkgs.lvm2Static else null; allowedReferences = []; # prevent accidents like glibc being included in the initrd } - " + '' ensureDir $out/bin - if test -n \"$devicemapper\"; then + if test -n "$devicemapper"; then cp $devicemapper/sbin/dmsetup.static $out/bin/dmsetup cp $lvm2/sbin/lvm.static $out/bin/lvm fi @@ -70,7 +69,7 @@ rec { cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $out/bin cp $udev/sbin/udevd $udev/sbin/udevtrigger $udev/sbin/udevsettle $out/bin nuke-refs $out/bin/* - "; + ''; # The init script of boot stage 1 (loading kernel modules for @@ -95,17 +94,16 @@ rec { # The closure of the init script of boot stage 1 is what we put in # the initial RAM disk. - initialRamdisk = import ../boot/make-initrd.nix { - inherit (pkgs) perl stdenv cpio; + initialRamdisk = pkgs.makeInitrd { contents = [ { object = bootStage1; symlink = "/init"; } ] ++ (if config.boot.initrd.enableSplashScreen then [ - { object = pkgs.runCommand "splashutils" {} " + { object = pkgs.runCommand "splashutils" {} '' ensureDir $out/bin cp ${pkgs.splashutils}/bin/splash_helper $out/bin - "; + ''; suffix = "/bin/splash_helper"; symlink = "/sbin/splash_helper"; }