lol

buildDotnetModule: make fetch-deps find output path automatically

+89 -43
+1 -1
doc/languages-frameworks/dotnet.section.md
··· 123 123 * `dotnetPackFlags` can be used to pass flags to `dotnet pack`. Used only if `packNupkg` is set to `true`. 124 124 * `dotnetFlags` can be used to pass flags to all of the above phases. 125 125 126 - When packaging a new application, you need to fetch its dependencies. You can run `nix-build -A package.fetch-deps` to generate a script that will build a lockfile for you. After running the script you should have the location of the generated lockfile printed to the console, which can be copied to a stable directory. Then set `nugetDeps = ./deps.nix` and you're ready to build the derivation. 126 + When packaging a new application, you need to fetch its dependencies. Create an empty `deps.nix`, set `nugetDeps = ./deps.nix`, then run `nix-build -A package.fetch-deps` to generate a script that will build the lockfile for you. 127 127 128 128 Here is an example `default.nix`, using some of the previously discussed arguments: 129 129 ```nix
+72
maintainers/scripts/update-dotnet-lockfiles.nix
··· 1 + /* 2 + To run: 3 + 4 + nix-shell maintainers/scripts/update-dotnet-lockfiles.nix 5 + 6 + This script finds all the derivations in nixpkgs that have a 'fetch-deps' 7 + attribute, and runs all of them sequentially. This is useful to test changes 8 + to 'fetch-deps', 'nuget-to-nix', or other changes to the dotnet build 9 + infrastructure. Regular updates should be done through the individual packages 10 + update scripts. 11 + */ 12 + let 13 + pkgs = import ../.. {}; 14 + 15 + inherit (pkgs) lib; 16 + 17 + packagesWith = cond: pkgs: 18 + let 19 + packagesWithInner = attrs: 20 + lib.unique ( 21 + lib.concatLists ( 22 + lib.mapAttrsToList (name: elem: 23 + let 24 + result = builtins.tryEval elem; 25 + in 26 + if result.success then 27 + let 28 + value = result.value; 29 + in 30 + if lib.isDerivation value then 31 + lib.optional (cond value) value 32 + else 33 + if lib.isAttrs value && (value.recurseForDerivations or false || value.recurseForRelease or false) then 34 + packagesWithInner value 35 + else [] 36 + else []) attrs)); 37 + in 38 + packagesWithInner pkgs; 39 + 40 + packages = 41 + packagesWith (pkgs: pkgs ? fetch-deps) pkgs; 42 + 43 + helpText = '' 44 + Please run: 45 + 46 + % nix-shell maintainers/scripts/update-dotnet-lockfiles.nix 47 + ''; 48 + 49 + fetchScripts = map (p: p.fetch-deps) packages; 50 + 51 + in pkgs.stdenv.mkDerivation { 52 + name = "nixpkgs-update-dotnet-lockfiles"; 53 + buildCommand = '' 54 + echo "" 55 + echo "----------------------------------------------------------------" 56 + echo "" 57 + echo "Not possible to update packages using \`nix-build\`" 58 + echo "" 59 + echo "${helpText}" 60 + echo "----------------------------------------------------------------" 61 + exit 1 62 + ''; 63 + shellHook = '' 64 + unset shellHook # do not contaminate nested shells 65 + set -e 66 + for x in $fetchScripts; do 67 + $x 68 + done 69 + exit 70 + ''; 71 + inherit fetchScripts; 72 + }
+2 -3
pkgs/applications/blockchains/nbxplorer/util/update-common.sh
··· 9 9 trap 'echo "Error at ${BASH_SOURCE[0]}:$LINENO"' ERR 10 10 11 11 pkgName=$1 12 - depsFile=$2 13 12 14 13 : ${getVersionFromTags:=} 15 14 : ${refetch:=} ··· 41 40 if [[ $newVersion == $oldVersion && ! $refetch ]]; then 42 41 echo "nixpkgs already has the latest version $newVersion" 43 42 echo "Run this script with env var refetch=1 to re-verify the content hash via GPG" 44 - echo "and to recreate $(basename "$depsFile"). This is useful for reviewing a version update." 43 + echo "and to recreate deps.nix. This is useful for reviewing a version update." 45 44 exit 0 46 45 fi 47 46 ··· 74 73 echo 75 74 76 75 # Create deps file 77 - $(nix-build "$nixpkgs" -A $pkgName.fetch-deps --no-out-link) "$depsFile" 76 + $(nix-build "$nixpkgs" -A $pkgName.fetch-deps --no-out-link)
+1 -3
pkgs/applications/emulators/ryujinx/updater.sh
··· 3 3 set -euo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - DEPS_FILE="$(realpath "./deps.nix")" 7 - 8 6 # provide a github token so you don't get rate limited 9 7 # if you use gh cli you can use: 10 8 # `export GITHUB_TOKEN="$(cat ~/.config/gh/config.yml | yq '.hosts."github.com".oauth_token' -r)"` ··· 75 73 76 74 echo "building Nuget lockfile" 77 75 78 - $(nix-build -A ryujinx.fetch-deps --no-out-link) "$DEPS_FILE" 76 + $(nix-build -A ryujinx.fetch-deps --no-out-link)
-1
pkgs/applications/graphics/pinta/default.nix
··· 26 26 # How-to update deps: 27 27 # $ nix-build -A pinta.fetch-deps 28 28 # $ ./result 29 - # $ cp /tmp/Pinta-deps.nix ./pkgs/applications/graphics/pinta/deps.nix 30 29 # TODO: create update script 31 30 nugetDeps = ./deps.nix; 32 31
+1 -3
pkgs/applications/misc/ArchiSteamFarm/update.sh
··· 3 3 set -euo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - deps_file="$(realpath ./deps.nix)" 7 - 8 6 new_version="$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} -s "https://api.github.com/repos/JustArchiNET/ArchiSteamFarm/releases" | jq -r 'map(select(.prerelease == false)) | .[0].tag_name')" 9 7 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" 10 8 ··· 22 20 update-source-version ArchiSteamFarm "$new_version" 23 21 fi 24 22 25 - $(nix-build -A ArchiSteamFarm.fetch-deps --no-out-link) "$deps_file" 23 + $(nix-build -A ArchiSteamFarm.fetch-deps --no-out-link) 26 24 27 25 popd 28 26 "$asf_path/web-ui/update.sh"
+1 -2
pkgs/applications/version-management/git-credential-manager/update.sh
··· 20 20 sed -i -Ee "s/hash = \"sha256-[A-Za-z0-9=]{44}\"/hash = \"${hash}\"/" default.nix 21 21 22 22 23 - nugetDeps="$(realpath ./deps.nix)" 24 - $(nix-build ../../../.. -A git-credential-manager.fetch-deps --no-out-link) "$nugetDeps" 23 + $(nix-build ../../../.. -A git-credential-manager.fetch-deps --no-out-link)
+1 -1
pkgs/development/tools/continuous-integration/github-runner/update.sh
··· 15 15 fi 16 16 17 17 update-source-version github-runner "$latestVersion" 18 - $(nix-build -A github-runner.fetch-deps --no-out-link) "$(dirname "$BASH_SOURCE")/deps.nix" 18 + $(nix-build -A github-runner.fetch-deps --no-out-link) 19 19
+1 -1
pkgs/development/tools/marksman/update.sh
··· 15 15 16 16 update-source-version marksman "$version" 17 17 18 - $(nix-build -A marksman.fetch-deps --no-out-link) "$(dirname -- "${BASH_SOURCE[0]}")/deps.nix" 18 + $(nix-build -A marksman.fetch-deps --no-out-link)
+1 -3
pkgs/development/tools/omnisharp-roslyn/updater.sh
··· 6 6 7 7 cd "$(dirname "${BASH_SOURCE[0]}")" 8 8 9 - deps_file="$(realpath "./deps.nix")" 10 - 11 9 new_version="$(curl -s "https://api.github.com/repos/OmniSharp/omnisharp-roslyn/releases?per_page=1" | jq -r '.[0].name')" 12 10 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" 13 11 ··· 19 17 cd ../../../.. 20 18 update-source-version omnisharp-roslyn "${new_version//v}" 21 19 22 - $(nix-build -A omnisharp-roslyn.fetch-deps --no-out-link) "$deps_file" 20 + $(nix-build -A omnisharp-roslyn.fetch-deps --no-out-link)
+1 -3
pkgs/games/osu-lazer/update.sh
··· 3 3 set -eo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - deps_file="$(realpath "./deps.nix")" 7 - 8 6 new_version="$(curl -s "https://api.github.com/repos/ppy/osu/releases?per_page=1" | jq -r '.[0].name')" 9 7 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" 10 8 if [[ "$new_version" == "$old_version" ]]; then ··· 18 16 update-source-version osu-lazer "$new_version" 19 17 fi 20 18 21 - $(nix-build . -A osu-lazer.fetch-deps --no-out-link) "$deps_file" 19 + $(nix-build . -A osu-lazer.fetch-deps --no-out-link)
+1 -3
pkgs/games/space-station-14-launcher/update.sh
··· 3 3 set -eo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - deps_file="$(realpath "./deps.nix")" 7 - 8 6 new_version="$(curl -s "https://api.github.com/repos/space-wizards/SS14.Launcher/releases?per_page=1" | jq -r '.[0].tag_name' | sed 's/v//')" 9 7 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./space-station-14-launcher.nix)" 10 8 ··· 15 13 16 14 cd ../../.. 17 15 update-source-version space-station-14-launcher.unwrapped "$new_version" 18 - $(nix-build -A space-station-14-launcher.fetch-deps --no-out-link) "$deps_file" 16 + $(nix-build -A space-station-14-launcher.fetch-deps --no-out-link)
+1 -3
pkgs/servers/jackett/updater.sh
··· 3 3 set -eo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - deps_file="$(realpath "./deps.nix")" 7 - 8 6 new_version="$(curl -s "https://api.github.com/repos/jackett/jackett/releases?per_page=1" | jq -r '.[0].name')" 9 7 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" 10 8 ··· 15 13 16 14 cd ../../.. 17 15 update-source-version jackett "${new_version//v}" 18 - $(nix-build -A jackett.fetch-deps --no-out-link) "$deps_file" 16 + $(nix-build -A jackett.fetch-deps --no-out-link)
+1 -5
pkgs/servers/jellyfin/update.sh
··· 11 11 exit 0 12 12 fi 13 13 14 - pushd "$(dirname "${BASH_SOURCE[0]}")" 15 - nugetDepsFile=$(realpath ./nuget-deps.nix) 16 - popd 17 - 18 14 update-source-version jellyfin "$latestVersion" 19 15 20 - $(nix-build . -A jellyfin.fetch-deps --no-out-link) "$nugetDepsFile" 16 + $(nix-build . -A jellyfin.fetch-deps --no-out-link)
+1 -3
pkgs/servers/nosql/eventstore/updater.sh
··· 6 6 7 7 cd "$(dirname "${BASH_SOURCE[0]}")" 8 8 9 - deps_file="$(realpath "./deps.nix")" 10 - 11 9 new_version="$(curl -s "https://api.github.com/repos/EventStore/EventStore/releases/latest" | jq -r '.name')" 12 10 new_version="${new_version#oss-v}" 13 11 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" ··· 20 18 cd ../../../.. 21 19 update-source-version eventstore "${new_version//v}" 22 20 23 - $(nix-build -A eventstore.fetch-deps --no-out-link) "$deps_file" 21 + $(nix-build -A eventstore.fetch-deps --no-out-link)
+1 -3
pkgs/tools/X11/opentabletdriver/update.sh
··· 3 3 set -eo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - deps_file="$(realpath "./deps.nix")" 7 - 8 6 new_version="$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} -s "https://api.github.com/repos/OpenTabletDriver/OpenTabletDriver/releases" | jq -r 'map(select(.prerelease == false)) | .[0].tag_name' | cut -c2-)" 9 7 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" 10 8 ··· 23 21 24 22 pushd ../../../.. 25 23 update-source-version opentabletdriver "$new_version" 26 - $(nix-build -A opentabletdriver.fetch-deps --no-out-link) "$deps_file" 24 + $(nix-build -A opentabletdriver.fetch-deps --no-out-link)
+1 -3
pkgs/tools/backup/discordchatexporter-cli/updater.sh
··· 3 3 set -eo pipefail 4 4 cd "$(dirname "${BASH_SOURCE[0]}")" 5 5 6 - deps_file="$(realpath "./deps.nix")" 7 - 8 6 new_version="$(curl -s "https://api.github.com/repos/tyrrrz/DiscordChatExporter/releases?per_page=1" | jq -r '.[0].name')" 9 7 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)" 10 8 if [[ "$new_version" == "$old_version" ]]; then ··· 14 12 15 13 cd ../../../.. 16 14 update-source-version discordchatexporter-cli "$new_version" 17 - $(nix-build -A discordchatexporter-cli.fetch-deps --no-out-link) "$deps_file" 15 + $(nix-build -A discordchatexporter-cli.fetch-deps --no-out-link)
+1 -2
pkgs/tools/misc/depotdownloader/update.sh
··· 3 3 4 4 set -eou pipefail 5 5 6 - depsFile="$(realpath "$(dirname "${BASH_SOURCE[0]}")/deps.nix")" 7 6 currentVersion="$(nix eval --raw -f . depotdownloader.version)" 8 7 latestVersion="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/SteamRE/DepotDownloader/releases?per_page=1" \ 9 8 | jq -r '.[].name' | cut -d' ' -f2)" ··· 14 13 fi 15 14 16 15 update-source-version depotdownloader "$latestVersion" 17 - $(nix-build -A depotdownloader.fetch-deps --no-out-link) "$depsFile" 16 + $(nix-build -A depotdownloader.fetch-deps --no-out-link)