| 18 Dec 2024 |
6pak | also the dotnet nuget add source workaround is not exactly correct because it means nuget.org gets lower priority | 17:02:21 |
6pak | also did anything come out of wanting to run fetch-deps in the sandbox? | 17:04:58 |
6pak | diff --git a/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh b/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh
--- a/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh (revision c70d04efdede54181fa5901b796c84e7c87166f2)
+++ b/pkgs/development/compilers/dotnet/dotnet-sdk-setup-hook.sh (date 1734541198688)
@@ -100,6 +100,18 @@
-i /configuration/packageSources/__new -t attr -n value -v "$nugetSource"
-r /configuration/packageSources/__new -v add)
+ if [[ -n ${keepNugetConfig-} ]] && ! xmlstarlet select -t -i "/configuration/packageSources/clear" -nl "$rootConfig"; then
+ @xmlstarlet@/bin/xmlstarlet ed --inplace \
+ -s /configuration -t elem -n "packageSources" \
+ -d "/configuration/packageSources[position() != 1]" \
+ -s "/configuration/packageSources" -t elem -n __unused \
+ -i "/configuration/packageSources/*[1]" -t elem -n add \
+ -i "/configuration/packageSources/*[1]" -t attr -n key -v "nuget" \
+ -i "/configuration/packageSources/*[1]" -t attr -n value -v "https://api.nuget.org/v3/index.json" \
+ -d "/configuration/packageSources/__unused" \
+ "$rootConfig"
+ fi
+
if [[ -z ${keepNugetConfig-} ]]; then
xmlConfigArgs+=(-d '//configuration/*')
xmlRootConfigArgs+=("${xmlSourceConfigArgs[@]}")
seems to work fine
| 17:09:15 |
6pak | it has to be a separate xmlstarlet call for mapNuGetDependencies to work | 17:09:35 |
6pak | is there really no sandboxProfile for linux? | 17:36:50 |
6pak | got something working
diff --git a/pkgs/build-support/dotnet/add-nuget-deps/default.nix b/pkgs/build-support/dotnet/add-nuget-deps/default.nix
--- a/pkgs/build-support/dotnet/add-nuget-deps/default.nix (revision c70d04efdede54181fa5901b796c84e7c87166f2)
+++ b/pkgs/build-support/dotnet/add-nuget-deps/default.nix (date 1734548430924)
@@ -48,15 +48,32 @@
fetch-drv =
let
pkg' = finalPackage.overrideAttrs (old: {
+ pname = "${old.pname}-fetch-deps-inner";
+
buildInputs = attrs.buildInputs or [ ];
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ cacert ];
keepNugetConfig = true;
- dontBuild = true;
- doCheck = false;
- dontInstall = true;
- doInstallCheck = false;
- dontFixup = true;
- doDist = false;
+
+ __impure = true;
+
+ phases = [
+ "unpackPhase"
+ "patchPhase"
+ "configureNuget"
+ "configurePhase"
+ "fetchDepsPhase"
+ ];
+
+ fetchDepsPhase = ''
+ mkdir -p "$out"
+
+ (
+ echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n"
+ ${lib.getExe buildPackages.nuget-to-nix} "''${NUGET_PACKAGES%/}"
+ ) > "$out/deps.nix"
+
+ ${lib.getExe buildPackages.nixfmt-rfc-style} "$out/deps.nix"
+ '';
});
in
pkg'.overrideAttrs overrideFetchAttrs;
@@ -64,14 +81,6 @@
let
drv = builtins.unsafeDiscardOutputDependency fetch-drv.drvPath;
- innerScript = substituteAll {
- src = ./fetch-deps.sh;
- isExecutable = true;
- inherit (buildPackages) cacert;
- nugetToNix = buildPackages.nuget-to-nix;
- nixfmt = buildPackages.nixfmt-rfc-style;
- };
-
defaultDepsFile =
# Wire in the depsFile such that running the script with no args
# runs it agains the correct deps file by default.
@@ -89,23 +98,14 @@
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}
+ out=$(${buildPackages.nix}/bin/nix build --no-link --print-out-paths --print-build-logs \
+ --option sandbox true \
+ "${drv}^*")
- HOME=$TMPDIR/home
- mkdir "$HOME"
-
- cd "$TMPDIR"
-
- NIX_BUILD_SHELL=${lib.escapeShellArg buildPackages.runtimeShell} ${buildPackages.nix}/bin/nix-shell \
- --pure --keep NUGET_HTTP_CACHE_PATH --run 'source '${lib.escapeShellArg innerScript}' '"''${depsFile@Q}" "${drv}"
+ cp "$out/deps.nix" "$depsFile"
+ echo "Succesfully wrote lockfile to $depsFile"
'';
};
}
| 19:01:25 |
6pak | okay this explains why beatsabermodmanager behaved so weirdly when running fetch-deps | 19:35:38 |
6pak |  Download image.png | 19:35:45 |
6pak | -_- | 19:35:47 |
Corngood | I thought all sources were equal in priority? | 19:40:24 |
6pak | how would that work | 19:40:43 |
6pak | different sources can have different package contents for the same version | 19:40:52 |
6pak | tbh it could error out in that case, but it doesn't | 19:41:02 |
6pak | it just takes the first result | 19:41:06 |
Corngood | So does this build a derivation? How do you make it unique on consecutive runs? | 19:41:23 |
6pak | it relies on impure-derivations | 19:41:42 |
Corngood | it actually uses the first one to respond or something insane like that | 19:41:45 |
6pak | which afaik makes it always rebuild | 19:41:47 |
6pak | and allows internet access | 19:41:49 |
Corngood | so an impure derivation will always rebuild? interesting | 19:42:13 |
6pak | that seems to be happening from what I see | 19:42:34 |
6pak | I would use --rebuild but that result in a non descriptive error for impure derivations, for some reason | 19:43:06 |
6pak | * I would use --rebuild but that result in a non descriptive error for impure derivations, for some reason (https://github.com/NixOS/nix/issues/9782) | 19:43:31 |
Corngood |
This is by design, sources are unordered and they are searched by order of the quickest response rather than by order of how they show up in file.
https://github.com/NuGet/Home/issues/3676
| 19:44:26 |
6pak | huh | 19:44:51 |
Corngood | I'm not sure how things have changed since then. But that was why nuget-to-nix had to check all the sources for each package :| | 19:45:04 |
6pak | if that's still the case then thats one more reason to always use package mapping | 19:45:38 |
6pak | * if that's still the case then thats one more reason to always use package source mapping | 19:45:58 |
Corngood | You can still end up with multiple sources as options for a package | 19:46:22 |
6pak | if that's still the case then I guess what I observed was simply the result of the first source being the first request made | 19:47:10 |