From d7728dfc671c56a1929665abd1e2fd07d64360e1 Mon Sep 17 00:00:00 2001 From: Evan Petousis Date: Mon, 1 Aug 2022 18:05:58 +1000 Subject: [PATCH 1/3] buildDotnetModule: use platform-agnostic cp format cp on macOS doesn't support the -T flag, which causes the fetch-deps script to fail. Appending `/.` to the source argument replicates the same functionality. --- pkgs/build-support/dotnet/build-dotnet-module/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index 1a5d499929ac..5ccff2f2a198 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -145,7 +145,7 @@ in stdenvNoCC.mkDerivation (args // { store_src="${srcOnly args}" src="$(mktemp -d /tmp/${pname}.XXX)" - cp -rT "$store_src" "$src" + cp -r "$store_src/." "$src" chmod -R +w "$src" trap "rm -rf $src $HOME" EXIT From c51e1a1fbae2bd14e0df183a50df6f1bd64780a3 Mon Sep 17 00:00:00 2001 From: Evan Petousis Date: Mon, 1 Aug 2022 21:21:30 +1000 Subject: [PATCH 2/3] buildDotnetModule: use coreutils in fetch-deps cp on macOS doesn't support the -T flag, which causes the fetch-deps script to fail. Use Nix's coreutils to ensure the script works consistently across all platforms. --- .../dotnet/build-dotnet-module/default.nix | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index 5ccff2f2a198..b24b2f9d191b 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenvNoCC, linkFarmFromDrvs, callPackage, nuget-to-nix, writeScript, makeWrapper, fetchurl, xml2, dotnetCorePackages, dotnetPackages, mkNugetSource, mkNugetDeps, cacert, srcOnly, symlinkJoin }: +{ lib, stdenvNoCC, linkFarmFromDrvs, callPackage, nuget-to-nix, writeScript, makeWrapper, fetchurl, xml2, dotnetCorePackages, dotnetPackages, mkNugetSource, mkNugetDeps, cacert, srcOnly, symlinkJoin, coreutils }: { name ? "${args.pname}-${args.version}" , pname ? name @@ -138,23 +138,23 @@ in stdenvNoCC.mkDerivation (args // { exclusions = dotnet-sdk.passthru.packages { fetchNuGet = attrs: attrs.pname; }; in writeScript "fetch-${pname}-deps" '' set -euo pipefail - cd "$(dirname "''${BASH_SOURCE[0]}")" + cd "$(${coreutils}/bin/dirname "''${BASH_SOURCE[0]}")" - export HOME=$(mktemp -d) + export HOME=$(${coreutils}/bin/mktemp -d) deps_file="/tmp/${pname}-deps.nix" store_src="${srcOnly args}" - src="$(mktemp -d /tmp/${pname}.XXX)" - cp -r "$store_src/." "$src" - chmod -R +w "$src" + src="$(${coreutils}/bin/mktemp -d /tmp/${pname}.XXX)" + ${coreutils}/bin/cp -rT "$store_src" "$src" + ${coreutils}/bin/chmod -R +w "$src" - trap "rm -rf $src $HOME" EXIT + trap "${coreutils}/bin/rm -rf $src $HOME" EXIT pushd "$src" export DOTNET_NOLOGO=1 export DOTNET_CLI_TELEMETRY_OPTOUT=1 - mkdir -p "$HOME/nuget_pkgs" + ${coreutils}/bin/mkdir -p "$HOME/nuget_pkgs" for project in "${lib.concatStringsSep "\" \"" ((lib.toList projectFile) ++ lib.optionals (testProjectFile != "") (lib.toList testProjectFile))}"; do ${dotnet-sdk}/bin/dotnet restore "$project" \ @@ -166,11 +166,11 @@ in stdenvNoCC.mkDerivation (args // { ${lib.optionalString (dotnetFlags != []) (builtins.toString dotnetFlags)} done - echo "${lib.concatStringsSep "\n" exclusions}" > "$HOME/package_exclusions" + ${coreutils}/bin/echo "${lib.concatStringsSep "\n" exclusions}" > "$HOME/package_exclusions" - echo "Writing lockfile..." + ${coreutils}/bin/echo "Writing lockfile..." ${nuget-to-nix}/bin/nuget-to-nix "$HOME/nuget_pkgs" "$HOME/package_exclusions" > "$deps_file" - echo "Succesfully wrote lockfile to: $deps_file" + ${coreutils}/bin/echo "Succesfully wrote lockfile to: $deps_file" ''; } // args.passthru or {}; }) From b4de4dc3bfc5dbbd11a506814636969465c9ade4 Mon Sep 17 00:00:00 2001 From: Evan Petousis Date: Thu, 18 Aug 2022 23:46:37 +1000 Subject: [PATCH 3/3] buildDotnetModule: set fetch-deps utils via PATH --- .../dotnet/build-dotnet-module/default.nix | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index b24b2f9d191b..62820e8d47ee 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -138,26 +138,28 @@ in stdenvNoCC.mkDerivation (args // { exclusions = dotnet-sdk.passthru.packages { fetchNuGet = attrs: attrs.pname; }; in writeScript "fetch-${pname}-deps" '' set -euo pipefail - cd "$(${coreutils}/bin/dirname "''${BASH_SOURCE[0]}")" + export PATH="${lib.makeBinPath [ coreutils dotnet-sdk nuget-to-nix ]}" - export HOME=$(${coreutils}/bin/mktemp -d) + cd "$(dirname "''${BASH_SOURCE[0]}")" + + export HOME=$(mktemp -d) deps_file="/tmp/${pname}-deps.nix" store_src="${srcOnly args}" - src="$(${coreutils}/bin/mktemp -d /tmp/${pname}.XXX)" - ${coreutils}/bin/cp -rT "$store_src" "$src" - ${coreutils}/bin/chmod -R +w "$src" + src="$(mktemp -d /tmp/${pname}.XXX)" + cp -rT "$store_src" "$src" + chmod -R +w "$src" - trap "${coreutils}/bin/rm -rf $src $HOME" EXIT + trap "rm -rf $src $HOME" EXIT pushd "$src" export DOTNET_NOLOGO=1 export DOTNET_CLI_TELEMETRY_OPTOUT=1 - ${coreutils}/bin/mkdir -p "$HOME/nuget_pkgs" + mkdir -p "$HOME/nuget_pkgs" for project in "${lib.concatStringsSep "\" \"" ((lib.toList projectFile) ++ lib.optionals (testProjectFile != "") (lib.toList testProjectFile))}"; do - ${dotnet-sdk}/bin/dotnet restore "$project" \ + dotnet restore "$project" \ ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \ -p:ContinuousIntegrationBuild=true \ -p:Deterministic=true \ @@ -166,11 +168,11 @@ in stdenvNoCC.mkDerivation (args // { ${lib.optionalString (dotnetFlags != []) (builtins.toString dotnetFlags)} done - ${coreutils}/bin/echo "${lib.concatStringsSep "\n" exclusions}" > "$HOME/package_exclusions" + echo "${lib.concatStringsSep "\n" exclusions}" > "$HOME/package_exclusions" - ${coreutils}/bin/echo "Writing lockfile..." - ${nuget-to-nix}/bin/nuget-to-nix "$HOME/nuget_pkgs" "$HOME/package_exclusions" > "$deps_file" - ${coreutils}/bin/echo "Succesfully wrote lockfile to: $deps_file" + echo "Writing lockfile..." + nuget-to-nix "$HOME/nuget_pkgs" "$HOME/package_exclusions" > "$deps_file" + echo "Succesfully wrote lockfile to: $deps_file" ''; } // args.passthru or {}; })