1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-17 04:51:31 +03:00
mobile-nixos/systems/bootimg.nix

62 lines
1.3 KiB
Nix
Raw Normal View History

{
2018-06-27 04:52:22 +03:00
device_config
, initrd
, pkgs
}:
let
2018-06-26 03:07:50 +03:00
inherit (pkgs) buildPackages;
2018-06-13 04:47:00 +03:00
in
let
device_name = device_config.name;
device_info = device_config.info;
with_qcdt = device_info ? bootimg_qcdt && device_info.bootimg_qcdt;
linux = device_info.kernel;
kernel = ''${linux}/${linux.image}'';
# TODO : make configurable
dt = "${linux}/boot/dt.img";
# TODO : Allow appending / prepending
cmdline = device_info.kernel_cmdline;
in
2018-06-26 03:07:50 +03:00
pkgs.stdenv.mkDerivation {
name = "nixos-mobile_${device_name}_boot.img";
src = builtins.filterSource (path: type: false) ./.;
unpackPhase = "true";
2018-06-26 03:07:50 +03:00
nativeBuildInputs = [
buildPackages.mkbootimg
buildPackages.dtbTool
];
buildInputs = [
linux
];
installPhase = ''
echo Using kernel: ${kernel}
(
PS4=" $ "
set -x
mkbootimg \
--kernel ${kernel} \
${
if with_qcdt then
"--dt ${dt}"
else
""
} \
--ramdisk ${initrd} \
--cmdline "${cmdline}" \
--base ${device_info.flash_offset_base } \
--kernel_offset ${device_info.flash_offset_kernel } \
--second_offset ${device_info.flash_offset_second } \
--ramdisk_offset ${device_info.flash_offset_ramdisk} \
--tags_offset ${device_info.flash_offset_tags } \
--pagesize ${device_info.flash_pagesize } \
-o $out
)
'';
}