···
···
, enableParallelBuilding ? true
23
-
# Flags to pass to `makeWrapper`. This is done to avoid double wrapping.
24
-
, makeWrapperArgs ? []
23
+
# Flags to pass to `makeWrapper`. This is done to avoid double wrapping.
24
+
, makeWrapperArgs ? [ ]
26
-
# Flags to pass to `dotnet restore`.
27
-
, dotnetRestoreFlags ? []
28
-
# Flags to pass to `dotnet build`.
29
-
, dotnetBuildFlags ? []
30
-
# Flags to pass to `dotnet test`, if running tests is enabled.
31
-
, dotnetTestFlags ? []
32
-
# Flags to pass to `dotnet install`.
33
-
, dotnetInstallFlags ? []
34
-
# Flags to pass to `dotnet pack`.
35
-
, dotnetPackFlags ? []
36
-
# Flags to pass to dotnet in all phases.
26
+
# Flags to pass to `dotnet restore`.
27
+
, dotnetRestoreFlags ? [ ]
28
+
# Flags to pass to `dotnet build`.
29
+
, dotnetBuildFlags ? [ ]
30
+
# Flags to pass to `dotnet test`, if running tests is enabled.
31
+
, dotnetTestFlags ? [ ]
32
+
# Flags to pass to `dotnet install`.
33
+
, dotnetInstallFlags ? [ ]
34
+
# Flags to pass to `dotnet pack`.
35
+
, dotnetPackFlags ? [ ]
36
+
# Flags to pass to dotnet in all phases.
39
-
# The path to publish the project to. When unset, the directory "$out/lib/$pname" is used.
39
+
# The path to publish the project to. When unset, the directory "$out/lib/$pname" is used.
41
-
# The binaries that should get installed to `$out/bin`, relative to `$out/lib/$pname/`. These get wrapped accordingly.
42
-
# Unfortunately, dotnet has no method for doing this automatically.
43
-
# If unset, all executables in the projects root will get installed. This may cause bloat!
41
+
# The binaries that should get installed to `$out/bin`, relative to `$out/lib/$pname/`. These get wrapped accordingly.
42
+
# Unfortunately, dotnet has no method for doing this automatically.
43
+
# If unset, all executables in the projects root will get installed. This may cause bloat!
45
-
# Packs a project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`.
45
+
# Packs a project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`.
47
-
# The packages project file, which contains instructions on how to compile it. This can be an array of multiple project files as well.
47
+
# The packages project file, which contains instructions on how to compile it. This can be an array of multiple project files as well.
49
-
# The NuGet dependency file. This locks all NuGet dependency versions, as otherwise they cannot be deterministically fetched.
50
-
# This can be generated by running the `passthru.fetch-deps` script.
49
+
# The NuGet dependency file. This locks all NuGet dependency versions, as otherwise they cannot be deterministically fetched.
50
+
# This can be generated by running the `passthru.fetch-deps` script.
52
-
# A list of derivations containing nupkg packages for local project references.
53
-
# Referenced derivations can be built with `buildDotnetModule` with `packNupkg=true` flag.
54
-
# Since we are sharing them as nugets they must be added to csproj/fsproj files as `PackageReference` as well.
55
-
# For example, your project has a local dependency:
56
-
# <ProjectReference Include="../foo/bar.fsproj" />
57
-
# To enable discovery through `projectReferences` you would need to add a line:
58
-
# <ProjectReference Include="../foo/bar.fsproj" />
59
-
# <PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
60
-
, projectReferences ? []
61
-
# Libraries that need to be available at runtime should be passed through this.
62
-
# These get wrapped into `LD_LIBRARY_PATH`.
52
+
# A list of derivations containing nupkg packages for local project references.
53
+
# Referenced derivations can be built with `buildDotnetModule` with `packNupkg=true` flag.
54
+
# Since we are sharing them as nugets they must be added to csproj/fsproj files as `PackageReference` as well.
55
+
# For example, your project has a local dependency:
56
+
# <ProjectReference Include="../foo/bar.fsproj" />
57
+
# To enable discovery through `projectReferences` you would need to add a line:
58
+
# <ProjectReference Include="../foo/bar.fsproj" />
59
+
# <PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
60
+
, projectReferences ? [ ]
61
+
# Libraries that need to be available at runtime should be passed through this.
62
+
# These get wrapped into `LD_LIBRARY_PATH`.
65
-
# Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks.
66
-
# See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details.
67
-
, disabledTests ? []
68
-
# The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set.
69
-
# It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this.
65
+
# Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks.
66
+
# See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details.
67
+
, disabledTests ? [ ]
68
+
# The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set.
69
+
# It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this.
72
-
# The type of build to perform. This is passed to `dotnet` with the `--configuration` flag. Possible values are `Release`, `Debug`, etc.
72
+
# The type of build to perform. This is passed to `dotnet` with the `--configuration` flag. Possible values are `Release`, `Debug`, etc.
74
-
# If set to true, builds the application as a self-contained - removing the runtime dependency on dotnet
74
+
# If set to true, builds the application as a self-contained - removing the runtime dependency on dotnet
, selfContainedBuild ? false
76
-
# The dotnet SDK to use.
76
+
# The dotnet SDK to use.
, dotnet-sdk ? dotnetCorePackages.sdk_6_0
78
-
# The dotnet runtime to use.
78
+
# The dotnet runtime to use.
, dotnet-runtime ? dotnetCorePackages.runtime_6_0
80
-
# The dotnet SDK to run tests against. This can differentiate from the SDK compiled against.
80
+
# The dotnet SDK to run tests against. This can differentiate from the SDK compiled against.
, dotnet-test-sdk ? dotnet-sdk
assert projectFile == null -> throw "Defining the `projectFile` attribute is required. This is usually an `.csproj`, or `.sln` file.";
···
inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
}) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
95
-
localDeps = if (projectReferences != [])
97
+
if (projectReferences != [ ])
then linkFarmFromDrvs "${name}-project-references" projectReferences
99
-
_nugetDeps = if lib.isDerivation nugetDeps
102
+
if lib.isDerivation nugetDeps
else mkNugetDeps { inherit name; nugetDeps = import nugetDeps; };
···
name = "${name}-nuget-source";
paths = [ _dependenciesSource _sdkSource ];
127
-
in stdenvNoCC.mkDerivation (args // {
128
-
nativeBuildInputs = args.nativeBuildInputs or [] ++ [
131
+
stdenvNoCC.mkDerivation (args // {
132
+
nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [
···
154
-
# Because this list is rather long its put in its own store path to maintain readability of the generated script
155
-
exclusions = writeText "nuget-package-exclusions" (lib.concatStringsSep "\n" (dotnet-sdk.passthru.packages { fetchNuGet = attrs: attrs.pname; }));
159
+
# Because this list is rather long its put in its own store path to maintain readability of the generated script
160
+
exclusions = writeText "nuget-package-exclusions" (lib.concatStringsSep "\n" (dotnet-sdk.passthru.packages { fetchNuGet = attrs: attrs.pname; }));
157
-
runtimeIds = map (system: dotnet-sdk.systemToDotnetRid system) (args.meta.platforms or dotnet-sdk.meta.platforms);
162
+
runtimeIds = map (system: dotnet-sdk.systemToDotnetRid system) (args.meta.platforms or dotnet-sdk.meta.platforms);
159
-
# Derivations may set flags such as `--runtime <rid>` based on the host platform to avoid restoring/building nuget dependencies they dont have or dont need.
160
-
# This introduces an issue; In this script we loop over all platforms from `meta` and add the RID flag for it, as to fetch all required dependencies.
161
-
# The script would inherit the RID flag from the derivation based on the platform building the script, and set the flag for any iteration we do over the RIDs.
162
-
# That causes conflicts. To circumvent it we remove all occurances of the flag.
165
-
hasRid = flag: lib.any (v: v) (map (rid: lib.hasInfix rid flag) (lib.attrValues dotnet-sdk.runtimeIdentifierMap));
167
-
builtins.filter (flag: !(hasRid flag)) (dotnetFlags ++ dotnetRestoreFlags);
164
+
# Derivations may set flags such as `--runtime <rid>` based on the host platform to avoid restoring/building nuget dependencies they dont have or dont need.
165
+
# This introduces an issue; In this script we loop over all platforms from `meta` and add the RID flag for it, as to fetch all required dependencies.
166
+
# The script would inherit the RID flag from the derivation based on the platform building the script, and set the flag for any iteration we do over the RIDs.
167
+
# That causes conflicts. To circumvent it we remove all occurances of the flag.
170
+
hasRid = flag: lib.any (v: v) (map (rid: lib.hasInfix rid flag) (lib.attrValues dotnet-sdk.runtimeIdentifierMap));
172
+
builtins.filter (flag: !(hasRid flag)) (dotnetFlags ++ dotnetRestoreFlags);
169
-
in writeShellScript "fetch-${pname}-deps" ''
175
+
writeShellScript "fetch-${pname}-deps" ''
172
-
export PATH="${lib.makeBinPath [ coreutils dotnet-sdk nuget-to-nix ]}"
178
+
export PATH="${lib.makeBinPath [ coreutils dotnet-sdk nuget-to-nix ]}"
176
-
echo "usage: $0 <output path> [--help]"
177
-
echo " <output path> The path to write the lockfile to"
178
-
echo " --help Show this help message"
182
+
echo "usage: $0 <output path> [--help]"
183
+
echo " <output path> The path to write the lockfile to"
184
+
echo " --help Show this help message"
183
-
deps_file="$(realpath "''${1:-$(mktemp -t "${pname}-deps-XXXXXX.nix")}")"
184
-
export HOME=$(mktemp -td "${pname}-home-XXXXXX")
185
-
mkdir -p "$HOME/nuget_pkgs"
189
+
deps_file="$(realpath "''${1:-$(mktemp -t "${pname}-deps-XXXXXX.nix")}")"
190
+
export HOME=$(mktemp -td "${pname}-home-XXXXXX")
191
+
mkdir -p "$HOME/nuget_pkgs"
187
-
store_src="${srcOnly args}"
188
-
src="$(mktemp -td "${pname}-src-XXXXXX")"
189
-
cp -rT "$store_src" "$src"
191
-
trap "rm -rf $src $HOME" EXIT
193
+
store_src="${srcOnly args}"
194
+
src="$(mktemp -td "${pname}-src-XXXXXX")"
195
+
cp -rT "$store_src" "$src"
197
+
trap "rm -rf $src $HOME" EXIT
194
-
echo "Restoring project..."
200
+
echo "Restoring project..."
196
-
export DOTNET_NOLOGO=1
197
-
export DOTNET_CLI_TELEMETRY_OPTOUT=1
202
+
export DOTNET_NOLOGO=1
203
+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
199
-
for rid in "${lib.concatStringsSep "\" \"" runtimeIds}"; do
200
-
for project in "${lib.concatStringsSep "\" \"" ((lib.toList projectFile) ++ lib.optionals (testProjectFile != "") (lib.toList testProjectFile))}"; do
201
-
dotnet restore "$project" \
202
-
-p:ContinuousIntegrationBuild=true \
203
-
-p:Deterministic=true \
204
-
--packages "$HOME/nuget_pkgs" \
206
-
${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
207
-
${lib.optionalString (flags != []) (toString flags)}
205
+
for rid in "${lib.concatStringsSep "\" \"" runtimeIds}"; do
206
+
for project in "${lib.concatStringsSep "\" \"" ((lib.toList projectFile) ++ lib.optionals (testProjectFile != "") (lib.toList testProjectFile))}"; do
207
+
dotnet restore "$project" \
208
+
-p:ContinuousIntegrationBuild=true \
209
+
-p:Deterministic=true \
210
+
--packages "$HOME/nuget_pkgs" \
212
+
${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
213
+
${lib.optionalString (flags != []) (toString flags)}
211
-
echo "Succesfully restored project"
217
+
echo "Succesfully restored project"
213
-
echo "Writing lockfile..."
214
-
echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$deps_file"
215
-
nuget-to-nix "$HOME/nuget_pkgs" "${exclusions}" >> "$deps_file"
216
-
echo "Succesfully wrote lockfile to: $deps_file"
218
-
} // args.passthru or {};
219
+
echo "Writing lockfile..."
220
+
echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$deps_file"
221
+
nuget-to-nix "$HOME/nuget_pkgs" "${exclusions}" >> "$deps_file"
222
+
echo "Succesfully wrote lockfile to: $deps_file"
224
+
} // args.passthru or { };
platforms = dotnet-sdk.meta.platforms;
222
-
} // args.meta or {};
228
+
} // args.meta or { };