about summary refs log tree commit diff
path: root/pkgs/build-support/kernel/make-initrd.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-03-17 10:40:47 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-03-17 10:40:47 +0000
commit3ee0b9bb74b0331e0aae0bb452074ef14967393f (patch)
tree50aecf67fea2027949db6fd2535c5314e54af191 /pkgs/build-support/kernel/make-initrd.nix
parented9107e33c7fe0b746dfe767da13142fe57b7414 (diff)
downloadnixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.tar
nixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.tar.gz
nixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.tar.bz2
nixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.tar.lz
nixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.tar.xz
nixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.tar.zst
nixlib-3ee0b9bb74b0331e0aae0bb452074ef14967393f.zip
* makeInitrd, makeModulesClosure: moved from NixOS.
* Use sh from klibc in the initrd.

svn path=/nixpkgs/trunk/; revision=11154
Diffstat (limited to 'pkgs/build-support/kernel/make-initrd.nix')
-rw-r--r--pkgs/build-support/kernel/make-initrd.nix31
1 files changed, 31 insertions, 0 deletions
diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix
new file mode 100644
index 000000000000..b62ed9840456
--- /dev/null
+++ b/pkgs/build-support/kernel/make-initrd.nix
@@ -0,0 +1,31 @@
+# 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 = ./paths-from-graph.pl;
+}