summary refs log tree commit diff
path: root/pkgs/development/tools/misc/coreboot-toolchain/default.nix
blob: 33265242b8562c490b1751d01d060b76b4b35a92 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ bison
, callPackage
, curl
, fetchgit
, flex
, getopt
, git
, gnat11
, lib
, perl
, stdenvNoCC
, zlib
}:

let
  common = arch: stdenvNoCC.mkDerivation rec {
    pname = "coreboot-toolchain-${arch}";
    version = "4.15";

    src = fetchgit {
      url = "https://review.coreboot.org/coreboot";
      rev = version;
      sha256 = "1qsb2ca22h5f0iwc254qsfm7qcn8967ir8aybdxa1pakgmnfsyp9";
      fetchSubmodules = false;
      leaveDotGit = true;
      postFetch = ''
        patchShebangs $out/util/crossgcc/buildgcc
        PATH=${lib.makeBinPath [ getopt ]}:$PATH $out/util/crossgcc/buildgcc -W > $out/.crossgcc_version
        rm -rf $out/.git
      '';
    };

    nativeBuildInputs = [ bison curl git perl ];
    buildInputs = [ flex gnat11 zlib ];

    enableParallelBuilding = true;
    dontConfigure = true;
    dontInstall = true;

    postPatch = ''
      mkdir -p util/crossgcc/tarballs

      ${lib.concatMapStringsSep "\n" (
        file: "ln -s ${file.archive} util/crossgcc/tarballs/${file.name}"
        ) (callPackage ./stable.nix { })
      }

      patchShebangs util/genbuild_h/genbuild_h.sh
    '';

    buildPhase = ''
      export CROSSGCC_VERSION=$(cat .crossgcc_version)
      make crossgcc-${arch} CPUS=$NIX_BUILD_CORES DEST=$out
    '';

    meta = with lib; {
      homepage = "https://www.coreboot.org";
      description = "coreboot toolchain for ${arch} targets";
      license = with licenses; [ bsd2 bsd3 gpl2 lgpl2Plus gpl3Plus ];
      maintainers = with maintainers; [ felixsinger ];
      platforms = platforms.linux;
    };
  };
in {
  i386 = common "i386";
}