summary refs log tree commit diff
path: root/pkgs/development/tools/misc/coreboot-toolchain
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2021-11-20 00:18:45 +0100
committerFelix Singer <felixsinger@posteo.net>2021-11-20 02:18:05 +0100
commit8002a4a1337ef874f8721eda787d2e95d13b05c6 (patch)
tree39fa8bb7e7c060f83b71265974eee91ada4d4228 /pkgs/development/tools/misc/coreboot-toolchain
parent9798a593c6c26b51f810be1d04482a812fb3ed7a (diff)
downloadnixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.tar
nixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.tar.gz
nixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.tar.bz2
nixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.tar.lz
nixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.tar.xz
nixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.tar.zst
nixpkgs-8002a4a1337ef874f8721eda787d2e95d13b05c6.zip
coreboot-toolchain: Allow adding new architectures
Rework package so that new target architectures can be added and reuse
common configurations.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'pkgs/development/tools/misc/coreboot-toolchain')
-rw-r--r--pkgs/development/tools/misc/coreboot-toolchain/default.nix82
1 files changed, 43 insertions, 39 deletions
diff --git a/pkgs/development/tools/misc/coreboot-toolchain/default.nix b/pkgs/development/tools/misc/coreboot-toolchain/default.nix
index 8042fc2522b..33265242b85 100644
--- a/pkgs/development/tools/misc/coreboot-toolchain/default.nix
+++ b/pkgs/development/tools/misc/coreboot-toolchain/default.nix
@@ -12,51 +12,55 @@
 , zlib
 }:
 
-stdenvNoCC.mkDerivation rec {
-  pname = "coreboot-toolchain";
-  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
-    '';
-  };
+let
+  common = arch: stdenvNoCC.mkDerivation rec {
+    pname = "coreboot-toolchain-${arch}";
+    version = "4.15";
 
-  nativeBuildInputs = [ bison curl git perl ];
-  buildInputs = [ flex gnat11 zlib ];
+    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
+      '';
+    };
 
-  enableParallelBuilding = true;
-  dontConfigure = true;
-  dontInstall = true;
+    nativeBuildInputs = [ bison curl git perl ];
+    buildInputs = [ flex gnat11 zlib ];
 
-  postPatch = ''
-    mkdir -p util/crossgcc/tarballs
+    enableParallelBuilding = true;
+    dontConfigure = true;
+    dontInstall = true;
 
-    ${lib.concatMapStringsSep "\n" (
-      file: "ln -s ${file.archive} util/crossgcc/tarballs/${file.name}"
-      ) (callPackage ./stable.nix { })
-    }
+    postPatch = ''
+      mkdir -p util/crossgcc/tarballs
 
-    patchShebangs util/genbuild_h/genbuild_h.sh
-  '';
+      ${lib.concatMapStringsSep "\n" (
+        file: "ln -s ${file.archive} util/crossgcc/tarballs/${file.name}"
+        ) (callPackage ./stable.nix { })
+      }
 
-  buildPhase = ''
-    export CROSSGCC_VERSION=$(cat .crossgcc_version)
-    make crossgcc-i386 CPUS=$NIX_BUILD_CORES DEST=$out
-  '';
+      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";
-    license = with licenses; [ bsd2 bsd3 gpl2 lgpl2Plus gpl3Plus ];
-    maintainers = with maintainers; [ felixsinger ];
-    platforms = platforms.linux;
+    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";
 }