···8383} @ args:
84848585let
8686+ platforms =
8787+ if args ? meta.platforms
8888+ then lib.intersectLists args.meta.platforms dotnet-sdk.meta.platforms
8989+ else dotnet-sdk.meta.platforms;
9090+8691 inherit (callPackage ./hooks {
8792 inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
8893 }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
···152157153158 fetch-deps =
154159 let
155155- # Because this list is rather long its put in its own store path to maintain readability of the generated script
156156- exclusions = writeText "nuget-package-exclusions" (lib.concatStringsSep "\n" (dotnet-sdk.passthru.packages { fetchNuGet = attrs: attrs.pname; }));
157157-158160 # Derivations may set flags such as `--runtime <rid>` based on the host platform to avoid restoring/building nuget dependencies they dont have or dont need.
159161 # This introduces an issue; In this script we loop over all platforms from `meta` and add the RID flag for it, as to fetch all required dependencies.
160162 # The script would inherit the RID flag from the derivation based on the platform building the script, and set the flag for any iteration we do over the RIDs.
···165167 in
166168 builtins.filter (flag: !(hasRid flag)) (dotnetFlags ++ dotnetRestoreFlags);
167169168168- runtimeIds = map (system: dotnet-sdk.systemToDotnetRid system) (args.meta.platforms or dotnet-sdk.meta.platforms);
170170+ runtimeIds = map (system: dotnet-sdk.systemToDotnetRid system) platforms;
169171 in
170172 writeShellScript "fetch-${pname}-deps" ''
171173 set -euo pipefail
172174173173- export PATH="${lib.makeBinPath [ coreutils dotnet-sdk nuget-to-nix ]}"
175175+ export PATH="${lib.makeBinPath [ coreutils dotnet-sdk (nuget-to-nix.override { inherit dotnet-sdk; }) ]}"
174176175177 for arg in "$@"; do
176178 case "$arg" in
···179181 shift
180182 ;;
181183 --help|-h)
182182- echo "usage: $0 <output path> [--keep-sources] [--help]"
184184+ echo "usage: $0 [--keep-sources] [--help] <output path>"
183185 echo " <output path> The path to write the lockfile to. A temporary file is used if this is not set"
184186 echo " --keep-sources Dont remove temporary directories upon exit, useful for debugging"
185187 echo " --help Show this help message"
···188190 esac
189191 done
190192193193+ export tmp=$(mktemp -td "${pname}-tmp-XXXXXX")
194194+ HOME=$tmp/home
195195+191196 exitTrap() {
192197 test -n "''${ranTrap-}" && return
193198 ranTrap=1
194199195200 if test -n "''${keepSources-}"; then
196196- echo -e "Path to the source: $src\nPath to the fake home: $HOME"
201201+ echo -e "Path to the source: $tmp/src\nPath to the fake home: $tmp/home"
197202 else
198198- rm -rf "$src" "$HOME"
203203+ rm -rf "$tmp"
199204 fi
200205201206 # Since mktemp is used this will be empty if the script didnt succesfully complete
···211216 dotnet restore ''${project-} \
212217 -p:ContinuousIntegrationBuild=true \
213218 -p:Deterministic=true \
214214- --packages "$HOME/nuget_pkgs" \
219219+ --packages "$tmp/nuget_pkgs" \
215220 --runtime "$rid" \
221221+ --no-cache \
222222+ --force \
216223 ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
217224 ${lib.optionalString (flags != []) (toString flags)}
218225 }
···220227 declare -a projectFiles=( ${toString (lib.toList projectFile)} )
221228 declare -a testProjectFiles=( ${toString (lib.toList testProjectFile)} )
222229223223- export HOME=$(mktemp -td "${pname}-home-XXXXXX")
224230 export DOTNET_NOLOGO=1
225231 export DOTNET_CLI_TELEMETRY_OPTOUT=1
226232227227- depsFile="$(realpath "''${1:-$(mktemp -t "${pname}-deps-XXXXXX.nix")}")"
228228- mkdir -p "$HOME/nuget_pkgs"
233233+ depsFile=$(realpath "''${1:-$(mktemp -t "${pname}-deps-XXXXXX.nix")}")
234234+ mkdir -p "$tmp/nuget_pkgs"
229235230236 storeSrc="${srcOnly args}"
231231- src="$(mktemp -td "${pname}-src-XXXXXX")"
237237+ src=$tmp/src
232238 cp -rT "$storeSrc" "$src"
233239 chmod -R +w "$src"
234240···247253248254 echo "Writing lockfile..."
249255 echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$depsFile"
250250- nuget-to-nix "$HOME/nuget_pkgs" "${exclusions}" >> "$depsFile"
256256+ nuget-to-nix "$tmp/nuget_pkgs" "${sdkDeps}" >> "$depsFile"
251257 echo "Succesfully wrote lockfile to $depsFile"
252258 '';
253259 } // args.passthru or { };
254260255255- meta = {
256256- platforms = dotnet-sdk.meta.platforms;
257257- } // args.meta or { };
261261+ meta = (args.meta or { }) // { inherit platforms; };
258262})