2006-11-02 23:48:01 +01:00
|
|
|
# This Nix expression builds the script that performs the first stage
|
|
|
|
# of booting the system: it loads the modules necessary to mount the
|
|
|
|
# root file system, then calls /init in the root file system to start
|
|
|
|
# the second boot stage. The closure of the result of this expression
|
|
|
|
# is supposed to be put into an initial RAM disk (initrd).
|
|
|
|
|
2006-12-10 23:29:44 +01:00
|
|
|
{ substituteAll, staticShell, staticTools
|
2006-12-19 23:12:44 +01:00
|
|
|
, module_init_tools, extraUtils, modules, modulesDir
|
2006-11-12 19:48:47 +01:00
|
|
|
|
|
|
|
, # Whether to find root device automatically using its label.
|
|
|
|
autoDetectRootDevice
|
|
|
|
|
2007-02-06 17:53:36 +01:00
|
|
|
, # If not scanning, the root must be specified explicitly. Actually,
|
|
|
|
# stage 1 can mount multiple file systems. This is necessary if,
|
|
|
|
# for instance, /nix (necessary for stage 2) is on a different file
|
|
|
|
# system than /.
|
|
|
|
#
|
|
|
|
# This is a list of {mountPoint, device|label} attribute sets, i.e.,
|
|
|
|
# the format used by the fileSystems configuration option. There
|
|
|
|
# must at least be a file system for the / mount point in this list.
|
|
|
|
fileSystems ? []
|
2006-11-12 19:48:47 +01:00
|
|
|
|
2008-01-24 17:56:09 +01:00
|
|
|
, # If scanning, we need a disk label.
|
|
|
|
rootLabel
|
|
|
|
|
|
|
|
, # Whether the root device is read-only and should be made writable
|
|
|
|
# through a unionfs.
|
|
|
|
isLiveCD
|
2006-11-13 12:41:27 +01:00
|
|
|
|
|
|
|
, # The path of the stage 2 init to call once we've mounted the root
|
|
|
|
# device.
|
|
|
|
stage2Init ? "/init"
|
2006-11-03 01:36:08 +01:00
|
|
|
}:
|
2006-11-02 23:48:01 +01:00
|
|
|
|
2007-02-06 17:53:36 +01:00
|
|
|
let
|
|
|
|
|
|
|
|
# !!! use XML; copy&pasted from upstart-jobs/filesystems.nix.
|
|
|
|
mountPoints = map (fs: fs.mountPoint) fileSystems;
|
|
|
|
devices = map (fs: if fs ? device then fs.device else "LABEL=" + fs.label) fileSystems;
|
|
|
|
fsTypes = map (fs: if fs ? fsType then fs.fsType else "auto") fileSystems;
|
|
|
|
optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2007-02-06 19:29:20 +01:00
|
|
|
assert !autoDetectRootDevice -> mountPoints != [];
|
2007-02-06 17:53:36 +01:00
|
|
|
|
2006-12-10 23:29:44 +01:00
|
|
|
substituteAll {
|
2006-11-02 23:48:01 +01:00
|
|
|
src = ./boot-stage-1-init.sh;
|
|
|
|
isExecutable = true;
|
2006-12-19 23:12:44 +01:00
|
|
|
inherit staticShell modules modulesDir;
|
2008-01-24 17:56:09 +01:00
|
|
|
inherit autoDetectRootDevice isLiveCD mountPoints devices fsTypes optionss;
|
2006-12-11 17:10:23 +01:00
|
|
|
rootLabel = if autoDetectRootDevice then rootLabel else "";
|
2006-11-02 23:48:01 +01:00
|
|
|
path = [
|
|
|
|
staticTools
|
2006-11-03 01:36:08 +01:00
|
|
|
module_init_tools
|
2006-11-03 14:35:02 +01:00
|
|
|
extraUtils
|
2006-11-02 23:48:01 +01:00
|
|
|
];
|
2006-11-13 12:41:27 +01:00
|
|
|
|
|
|
|
# We only want the path of the stage 2 init, we don't want it as a
|
|
|
|
# dependency (since then it the stage 2 init would end up in the
|
|
|
|
# initrd).
|
|
|
|
stage2Init = toString stage2Init; # !!! doesn't work
|
2006-11-02 23:48:01 +01:00
|
|
|
}
|