at 17.09-beta 42 lines 1.5 kB view raw
1# Create an initial ramdisk containing the closure of the specified 2# file system objects. An initial ramdisk is used during the initial 3# stages of booting a Linux system. It is loaded by the boot loader 4# along with the kernel image. It's supposed to contain everything 5# (such as kernel modules) necessary to allow us to mount the root 6# file system. Once the root file system is mounted, the `real' boot 7# script can be called. 8# 9# An initrd is really just a gzipped cpio archive. 10# 11# Symlinks are created for each top-level file system object. E.g., 12# `contents = {object = ...; symlink = /init;}' is a typical 13# argument. 14 15{ stdenv, perl, cpio, contents, ubootChooser, compressor, prepend 16, hostPlatform 17}: 18 19let 20 inputsFun = ubootName : [ perl cpio ] 21 ++ stdenv.lib.optional (ubootName != null) [ (ubootChooser ubootName) ]; 22 makeUInitrdFun = ubootName : (ubootName != null); 23in 24stdenv.mkDerivation { 25 name = "initrd"; 26 builder = ./make-initrd.sh; 27 nativeBuildInputs = inputsFun hostPlatform.platform.uboot; 28 29 makeUInitrd = makeUInitrdFun hostPlatform.platform.uboot; 30 31 # !!! should use XML. 32 objects = map (x: x.object) contents; 33 symlinks = map (x: x.symlink) contents; 34 suffices = map (x: if x ? suffix then x.suffix else "none") contents; 35 36 # For obtaining the closure of `contents'. 37 exportReferencesGraph = 38 map (x: [("closure-" + baseNameOf x.symlink) x.object]) contents; 39 pathsFromGraph = ./paths-from-graph.pl; 40 41 inherit compressor prepend; 42}