aboutsummaryrefslogtreecommitdiff
path: root/pkgs/mtk-arm-trusted-firmware/default.nix
blob: 44fbf64f73dfcda3538c83461b006dec8e83e56d (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  lib,
  stdenv,
  fetchFromGitHub,
  buildPackages,
  openssl,
  dtc,
  filesToInstall,
  platform ? null,
  extraMakeFlags ? [],
  extraMeta ? {},
}:
stdenv.mkDerivation {
  pname = "arm-trusted-firmware${lib.optionalString (platform != null) "-${platform}"}";
  version = "2025.02.12";

  src = fetchFromGitHub {
    owner = "mtk-openwrt";
    repo = "arm-trusted-firmware";
    rev = "e090770684e775711a624e68e0b28112227a4c38";
    hash = "sha256-VI5OB2nWdXUjkSuUXl/0yQN+/aJp9Jkt+hy7DlL+PMg=";
  };

  depsBuildBuild = [buildPackages.stdenv.cc];
  nativeBuildInputs = [dtc];
  buildInputs = [openssl];

  makeFlags =
    [
      "HOSTCC=$(CC_FOR_BUILD)"
      "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
      # Make the new toolchain guessing (from 2.11+) happy
      "CC=${stdenv.cc.targetPrefix}cc"
      "LD=${stdenv.cc.targetPrefix}cc"
      "AS=${stdenv.cc.targetPrefix}cc"
      "OC=${stdenv.cc.targetPrefix}objcopy"
      "OD=${stdenv.cc.targetPrefix}objdump"
      # Passing OpenSSL path according to docs/design/trusted-board-boot-build.rst
      "OPENSSL_DIR=${openssl}"
    ]
    ++ (lib.optional (platform != null) "PLAT=${platform}")
    ++ extraMakeFlags;

  installPhase = ''
    runHook preInstall

    mkdir -p $out
    cp ${lib.concatStringsSep " " filesToInstall} $out

    runHook postInstall
  '';

  hardeningDisable = ["all"];
  dontStrip = true;

  meta = with lib;
    {
      homepage = "https://github.com/mtk-openwrt/arm-trusted-firmware";
      description = "MediaTek ARM Trusted Firmware";
      license = [licenses.bsd3];
      maintainers = with maintainers; [cynerd];
    }
    // extraMeta;
}