From 6bc3e866628bd5253f7ea0004b0cd7924d4d91a6 Mon Sep 17 00:00:00 2001 From: r-burns <52847440+r-burns@users.noreply.github.com> Date: Mon, 9 Nov 2020 20:12:31 -0800 Subject: [PATCH] bandwidth: fix build on darwin, fix license, adopt (#101522) Cleaned up rules a bit for platform-independent building. License was incorrectly listed as MIT, it is actually GPL2+. Taking on maintainership as it appears to be orphaned. --- pkgs/tools/misc/bandwidth/default.nix | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pkgs/tools/misc/bandwidth/default.nix b/pkgs/tools/misc/bandwidth/default.nix index 8cd926c5c27..024454a3472 100644 --- a/pkgs/tools/misc/bandwidth/default.nix +++ b/pkgs/tools/misc/bandwidth/default.nix @@ -1,13 +1,8 @@ { stdenv, fetchurl, nasm }: let - arch = - if stdenv.hostPlatform.system == "x86_64-linux" then "bandwidth64" - else if stdenv.hostPlatform.system == "i686-linux" then "bandwidth32" - else if stdenv.hostPlatform.system == "x86_64-darwin" then "bandwidth-mac64" - else if stdenv.hostPlatform.system == "i686-darwin" then "bandwidth-mac32" - else if stdenv.hostPlatform.system == "i686-cygwin" then "bandwidth-win32" - else throw "Unknown architecture"; + inherit (stdenv.hostPlatform.parsed.cpu) bits; + arch = "bandwidth${toString bits}"; in stdenv.mkDerivation rec { pname = "bandwidth"; @@ -18,21 +13,25 @@ stdenv.mkDerivation rec { sha256 = "0x798xj3vhiwq2hal0vmf92sq4h7yalp3i6ylqwhnnpv99m2zws4"; }; - buildInputs = [ nasm ]; + postPatch = '' + sed -i 's,^CC=gcc .*,,' OOC/Makefile Makefile* + sed -i 's,ar ,$(AR) ,g' OOC/Makefile + ''; - buildFlags = [ arch ] - ++ stdenv.lib.optionals stdenv.cc.isClang [ "CC=clang" "LD=clang" ]; + nativeBuildInputs = [ nasm ]; + + buildFlags = [ arch ]; installPhase = '' mkdir -p $out/bin - cp ${arch} $out/bin - ln -s ${arch} $out/bin/bandwidth + cp ${arch} $out/bin/bandwidth ''; meta = with stdenv.lib; { homepage = "https://zsmith.co/bandwidth.html"; description = "Artificial benchmark for identifying weaknesses in the memory subsystem"; - license = licenses.mit; - platforms = platforms.unix; + license = licenses.gpl2Plus; + platforms = platforms.x86; + maintainers = with maintainers; [ r-burns ]; }; }