From 8ad4ee43418a7e85e2cc21beb94a10e9b521d25f Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 10 Aug 2023 07:41:12 +0000 Subject: [PATCH] bonsai: support cross compilation --- overlays/cross.nix | 16 ++++++++-------- pkgs/additional/bonsai/default.nix | 17 ++++++++++++++++- pkgs/default.nix | 4 +++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/overlays/cross.nix b/overlays/cross.nix index 27f69d0e..7cf969cf 100644 --- a/overlays/cross.nix +++ b/overlays/cross.nix @@ -240,14 +240,14 @@ in { # # configure: error: ifconfig or ip not found, install net-tools or iproute2 # nativeBuildInputs = orig.nativeBuildInputs ++ [ final.iproute2 ]; # }); - bonsai = emulateBuildMachine (prev.bonsai.override { - hare = emulateBuildMachine (final.hare.override { - qbe = emulateBuildMachine final.qbe; - harePackages.harec = emulateBuildMachine (final.harePackages.harec.override { - qbe = emulateBuildMachine final.qbe; - }); - }); - }); + # bonsai = emulateBuildMachine (prev.bonsai.override { + # hare = emulateBuildMachine (final.hare.override { + # qbe = emulateBuildMachine final.qbe; + # harePackages.harec = emulateBuildMachine (final.harePackages.harec.override { + # qbe = emulateBuildMachine final.qbe; + # }); + # }); + # }); # bonsai = prev.bonsai.override { # inherit (emulated) stdenv hare; # }; diff --git a/pkgs/additional/bonsai/default.nix b/pkgs/additional/bonsai/default.nix index 4f4fc014..53a8e8a2 100644 --- a/pkgs/additional/bonsai/default.nix +++ b/pkgs/additional/bonsai/default.nix @@ -18,6 +18,21 @@ stdenv.mkDerivation rec { hash = "sha256-jOtFUpl2/Aa7f8JMZf6g63ayFOi+Ci+i7Ac63k63znc="; }; + postPatch = '' + substituteInPlace Makefile \ + --replace 'hare build' 'hare build $(HARE_TARGET_FLAGS)' + ''; + + env.HARE_TARGET_FLAGS = + if stdenv.hostPlatform.isAarch64 then + "-t aarch64" + else if stdenv.hostPlatform.isRiscV64 then + "-t riscv64" + else if stdenv.hostPlatform.isx86_64 then + "-t x86_64" + else + ""; + nativeBuildInputs = [ hare hare-ev @@ -31,7 +46,7 @@ stdenv.mkDerivation rec { # export ARFLAGS="-csr" ''; - installFlags = [ "PREFIX=" "DESTDIR=$(out)" ]; + installFlags = [ "PREFIX=$(out)" ]; passthru.updateScript = gitUpdater { rev-prefix = "v"; diff --git a/pkgs/default.nix b/pkgs/default.nix index e728f8ac..32925ef7 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -21,7 +21,9 @@ let ### ADDITIONAL PACKAGES alsa-ucm-conf-sane = callPackage ./additional/alsa-ucm-conf-sane { }; - bonsai = unpatched.bonsai or (callPackage ./additional/bonsai { }); + # TODO: move target flags to upstream PR and re-enable this bonsai + # bonsai = unpatched.bonsai or (callPackage ./additional/bonsai { }); + bonsai = callPackage ./additional/bonsai { }; bootpart-uefi-x86_64 = callPackage ./additional/bootpart-uefi-x86_64 { }; cargoDocsetHook = callPackage ./additional/cargo-docset/hook.nix { }; chatty-latest = callPackage ./additional/chatty-latest { };