about summary refs log tree commit diff
path: root/pkgs/by-name/rk/rkboot/package.nix
blob: 5e71406967a62d1b6dba443c3375958172068037 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ stdenv
, lib
, rkbin
, box64
}:

stdenv.mkDerivation {
  name = "rkboot";

  src = rkbin.src;

  postPatch = ''
    substituteInPlace RKBOOT/*.ini --replace 'PATH=' 'PATH=rkboot/'
  '';

  buildPhase = ''
    mkdir rkboot
    for i in $(ls ./RKBOOT/*.ini)
    do
      # The proprietary, statically linked binaries to perform boot_merge are
      # x86_64 only. Though we use box64 to emulate if building on aarch64-linux
      ${lib.optionalString stdenv.isAarch64 "${lib.getExe box64}"} ./tools/boot_merger "$i" || true
    done
  '';

  installPhase = ''
    mkdir -p $out
    if [ -z "$(ls -A rkboot)" ]; then
      echo "Error: The 'rkboot' directory is empty."
      exit 1
    else
      mv rkboot $out/bin
    fi
  '';

  meta = with lib; {
    description = "Rockchip proprietary SPL bootloader blobs";
    homepage = "https://github.com/rockchip-linux/rkbin";
    license = licenses.unfreeRedistributable;
    maintainers = with maintainers; [ matthewcroughan ];
    platforms = [ "x86_64-linux" "aarch64-linux" ];
  };
}