diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2023-06-28 23:41:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-28 23:41:18 +0200 |
commit | 198bd0a4a7dbf059b4bbb307c0b389ee8d8e5d1c (patch) | |
tree | 1eb1cec186e41f0f2bbed767dff2c5fe906230cb /pkgs/build-support | |
parent | 37bceead9019439c608464e87377626608becb09 (diff) | |
parent | 7af46fb0476330aaa2fe7a1627827007005918ef (diff) |
Merge pull request #239622 from corngood/dotnet-misc
dotnet: misc fixes
Diffstat (limited to 'pkgs/build-support')
4 files changed, 28 insertions, 17 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index a9c49d1e526eb..686d89f8c11cb 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -112,7 +112,11 @@ let if (nugetDeps != null) then if lib.isDerivation nugetDeps then nugetDeps - else mkNugetDeps { inherit name; nugetDeps = import nugetDeps; } + else mkNugetDeps { + inherit name; + nugetDeps = import nugetDeps; + sourceFile = nugetDeps; + } else throw "Defining the `nugetDeps` attribute is required, as to lock the NuGet dependencies. This file can be generated by running the `passthru.fetch-deps` script."; # contains the actual package dependencies @@ -138,6 +142,8 @@ let name = "${name}-nuget-source"; paths = [ dependenciesSource sdkSource ]; }; + + nugetDepsFile = _nugetDeps.sourceFile; in stdenvNoCC.mkDerivation (args // { nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ @@ -166,7 +172,7 @@ stdenvNoCC.mkDerivation (args // { passthru = { inherit nuget-source; - + } // lib.optionalAttrs (nugetDepsFile != null) { fetch-deps = let flags = dotnetFlags ++ dotnetRestoreFlags; @@ -180,8 +186,8 @@ stdenvNoCC.mkDerivation (args // { # Note that toString is necessary here as it results in the path at # eval time (i.e. to the file in your local Nixpkgs checkout) rather # than the Nix store path of the path after it's been imported. - if lib.isPath nugetDeps && !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDeps) - then toString nugetDeps + if lib.isPath nugetDepsFile && !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDepsFile) + then toString nugetDepsFile else ''$(mktemp -t "${pname}-deps-XXXXXX.nix")''; in writeShellScript "fetch-${pname}-deps" '' @@ -208,7 +214,7 @@ stdenvNoCC.mkDerivation (args // { if [[ ''${TMPDIR:-} == /run/user/* ]]; then # /run/user is usually a tmpfs in RAM, which may be too small # to store all downloaded dotnet packages - TMPDIR= + unset TMPDIR fi export tmp=$(mktemp -td "deps-${pname}-XXXXXX") @@ -281,13 +287,15 @@ stdenvNoCC.mkDerivation (args // { echo "Succesfully restored project" echo "Writing lockfile..." - echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$depsFile" excluded_sources="${lib.concatStringsSep " " sdkDeps}" for excluded_source in ''${excluded_sources[@]}; do ls "$excluded_source" >> "$tmp/excluded_list" done - nuget-to-nix "$tmp/nuget_pkgs" "$tmp/excluded_list" >> "$depsFile" + tmpFile="$tmp"/deps.nix + echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$tmpFile" + nuget-to-nix "$tmp/nuget_pkgs" "$tmp/excluded_list" >> "$tmpFile" + mv "$tmpFile" "$depsFile" echo "Succesfully wrote lockfile to $depsFile" ''; } // args.passthru or { }; diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh index 8035b42d08608..3f2a89c414044 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh @@ -40,15 +40,15 @@ dotnetInstallHook() { dotnetPack() { local -r project="${1-}" - env dotnet pack ${project-} \ - -p:ContinuousIntegrationBuild=true \ - -p:Deterministic=true \ - --output "$out/share" \ - --configuration "@buildType@" \ - --no-build \ + env dotnet pack ${project-} \ + -p:ContinuousIntegrationBuild=true \ + -p:Deterministic=true \ + --output "$out/share" \ + --configuration "@buildType@" \ + --no-build \ --runtime "@runtimeId@" \ - ${dotnetPackFlags[@]} \ - ${dotnetFlags[@]} + ${dotnetPackFlags[@]} \ + ${dotnetFlags[@]} } if (( "${#projectFile[@]}" == 0 )); then diff --git a/pkgs/build-support/dotnet/make-nuget-deps/default.nix b/pkgs/build-support/dotnet/make-nuget-deps/default.nix index 723646c5fdcab..8281976df6260 100644 --- a/pkgs/build-support/dotnet/make-nuget-deps/default.nix +++ b/pkgs/build-support/dotnet/make-nuget-deps/default.nix @@ -1,5 +1,5 @@ { linkFarmFromDrvs, fetchurl }: -{ name, nugetDeps }: +{ name, nugetDeps, sourceFile ? null }: linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps { fetchNuGet = { pname, version, sha256 , url ? "https://www.nuget.org/api/v2/package/${pname}/${version}" }: @@ -7,4 +7,6 @@ linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps { name = "${pname}.${version}.nupkg"; inherit url sha256; }; -}) +}) // { + inherit sourceFile; +} diff --git a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh index ce2a7070ea31e..86bc4482088b1 100755 --- a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh +++ b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh @@ -1,6 +1,7 @@ #!@runtimeShell@ set -euo pipefail +shopt -s nullglob export PATH="@binPath@" # used for glob ordering of package names |