From 5f1dbaa58bca5575825dfb6e7b9889c0ca86886b Mon Sep 17 00:00:00 2001 From: Pavel Shirshov Date: Sat, 26 Oct 2024 13:22:22 +0100 Subject: [PATCH] flake.nix/shell.nix merged --- build.sbt | 50 ++++++++++++++++++-------------------------------- flake.nix | 4 ++++ 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/build.sbt b/build.sbt index 659626d..7bd6a1b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,38 +2,24 @@ import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations.* ThisBuild / scalaVersion := "2.13.14" -val niOptionsCommon = Seq( - "-ENIX_BINTOOLS", - "-ENIX_CC", - "-ENIX_CFLAGS_COMPILE", - "-ENIX_LDFLAGS", - "-EbuildInputs", - "-EcmakeFlags", - "-EnativeBuildInputs", - "-EpropagatedBuildInputs", - "-EpropagatedNativeBuildInputs", -) - -val niOptions = niOptionsCommon ++ (if (System - .getProperty("os.name") - .toLowerCase - .contains("mac") && System - .getProperty("os.arch") == "aarch64") { - Seq( - "-ENIX_CC_WRAPPER_TARGET_HOST_aarch64_apple_darwin", - "-ENIX_BINTOOLS_WRAPPER_TARGET_HOST_aarch64_apple_darwin", - ) - } else if (System - .getProperty("os.name") - .toLowerCase - .contains("mac")) { - Seq( - "-ENIX_CC_WRAPPER_TARGET_HOST_x86_64_apple_darwin", - "-ENIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_apple_darwin", - ) - } else { - Seq.empty - }) +val niOptions = + Option(System.getenv("NIX_CC_SUFFIX_SALT")) + .map { suffix => + Seq( + "-ENIX_BINTOOLS", + "-ENIX_CC", + "-ENIX_CFLAGS_COMPILE", + "-ENIX_LDFLAGS", + "-EbuildInputs", + "-EcmakeFlags", + "-EnativeBuildInputs", + "-EpropagatedBuildInputs", + "-EpropagatedNativeBuildInputs", + s"-ENIX_CC_WRAPPER_TARGET_HOST_${suffix}", + s"-ENIX_BINTOOLS_WRAPPER_TARGET_HOST_${suffix}", + ) + } + .getOrElse(Seq.empty) lazy val root = (project in file(".")) .settings( diff --git a/flake.nix b/flake.nix index 8a3910b..d619627 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,10 @@ sbt dotnet-sdk_7 ]; + + shellHook = '' + export NIX_CC_SUFFIX_SALT=${stdenv.cc.suffixSalt} + ''; }; } );