2018-06-10 06:03:24 +03:00
|
|
|
{
|
2018-06-17 20:50:32 +03:00
|
|
|
# Configuration from the configuration system.
|
2018-06-17 03:43:19 +03:00
|
|
|
device_config,
|
|
|
|
stage-1 ? {},
|
2018-06-10 06:03:24 +03:00
|
|
|
|
2018-06-17 20:50:32 +03:00
|
|
|
busybox,
|
|
|
|
|
|
|
|
stdenvNoCC,
|
2018-06-10 06:03:24 +03:00
|
|
|
makeInitrd,
|
|
|
|
writeScript,
|
|
|
|
|
2018-06-11 03:00:03 +03:00
|
|
|
lib,
|
2018-06-13 03:07:36 +03:00
|
|
|
mkExtraUtils,
|
2018-06-10 06:03:24 +03:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-06-17 20:50:32 +03:00
|
|
|
inherit (lib) optionals flatten;
|
2018-06-13 04:47:00 +03:00
|
|
|
|
2018-06-17 03:43:19 +03:00
|
|
|
device_name = device_config.name;
|
2018-06-13 04:47:00 +03:00
|
|
|
|
2018-06-13 03:07:36 +03:00
|
|
|
extraUtils = mkExtraUtils {
|
|
|
|
name = device_name;
|
|
|
|
packages = [
|
|
|
|
busybox
|
2018-06-13 04:47:00 +03:00
|
|
|
]
|
2018-06-17 03:43:19 +03:00
|
|
|
++ optionals (stage-1 ? extraUtils) stage-1.extraUtils
|
2018-06-13 04:47:00 +03:00
|
|
|
;
|
2018-06-13 03:07:36 +03:00
|
|
|
};
|
2018-06-10 06:03:24 +03:00
|
|
|
|
|
|
|
shell = "${extraUtils}/bin/ash";
|
|
|
|
|
|
|
|
stage1 = writeScript "stage1" ''
|
|
|
|
#!${shell}
|
2018-06-17 20:50:32 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Basic necessary environment.
|
|
|
|
#
|
2018-06-10 06:03:24 +03:00
|
|
|
export PATH=${extraUtils}/bin/
|
2018-06-11 03:09:06 +03:00
|
|
|
export LD_LIBRARY_PATH=${extraUtils}/lib
|
2018-06-13 04:47:00 +03:00
|
|
|
mkdir -p /bin
|
|
|
|
ln -sv ${shell} /bin/sh
|
|
|
|
|
2018-06-17 20:50:32 +03:00
|
|
|
# ---- stage-1.init START ----
|
2018-06-17 06:43:11 +03:00
|
|
|
${stage-1.init}
|
2018-06-17 20:50:32 +03:00
|
|
|
# ---- stage-1.init END ----
|
2018-06-10 06:03:24 +03:00
|
|
|
'';
|
2018-06-17 06:43:11 +03:00
|
|
|
|
2018-06-10 06:03:24 +03:00
|
|
|
ramdisk = makeInitrd {
|
2018-06-17 20:50:32 +03:00
|
|
|
contents = [ { object = stage1; symlink = "/init"; } ]
|
|
|
|
++ flatten stage-1.contents
|
2018-06-13 02:14:55 +03:00
|
|
|
;
|
2018-06-10 06:03:24 +03:00
|
|
|
};
|
|
|
|
in
|
2018-06-17 20:50:32 +03:00
|
|
|
stdenvNoCC.mkDerivation {
|
2018-06-10 06:03:24 +03:00
|
|
|
name = "initrd-${device_name}";
|
|
|
|
src = builtins.filterSource (path: type: false) ./.;
|
|
|
|
unpackPhase = "true";
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cp ${ramdisk}/initrd $out
|
|
|
|
'';
|
|
|
|
}
|