2018-06-10 06:03:24 +03:00
|
|
|
{
|
2018-06-10 20:18:28 +03:00
|
|
|
device_name
|
2018-06-10 06:03:24 +03:00
|
|
|
}:
|
|
|
|
with (import ./overlay);
|
|
|
|
|
|
|
|
let
|
2018-06-10 20:18:28 +03:00
|
|
|
deviceinfo = (lib.importJSON ./devices/postmarketOS-devices.json).${device_name};
|
2018-06-10 06:03:24 +03:00
|
|
|
linux = pkgs."linux_${device_name}";
|
|
|
|
kernel = "${linux}/Image.gz-dtb";
|
|
|
|
dt = "${linux}/boot/dt.img";
|
|
|
|
|
2018-06-10 20:18:28 +03:00
|
|
|
# TODO : Allow appending / prepending
|
|
|
|
cmdline = deviceinfo.kernel_cmdline;
|
2018-06-10 06:03:24 +03:00
|
|
|
|
2018-06-10 20:18:28 +03:00
|
|
|
# TODO : make configurable?
|
|
|
|
initrd = callPackage ./rootfs.nix { inherit device_name; };
|
2018-06-10 06:03:24 +03:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "nixos-mobile_${device_name}_boot.img";
|
|
|
|
|
|
|
|
src = builtins.filterSource (path: type: false) ./.;
|
|
|
|
unpackPhase = "true";
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
mkbootimg
|
|
|
|
dtbTool
|
|
|
|
linux
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkbootimg \
|
|
|
|
--kernel ${kernel} \
|
|
|
|
--dt ${dt} \
|
2018-06-10 20:18:28 +03:00
|
|
|
--ramdisk ${initrd} \
|
|
|
|
--cmdline "${cmdline}" \
|
|
|
|
--base ${deviceinfo.flash_offset_base } \
|
|
|
|
--kernel_offset ${deviceinfo.flash_offset_kernel } \
|
|
|
|
--second_offset ${deviceinfo.flash_offset_second } \
|
|
|
|
--ramdisk_offset ${deviceinfo.flash_offset_ramdisk} \
|
|
|
|
--tags_offset ${deviceinfo.flash_offset_tags } \
|
|
|
|
--pagesize ${deviceinfo.flash_pagesize } \
|
2018-06-10 06:03:24 +03:00
|
|
|
-o $out
|
|
|
|
'';
|
|
|
|
}
|