!bxVOQwsVoHhZcmNDGw:nixos.org

Nix + dotnet

126 Members
24 Servers

Load older messages


SenderMessageTime
17 Dec 2024
@gggkiller:matrix.orgGGGI just want to finish this nix to JSON PR already 😩23:21:42
@gggkiller:matrix.orgGGG and maybe get started on autoPatchilHook 23:21:54
@corngood:corngood.comCorngood I think at least godot_4-mono is missing from that list. I'm having a look at it now actually, but it may have to wait for upstream. 23:40:37
18 Dec 2024
@gggkiller:matrix.orgGGGok, took care of quite a few at https://github.com/NixOS/nixpkgs/pull/36606704:50:01
@jan.pluskal:matrix.orgJan Pluskal joined the room.07:13:38
@corngood:corngood.comCorngood
In reply to @gggkiller:matrix.org
ok, took care of quite a few at https://github.com/NixOS/nixpkgs/pull/366067
That's awesome. Thanks!
13:54:50
@6pak:matrix.org6pakI ran into https://github.com/NixOS/nixpkgs/issues/36349716:25:21
@6pak:matrix.org6paktried fixing it, and man do I hate xmlstarlet now16:25:26
@6pak:matrix.org6paklike what is this16:27:50
@6pak:matrix.org6pakimage.png
Download image.png
16:28:05
@6pak:matrix.org6pak also the dotnet nuget add source workaround is not exactly correct because it means nuget.org gets lower priority 17:02:21
@6pak:matrix.org6pakalso did anything come out of wanting to run fetch-deps in the sandbox?17:04:58
@6pak:matrix.org6pak
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:matrix.org6pakit has to be a separate xmlstarlet call for mapNuGetDependencies to work17:09:35
@6pak:matrix.org6pak is there really no sandboxProfile for linux? 17:36:50
@6pak:matrix.org6pak

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:matrix.org6pakokay this explains why beatsabermodmanager behaved so weirdly when running fetch-deps19:35:38
@6pak:matrix.org6pakimage.png
Download image.png
19:35:45
@6pak:matrix.org6pak-_-19:35:47
@corngood:corngood.comCorngoodI thought all sources were equal in priority?19:40:24
@6pak:matrix.org6pakhow would that work19:40:43
@6pak:matrix.org6pakdifferent sources can have different package contents for the same version19:40:52
@6pak:matrix.org6paktbh it could error out in that case, but it doesn't19:41:02
@6pak:matrix.org6pakit just takes the first result19:41:06
@corngood:corngood.comCorngoodSo does this build a derivation? How do you make it unique on consecutive runs?19:41:23
@6pak:matrix.org6pakit relies on impure-derivations19:41:42
@corngood:corngood.comCorngoodit actually uses the first one to respond or something insane like that19:41:45
@6pak:matrix.org6pakwhich afaik makes it always rebuild19:41:47
@6pak:matrix.org6pakand allows internet access19:41:49
@corngood:corngood.comCorngoodso an impure derivation will always rebuild? interesting19:42:13

Show newer messages


Back to Room ListRoom Version: 9