···123* `dotnetPackFlags` can be used to pass flags to `dotnet pack`. Used only if `packNupkg` is set to `true`.
124* `dotnetFlags` can be used to pass flags to all of the above phases.
125126-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.
127128Here is an example `default.nix`, using some of the previously discussed arguments:
129```nix
···123* `dotnetPackFlags` can be used to pass flags to `dotnet pack`. Used only if `packNupkg` is set to `true`.
124* `dotnetFlags` can be used to pass flags to all of the above phases.
125126+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.
127128Here is an example `default.nix`, using some of the previously discussed arguments:
129```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+}
···9trap 'echo "Error at ${BASH_SOURCE[0]}:$LINENO"' ERR
1011pkgName=$1
12-depsFile=$2
1314: ${getVersionFromTags:=}
15: ${refetch:=}
···41if [[ $newVersion == $oldVersion && ! $refetch ]]; then
42 echo "nixpkgs already has the latest version $newVersion"
43 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."
45 exit 0
46fi
47···74echo
7576# Create deps file
77-$(nix-build "$nixpkgs" -A $pkgName.fetch-deps --no-out-link) "$depsFile"
···9trap 'echo "Error at ${BASH_SOURCE[0]}:$LINENO"' ERR
1011pkgName=$1
01213: ${getVersionFromTags:=}
14: ${refetch:=}
···40if [[ $newVersion == $oldVersion && ! $refetch ]]; then
41 echo "nixpkgs already has the latest version $newVersion"
42 echo "Run this script with env var refetch=1 to re-verify the content hash via GPG"
43+ echo "and to recreate deps.nix. This is useful for reviewing a version update."
44 exit 0
45fi
46···73echo
7475# Create deps file
76+$(nix-build "$nixpkgs" -A $pkgName.fetch-deps --no-out-link)
+1-3
pkgs/applications/emulators/ryujinx/updater.sh
···3set -euo pipefail
4cd "$(dirname "${BASH_SOURCE[0]}")"
56-DEPS_FILE="$(realpath "./deps.nix")"
7-8# provide a github token so you don't get rate limited
9# if you use gh cli you can use:
10# `export GITHUB_TOKEN="$(cat ~/.config/gh/config.yml | yq '.hosts."github.com".oauth_token' -r)"`
···7576echo "building Nuget lockfile"
7778-$(nix-build -A ryujinx.fetch-deps --no-out-link) "$DEPS_FILE"
···3set -euo pipefail
4cd "$(dirname "${BASH_SOURCE[0]}")"
5006# provide a github token so you don't get rate limited
7# if you use gh cli you can use:
8# `export GITHUB_TOKEN="$(cat ~/.config/gh/config.yml | yq '.hosts."github.com".oauth_token' -r)"`
···7374echo "building Nuget lockfile"
7576+$(nix-build -A ryujinx.fetch-deps --no-out-link)