From 3463d22cd84e38697e9d43a4953ff84c3ce9074a Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 2 Dec 2024 21:21:10 -0400 Subject: [PATCH 1/8] buildDotnetGlobalTool: format with nixfmt --- .../build-dotnet-global-tool/default.nix | 84 +++++++++++-------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix b/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix index 2177000c3627..9d199a6d0a4e 100644 --- a/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix @@ -1,53 +1,67 @@ -{ buildDotnetModule, emptyDirectory, fetchNupkg, dotnet-sdk }: +{ + buildDotnetModule, + emptyDirectory, + fetchNupkg, + dotnet-sdk, +}: -{ pname -, version +{ + pname, + version, # Name of the nuget package to install, if different from pname -, nugetName ? pname + nugetName ? pname, # Hash of the nuget package to install, will be given on first build # nugetHash uses SRI hash and should be preferred -, nugetHash ? "" -, nugetSha256 ? "" + nugetHash ? "", + nugetSha256 ? "", # Additional nuget deps needed by the tool package -, nugetDeps ? (_: []) + nugetDeps ? (_: [ ]), # Executables to wrap into `$out/bin`, same as in `buildDotnetModule`, but with # a default of `pname` instead of null, to avoid auto-wrapping everything -, executables ? pname + executables ? pname, # The dotnet runtime to use, dotnet tools need a full SDK to function -, dotnet-runtime ? dotnet-sdk -, ... -} @ args: + dotnet-runtime ? dotnet-sdk, + ... +}@args: -buildDotnetModule (args // { - inherit pname version dotnet-runtime executables; +buildDotnetModule ( + args + // { + inherit + pname + version + dotnet-runtime + executables + ; - src = emptyDirectory; + src = emptyDirectory; - buildInputs = [ - (fetchNupkg { - pname = nugetName; - inherit version; - sha256 = nugetSha256; - hash = nugetHash; - installable = true; - }) - ]; + buildInputs = [ + (fetchNupkg { + pname = nugetName; + inherit version; + sha256 = nugetSha256; + hash = nugetHash; + installable = true; + }) + ]; - dotnetGlobalTool = true; + dotnetGlobalTool = true; - useDotnetFromEnv = true; + useDotnetFromEnv = true; - dontBuild = true; + dontBuild = true; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - dotnet tool install --tool-path $out/lib/${pname} ${nugetName} + dotnet tool install --tool-path $out/lib/${pname} ${nugetName} - # remove files that contain nix store paths to temp nuget sources we made - find $out -name 'project.assets.json' -delete - find $out -name '.nupkg.metadata' -delete + # remove files that contain nix store paths to temp nuget sources we made + find $out -name 'project.assets.json' -delete + find $out -name '.nupkg.metadata' -delete - runHook postInstall - ''; -}) + runHook postInstall + ''; + } +) From 07a92bc00666ed8c9aaecaf2a50907d7ebbcbf01 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 2 Dec 2024 21:27:55 -0400 Subject: [PATCH 2/8] buildDotnetGlobalTools: add finalAttrs support --- .../build-dotnet-global-tool/default.nix | 102 +++++++++--------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix b/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix index 9d199a6d0a4e..4b8ad583d82d 100644 --- a/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix @@ -3,65 +3,71 @@ emptyDirectory, fetchNupkg, dotnet-sdk, + lib, }: -{ - pname, - version, - # Name of the nuget package to install, if different from pname - nugetName ? pname, - # Hash of the nuget package to install, will be given on first build - # nugetHash uses SRI hash and should be preferred - nugetHash ? "", - nugetSha256 ? "", - # Additional nuget deps needed by the tool package - nugetDeps ? (_: [ ]), - # Executables to wrap into `$out/bin`, same as in `buildDotnetModule`, but with - # a default of `pname` instead of null, to avoid auto-wrapping everything - executables ? pname, - # The dotnet runtime to use, dotnet tools need a full SDK to function - dotnet-runtime ? dotnet-sdk, - ... -}@args: +fnOrAttrs: buildDotnetModule ( - args - // { - inherit - pname - version - dotnet-runtime - executables - ; + finalAttrs: + ( + { + pname, + version, + # Name of the nuget package to install, if different from pname + nugetName ? pname, + # Hash of the nuget package to install, will be given on first build + # nugetHash uses SRI hash and should be preferred + nugetHash ? "", + nugetSha256 ? "", + # Additional nuget deps needed by the tool package + nugetDeps ? (_: [ ]), + # Executables to wrap into `$out/bin`, same as in `buildDotnetModule`, but with + # a default of `pname` instead of null, to avoid auto-wrapping everything + executables ? pname, + # The dotnet runtime to use, dotnet tools need a full SDK to function + dotnet-runtime ? dotnet-sdk, + ... + }@args: + args + // { + inherit + pname + version + dotnet-runtime + executables + ; - src = emptyDirectory; + src = emptyDirectory; - buildInputs = [ - (fetchNupkg { - pname = nugetName; - inherit version; - sha256 = nugetSha256; - hash = nugetHash; - installable = true; - }) - ]; + buildInputs = [ + (fetchNupkg { + pname = nugetName; + inherit version; + sha256 = nugetSha256; + hash = nugetHash; + installable = true; + }) + ]; - dotnetGlobalTool = true; + dotnetGlobalTool = true; - useDotnetFromEnv = true; + useDotnetFromEnv = true; - dontBuild = true; + dontBuild = true; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - dotnet tool install --tool-path $out/lib/${pname} ${nugetName} + dotnet tool install --tool-path $out/lib/${pname} ${nugetName} - # remove files that contain nix store paths to temp nuget sources we made - find $out -name 'project.assets.json' -delete - find $out -name '.nupkg.metadata' -delete + # remove files that contain nix store paths to temp nuget sources we made + find $out -name 'project.assets.json' -delete + find $out -name '.nupkg.metadata' -delete - runHook postInstall - ''; - } + runHook postInstall + ''; + } + ) + (if lib.isFunction fnOrAttrs then fnOrAttrs finalAttrs else fnOrAttrs) ) From 04f1c8b4eab2d07d390015461d182dc5818f89c4 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 2 Dec 2024 22:32:11 -0400 Subject: [PATCH 3/8] buildDotnetGlobalTool: add default updateScript --- .../build-dotnet-global-tool/default.nix | 24 +++++++----- .../dotnet/build-dotnet-global-tool/update.sh | 24 ++++++++++++ pkgs/by-name/cs/csharp-ls/package.nix | 5 --- pkgs/development/tools/fable/default.nix | 1 - pkgs/development/tools/fable/update.sh | 39 ------------------- 5 files changed, 39 insertions(+), 54 deletions(-) create mode 100755 pkgs/build-support/dotnet/build-dotnet-global-tool/update.sh delete mode 100755 pkgs/development/tools/fable/update.sh diff --git a/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix b/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix index 4b8ad583d82d..f6a832386b9f 100644 --- a/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix @@ -29,6 +29,15 @@ buildDotnetModule ( dotnet-runtime ? dotnet-sdk, ... }@args: + let + nupkg = fetchNupkg { + pname = nugetName; + inherit version; + sha256 = nugetSha256; + hash = nugetHash; + installable = true; + }; + in args // { inherit @@ -40,15 +49,7 @@ buildDotnetModule ( src = emptyDirectory; - buildInputs = [ - (fetchNupkg { - pname = nugetName; - inherit version; - sha256 = nugetSha256; - hash = nugetHash; - installable = true; - }) - ]; + buildInputs = [ nupkg ]; dotnetGlobalTool = true; @@ -67,6 +68,11 @@ buildDotnetModule ( runHook postInstall ''; + + passthru = { + updateScript = ./update.sh; + nupkg = nupkg; + } // args.passthru or {}; } ) (if lib.isFunction fnOrAttrs then fnOrAttrs finalAttrs else fnOrAttrs) diff --git a/pkgs/build-support/dotnet/build-dotnet-global-tool/update.sh b/pkgs/build-support/dotnet/build-dotnet-global-tool/update.sh new file mode 100755 index 000000000000..e00fae9ace36 --- /dev/null +++ b/pkgs/build-support/dotnet/build-dotnet-global-tool/update.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env nix-shell +#!nix-shell -I nixpkgs=./. -i bash -p curl jq nix common-updater-scripts +# shellcheck shell=bash + +set -euo pipefail + +attr=$UPDATE_NIX_ATTR_PATH + +nixeval() { + nix --extra-experimental-features nix-command eval --json --impure -f . "$1" | jq -r . +} + +nugetName=$(nixeval "$attr.nupkg.pname") + +# always skip prerelease versions for now +version=$(curl -fsSL "https://api.nuget.org/v3-flatcontainer/$nugetName/index.json" | + jq -er '.versions | last(.[] | select(match("^[0-9]+\\.[0-9]+\\.[0-9]+$")))') + +if [[ $version == $(nixeval "$attr.version") ]]; then + echo "$attr" is already version "$version" + exit 0 +fi + +update-source-version "$attr" "$version" --source-key=nupkg.src diff --git a/pkgs/by-name/cs/csharp-ls/package.nix b/pkgs/by-name/cs/csharp-ls/package.nix index 1ae39b36d2bb..4f2972575637 100644 --- a/pkgs/by-name/cs/csharp-ls/package.nix +++ b/pkgs/by-name/cs/csharp-ls/package.nix @@ -2,7 +2,6 @@ lib, buildDotnetGlobalTool, dotnetCorePackages, - nix-update-script, }: let inherit (dotnetCorePackages) sdk_8_0; @@ -17,10 +16,6 @@ buildDotnetGlobalTool rec { dotnet-sdk = sdk_8_0; dotnet-runtime = sdk_8_0; - passthru = { - updateScript = nix-update-script { }; - }; - meta = { description = "Roslyn-based LSP language server for C#"; mainProgram = "csharp-ls"; diff --git a/pkgs/development/tools/fable/default.nix b/pkgs/development/tools/fable/default.nix index ea5362daa90f..172c3d310321 100644 --- a/pkgs/development/tools/fable/default.nix +++ b/pkgs/development/tools/fable/default.nix @@ -5,7 +5,6 @@ buildDotnetGlobalTool { version = "4.20.0"; nugetHash = "sha256-K3908gEbl9crT4wmZfBtvag5Z6qYABfalBfLZlqZuDk="; - passthru.updateScript = ./update.sh; meta = with lib; { description = "Fable is an F# to JavaScript compiler"; diff --git a/pkgs/development/tools/fable/update.sh b/pkgs/development/tools/fable/update.sh deleted file mode 100755 index 181570d1a0de..000000000000 --- a/pkgs/development/tools/fable/update.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl gnused nix-prefetch jq - -set -euo pipefail -URL="https://github.com/fable-compiler/fable" -PKG="Fable" -ROOT="$(dirname "$(readlink -f "$0")")" -NIX_DRV="$ROOT/default.nix" -if [ ! -f "$NIX_DRV" ]; then - echo "ERROR: cannot find default.nix in $ROOT" - exit 1 -fi - -TMP="$(mktemp -d)" -clean_up() { - rm -rf "$TMP" -} -trap clean_up EXIT SIGINT SIGTERM -PACKAGES="$TMP/packages" -SRC_RW="$TMP/src" - -mkdir -p $SRC_RW -mkdir -p $PACKAGES - - -VER=$(curl -s "https://api.github.com/repos/fable-compiler/fable/releases/latest" | jq -r .tag_name | grep -oP '\d+\.\d+\.\d+' ) - -CURRENT_VER=$(grep -oP '(?<=version = ")[^"]+' "$NIX_DRV") -if [[ "$CURRENT_VER" == "$VER" ]]; then - echo "$PKG is already up to date: $CURRENT_VER" - exit -fi - - -NUGET_URL="$(curl -f "https://api.nuget.org/v3/index.json" | jq --raw-output '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"')$PKG/$VER/$PKG.$VER.nupkg" -HASH=$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url "$NUGET_URL")") - -sed -i "s/version = \".*\"/version = \"$VER\"/" "$NIX_DRV" -sed -i "s#nugetHash = \"sha256-.\{44\}\"#nugetHash = \"$HASH\"#" "$NIX_DRV" From 79e336184f5c5d0a1d55abd721193863534e27fe Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 2 Dec 2024 22:35:10 -0400 Subject: [PATCH 4/8] fable: add version test --- pkgs/development/tools/fable/default.nix | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pkgs/development/tools/fable/default.nix b/pkgs/development/tools/fable/default.nix index 172c3d310321..5ea966199cdb 100644 --- a/pkgs/development/tools/fable/default.nix +++ b/pkgs/development/tools/fable/default.nix @@ -1,11 +1,22 @@ -{ buildDotnetGlobalTool, lib }: +{ + buildDotnetGlobalTool, + lib, + testers, +}: -buildDotnetGlobalTool { +buildDotnetGlobalTool (finalAttrs: { pname = "fable"; version = "4.20.0"; nugetHash = "sha256-K3908gEbl9crT4wmZfBtvag5Z6qYABfalBfLZlqZuDk="; + passthru.tests = testers.testVersion { + package = finalAttrs.finalPackage; + # the version is written with an escape sequence for colour, and I couldn't + # find a way to disable it + version = "[37m${finalAttrs.version}"; + }; + meta = with lib; { description = "Fable is an F# to JavaScript compiler"; mainProgram = "fable"; @@ -13,6 +24,9 @@ buildDotnetGlobalTool { changelog = "https://github.com/fable-compiler/fable/releases/tag/v${version}"; license = licenses.mit; platforms = platforms.linux; - maintainers = with maintainers; [ anpin mdarocha ]; + maintainers = with maintainers; [ + anpin + mdarocha + ]; }; -} +}) From f355a9b9d75a398e09b0773bb1d8b7f636bd0434 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Tue, 3 Dec 2024 03:32:32 +0000 Subject: [PATCH 5/8] csharpier: 0.29.1 -> 0.30.2 --- pkgs/by-name/cs/csharpier/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/cs/csharpier/package.nix b/pkgs/by-name/cs/csharpier/package.nix index ab9c003e2765..7bc0c0d26a9d 100644 --- a/pkgs/by-name/cs/csharpier/package.nix +++ b/pkgs/by-name/cs/csharpier/package.nix @@ -2,10 +2,10 @@ buildDotnetGlobalTool { pname = "csharpier"; - version = "0.29.1"; + version = "0.30.2"; executables = "dotnet-csharpier"; - nugetHash = "sha256-VW9QzbQfbY3Tz+Gz3hQ7VC4wOtwfIYV1Yq2WJz6bL04="; + nugetHash = "sha256-MrpsVlIYyrlu3VvEPcLQRgD2lhfu8ZTN3pUZrZ9nQcA="; meta = with lib; { description = "Opinionated code formatter for C#"; From fb426e653dda5e30de0ae656a9ff817e2ba9efa4 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Tue, 3 Dec 2024 03:32:36 +0000 Subject: [PATCH 6/8] fable: 4.20.0 -> 4.24.0 --- pkgs/development/tools/fable/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/fable/default.nix b/pkgs/development/tools/fable/default.nix index 5ea966199cdb..31013115cb09 100644 --- a/pkgs/development/tools/fable/default.nix +++ b/pkgs/development/tools/fable/default.nix @@ -6,9 +6,9 @@ buildDotnetGlobalTool (finalAttrs: { pname = "fable"; - version = "4.20.0"; + version = "4.24.0"; - nugetHash = "sha256-K3908gEbl9crT4wmZfBtvag5Z6qYABfalBfLZlqZuDk="; + nugetHash = "sha256-ERewWqfEyyZKpHFFALpMGJT0fDWywBYY5buU/wTZZTg="; passthru.tests = testers.testVersion { package = finalAttrs.finalPackage; From a6a87f182150a50d7dffbd77a8e361f1a58b00c6 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Tue, 3 Dec 2024 03:32:41 +0000 Subject: [PATCH 7/8] pbm: 1.3.2 -> 1.4.3 --- pkgs/by-name/pb/pbm/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/pb/pbm/package.nix b/pkgs/by-name/pb/pbm/package.nix index 8a444311ffd6..57646c1db161 100644 --- a/pkgs/by-name/pb/pbm/package.nix +++ b/pkgs/by-name/pb/pbm/package.nix @@ -2,9 +2,9 @@ buildDotnetGlobalTool { pname = "pbm"; - version = "1.3.2"; + version = "1.4.3"; - nugetHash = "sha256-xu3g8NFLZYnHzBuoIhIiAzaPJqY0xhLWLYi+ORRADH8="; + nugetHash = "sha256-R6dmF3HPI2BAcNGLCm6WwBlk4ev6T6jaiJUAWYKf2S4="; meta = with lib; { description = "CLI for managing Akka.NET applications and Akka.NET Clusters"; From 8e497c4232fd2ce640046203e441f3ce64f3b45a Mon Sep 17 00:00:00 2001 From: David McFarland Date: Tue, 3 Dec 2024 03:32:46 +0000 Subject: [PATCH 8/8] upgrade-assistant: 0.5.820 -> 0.5.829 --- pkgs/by-name/up/upgrade-assistant/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/up/upgrade-assistant/package.nix b/pkgs/by-name/up/upgrade-assistant/package.nix index 4550a3f7b71e..06e361d74267 100644 --- a/pkgs/by-name/up/upgrade-assistant/package.nix +++ b/pkgs/by-name/up/upgrade-assistant/package.nix @@ -1,9 +1,9 @@ { lib, buildDotnetGlobalTool }: buildDotnetGlobalTool { pname = "upgrade-assistant"; - version = "0.5.820"; + version = "0.5.829"; - nugetHash = "sha256-GB+q5aZRkBTeXUbIPjkPsll6pSI/H6Iyh5mY53uT284="; + nugetHash = "sha256-N0xEmPQ88jfirGPLJykeAJQYGwELFzKwUWdFxIgiwhY="; meta = { homepage = "https://github.com/dotnet/upgrade-assistant";