···83} @ args:
8485let
0000086 inherit (callPackage ./hooks {
87 inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
88 }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
···152153 fetch-deps =
154 let
155- # Because this list is rather long its put in its own store path to maintain readability of the generated script
156- exclusions = writeText "nuget-package-exclusions" (lib.concatStringsSep "\n" (dotnet-sdk.passthru.packages { fetchNuGet = attrs: attrs.pname; }));
157-158 # 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.
159 # 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.
160 # 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.
···165 in
166 builtins.filter (flag: !(hasRid flag)) (dotnetFlags ++ dotnetRestoreFlags);
167168- runtimeIds = map (system: dotnet-sdk.systemToDotnetRid system) (args.meta.platforms or dotnet-sdk.meta.platforms);
169 in
170 writeShellScript "fetch-${pname}-deps" ''
171 set -euo pipefail
172173- export PATH="${lib.makeBinPath [ coreutils dotnet-sdk nuget-to-nix ]}"
174175 for arg in "$@"; do
176 case "$arg" in
···179 shift
180 ;;
181 --help|-h)
182- echo "usage: $0 <output path> [--keep-sources] [--help]"
183 echo " <output path> The path to write the lockfile to. A temporary file is used if this is not set"
184 echo " --keep-sources Dont remove temporary directories upon exit, useful for debugging"
185 echo " --help Show this help message"
···188 esac
189 done
190000191 exitTrap() {
192 test -n "''${ranTrap-}" && return
193 ranTrap=1
194195 if test -n "''${keepSources-}"; then
196- echo -e "Path to the source: $src\nPath to the fake home: $HOME"
197 else
198- rm -rf "$src" "$HOME"
199 fi
200201 # Since mktemp is used this will be empty if the script didnt succesfully complete
···211 dotnet restore ''${project-} \
212 -p:ContinuousIntegrationBuild=true \
213 -p:Deterministic=true \
214- --packages "$HOME/nuget_pkgs" \
215 --runtime "$rid" \
00216 ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
217 ${lib.optionalString (flags != []) (toString flags)}
218 }
···220 declare -a projectFiles=( ${toString (lib.toList projectFile)} )
221 declare -a testProjectFiles=( ${toString (lib.toList testProjectFile)} )
222223- export HOME=$(mktemp -td "${pname}-home-XXXXXX")
224 export DOTNET_NOLOGO=1
225 export DOTNET_CLI_TELEMETRY_OPTOUT=1
226227- depsFile="$(realpath "''${1:-$(mktemp -t "${pname}-deps-XXXXXX.nix")}")"
228- mkdir -p "$HOME/nuget_pkgs"
229230 storeSrc="${srcOnly args}"
231- src="$(mktemp -td "${pname}-src-XXXXXX")"
232 cp -rT "$storeSrc" "$src"
233 chmod -R +w "$src"
234···247248 echo "Writing lockfile..."
249 echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$depsFile"
250- nuget-to-nix "$HOME/nuget_pkgs" "${exclusions}" >> "$depsFile"
251 echo "Succesfully wrote lockfile to $depsFile"
252 '';
253 } // args.passthru or { };
254255- meta = {
256- platforms = dotnet-sdk.meta.platforms;
257- } // args.meta or { };
258})
···83} @ args:
8485let
86+ platforms =
87+ if args ? meta.platforms
88+ then lib.intersectLists args.meta.platforms dotnet-sdk.meta.platforms
89+ else dotnet-sdk.meta.platforms;
90+91 inherit (callPackage ./hooks {
92 inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
93 }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
···157158 fetch-deps =
159 let
000160 # 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.
161 # 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.
162 # 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.
···167 in
168 builtins.filter (flag: !(hasRid flag)) (dotnetFlags ++ dotnetRestoreFlags);
169170+ runtimeIds = map (system: dotnet-sdk.systemToDotnetRid system) platforms;
171 in
172 writeShellScript "fetch-${pname}-deps" ''
173 set -euo pipefail
174175+ export PATH="${lib.makeBinPath [ coreutils dotnet-sdk (nuget-to-nix.override { inherit dotnet-sdk; }) ]}"
176177 for arg in "$@"; do
178 case "$arg" in
···181 shift
182 ;;
183 --help|-h)
184+ echo "usage: $0 [--keep-sources] [--help] <output path>"
185 echo " <output path> The path to write the lockfile to. A temporary file is used if this is not set"
186 echo " --keep-sources Dont remove temporary directories upon exit, useful for debugging"
187 echo " --help Show this help message"
···190 esac
191 done
192193+ export tmp=$(mktemp -td "${pname}-tmp-XXXXXX")
194+ HOME=$tmp/home
195+196 exitTrap() {
197 test -n "''${ranTrap-}" && return
198 ranTrap=1
199200 if test -n "''${keepSources-}"; then
201+ echo -e "Path to the source: $tmp/src\nPath to the fake home: $tmp/home"
202 else
203+ rm -rf "$tmp"
204 fi
205206 # Since mktemp is used this will be empty if the script didnt succesfully complete
···216 dotnet restore ''${project-} \
217 -p:ContinuousIntegrationBuild=true \
218 -p:Deterministic=true \
219+ --packages "$tmp/nuget_pkgs" \
220 --runtime "$rid" \
221+ --no-cache \
222+ --force \
223 ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
224 ${lib.optionalString (flags != []) (toString flags)}
225 }
···227 declare -a projectFiles=( ${toString (lib.toList projectFile)} )
228 declare -a testProjectFiles=( ${toString (lib.toList testProjectFile)} )
2290230 export DOTNET_NOLOGO=1
231 export DOTNET_CLI_TELEMETRY_OPTOUT=1
232233+ depsFile=$(realpath "''${1:-$(mktemp -t "${pname}-deps-XXXXXX.nix")}")
234+ mkdir -p "$tmp/nuget_pkgs"
235236 storeSrc="${srcOnly args}"
237+ src=$tmp/src
238 cp -rT "$storeSrc" "$src"
239 chmod -R +w "$src"
240···253254 echo "Writing lockfile..."
255 echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$depsFile"
256+ nuget-to-nix "$tmp/nuget_pkgs" "${sdkDeps}" >> "$depsFile"
257 echo "Succesfully wrote lockfile to $depsFile"
258 '';
259 } // args.passthru or { };
260261+ meta = (args.meta or { }) // { inherit platforms; };
00262})