1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2025-01-05 10:09:04 +03:00
mobile-nixos/bootimg.nix
2018-06-13 02:06:24 +00:00

47 lines
1.2 KiB
Nix

{
device_name
}:
let
pkgs = (import ./overlay);
in
with pkgs;
let
device_config = import (./devices + ("/" + device_name)) {inherit pkgs lib;};
linux = device_config.kernel;
kernel = "${linux}/Image.gz-dtb";
dt = "${linux}/boot/dt.img";
# TODO : Allow appending / prepending
cmdline = device_config.kernel_cmdline;
# TODO : make configurable?
initrd = callPackage ./rootfs.nix { inherit device_config; };
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} \
--ramdisk ${initrd} \
--cmdline "${cmdline}" \
--base ${device_config.flash_offset_base } \
--kernel_offset ${device_config.flash_offset_kernel } \
--second_offset ${device_config.flash_offset_second } \
--ramdisk_offset ${device_config.flash_offset_ramdisk} \
--tags_offset ${device_config.flash_offset_tags } \
--pagesize ${device_config.flash_pagesize } \
-o $out
'';
}