-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dotnet: infrastructure improvements (#336824)
- Loading branch information
Showing
37 changed files
with
5,741 additions
and
2,834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
writeShellScript, | ||
runtimeShell, | ||
nix, | ||
lib, | ||
substituteAll, | ||
nuget-to-nix, | ||
cacert, | ||
fetchNupkg, | ||
callPackage, | ||
}: | ||
|
||
{ | ||
nugetDeps, | ||
overrideFetchAttrs ? x: { }, | ||
}: | ||
fnOrAttrs: finalAttrs: | ||
let | ||
attrs = if builtins.isFunction fnOrAttrs then fnOrAttrs finalAttrs else fnOrAttrs; | ||
|
||
deps = | ||
if (nugetDeps != null) then | ||
if lib.isDerivation nugetDeps then | ||
[ nugetDeps ] | ||
else if lib.isList nugetDeps then | ||
nugetDeps | ||
else | ||
assert (lib.isPath nugetDeps); | ||
callPackage nugetDeps { fetchNuGet = fetchNupkg; } | ||
else | ||
[ ]; | ||
|
||
finalPackage = finalAttrs.finalPackage; | ||
|
||
in | ||
attrs | ||
// { | ||
buildInputs = attrs.buildInputs or [ ] ++ deps; | ||
|
||
passthru = | ||
attrs.passthru or { } | ||
// { | ||
nugetDeps = deps; | ||
} | ||
// lib.optionalAttrs (nugetDeps == null || lib.isPath nugetDeps) rec { | ||
fetch-drv = | ||
let | ||
pkg' = finalPackage.overrideAttrs (old: { | ||
buildInputs = attrs.buildInputs or [ ]; | ||
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ cacert ]; | ||
keepNugetConfig = true; | ||
dontBuild = true; | ||
doCheck = false; | ||
dontInstall = true; | ||
doInstallCheck = false; | ||
dontFixup = true; | ||
doDist = false; | ||
}); | ||
in | ||
pkg'.overrideAttrs overrideFetchAttrs; | ||
fetch-deps = | ||
let | ||
drv = builtins.unsafeDiscardOutputDependency fetch-drv.drvPath; | ||
|
||
innerScript = substituteAll { | ||
src = ./fetch-deps.sh; | ||
isExecutable = true; | ||
inherit cacert; | ||
nugetToNix = nuget-to-nix; | ||
}; | ||
|
||
defaultDepsFile = | ||
# Wire in the depsFile such that running the script with no args | ||
# runs it agains the correct deps file by default. | ||
# 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.isStorePath nugetDeps then | ||
toString nugetDeps | ||
else | ||
''$(mktemp -t "${finalAttrs.pname or finalPackage.name}-deps-XXXXXX.nix")''; | ||
|
||
in | ||
writeShellScript "${finalPackage.name}-fetch-deps" '' | ||
set -eu | ||
echo 'fetching dependencies for' ${lib.escapeShellArg finalPackage.name} >&2 | ||
# this needs to be before TMPDIR is changed, so the output isn't deleted | ||
# if it uses mktemp | ||
depsFile=$(realpath "''${1:-${lib.escapeShellArg defaultDepsFile}}") | ||
export TMPDIR | ||
TMPDIR=$(mktemp -d -t fetch-deps-${lib.escapeShellArg finalPackage.name}.XXXXXX) | ||
trap 'chmod -R +w "$TMPDIR" && rm -fr "$TMPDIR"' EXIT | ||
export NUGET_HTTP_CACHE_PATH=''${NUGET_HTTP_CACHE_PATH-~/.local/share/NuGet/v3-cache} | ||
HOME=$TMPDIR/home | ||
mkdir "$HOME" | ||
cd "$TMPDIR" | ||
NIX_BUILD_SHELL=${lib.escapeShellArg runtimeShell} ${nix}/bin/nix-shell \ | ||
--pure --keep NUGET_HTTP_CACHE_PATH --run 'source '${lib.escapeShellArg innerScript}' '"''${depsFile@Q}" "${drv}" | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set -e | ||
|
||
genericBuild | ||
|
||
( | ||
echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" | ||
@nugetToNix@/bin/nuget-to-nix "${NUGET_PACKAGES%/}" | ||
) > deps.nix | ||
|
||
mv deps.nix "$1" | ||
echo "Succesfully wrote lockfile to $1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
pkgs/build-support/dotnet/build-dotnet-module/fetch-deps.sh
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.