1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-11-28 12:56:54 +03:00
mobile-nixos/systems/initrd.nix

63 lines
1.1 KiB
Nix
Raw Normal View History

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