mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
buildDotnetModule: use individual dependencies for nugetDeps
This commit is contained in:
parent
6c5a9e5a43
commit
cc9c59c478
@ -93,7 +93,7 @@ The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given
|
||||
To package Dotnet applications, you can use `buildDotnetModule`. This has similar arguments to `stdenv.mkDerivation`, with the following additions:
|
||||
|
||||
* `projectFile` is used for specifying the dotnet project file, relative to the source root. These have `.sln` (entire solution) or `.csproj` (single project) file extensions. This can be a list of multiple projects as well. When omitted, will attempt to find and build the solution (`.sln`). If running into problems, make sure to set it to a file (or a list of files) with the `.csproj` extension - building applications as entire solutions is not fully supported by the .NET CLI.
|
||||
* `nugetDeps` takes either a path to a `deps.nix` file, or a derivation. The `deps.nix` file can be generated using the script attached to `passthru.fetch-deps`. If the argument is a derivation, it will be used directly and assume it has the same output as `mkNugetDeps`.
|
||||
* `nugetDeps` takes either a path to a `deps.nix` file, or a derivation. The `deps.nix` file can be generated using the script attached to `passthru.fetch-deps`. For compatibility, if the argument is a list of derivations, they will be added to `buildInputs`.
|
||||
::: {.note}
|
||||
For more detail about managing the `deps.nix` file, see [Generating and updating NuGet dependencies](#generating-and-updating-nuget-dependencies)
|
||||
:::
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ buildDotnetModule, emptyDirectory, mkNugetDeps, dotnet-sdk }:
|
||||
{ buildDotnetModule, emptyDirectory, fetchNupkg, dotnet-sdk }:
|
||||
|
||||
{ pname
|
||||
, version
|
||||
@ -23,13 +23,15 @@ buildDotnetModule (args // {
|
||||
|
||||
src = emptyDirectory;
|
||||
|
||||
nugetDeps = mkNugetDeps {
|
||||
name = pname;
|
||||
nugetDeps = { fetchNuGet }: [
|
||||
(fetchNuGet { pname = nugetName; inherit version; sha256 = nugetSha256; hash = nugetHash; })
|
||||
] ++ (nugetDeps fetchNuGet);
|
||||
installable = true;
|
||||
};
|
||||
buildInputs = [
|
||||
(fetchNupkg {
|
||||
pname = nugetName;
|
||||
inherit version;
|
||||
sha256 = nugetSha256;
|
||||
hash = nugetHash;
|
||||
installable = true;
|
||||
})
|
||||
];
|
||||
|
||||
dotnetGlobalTool = true;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
writeShellScript,
|
||||
makeWrapper,
|
||||
dotnetCorePackages,
|
||||
mkNugetDeps,
|
||||
fetchNupkg,
|
||||
nuget-to-nix,
|
||||
cacert,
|
||||
unzip,
|
||||
@ -112,16 +112,16 @@ let
|
||||
_nugetDeps =
|
||||
if (nugetDeps != null) then
|
||||
if lib.isDerivation nugetDeps then
|
||||
[ nugetDeps ]
|
||||
else if lib.isList nugetDeps then
|
||||
nugetDeps
|
||||
else
|
||||
mkNugetDeps {
|
||||
inherit (finalAttrs.finalPackage) name;
|
||||
sourceFile = nugetDeps;
|
||||
}
|
||||
assert (lib.isPath nugetDeps);
|
||||
callPackage nugetDeps { fetchNuGet = fetchNupkg; }
|
||||
else
|
||||
throw "Defining the `nugetDeps` attribute is required, as to lock the NuGet dependencies. This file can be generated by running the `passthru.fetch-deps` script.";
|
||||
[ ];
|
||||
|
||||
nugetDepsFile = _nugetDeps.sourceFile;
|
||||
nugetDepsFile = if lib.isPath nugetDeps then nugetDeps else null;
|
||||
|
||||
inherit (dotnetCorePackages) systemToDotnetRid;
|
||||
in
|
||||
@ -183,13 +183,7 @@ let
|
||||
yq
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
args.buildInputs or [ ]
|
||||
++ [
|
||||
dotnet-sdk.packages
|
||||
_nugetDeps
|
||||
]
|
||||
++ projectReferences;
|
||||
buildInputs = args.buildInputs or [ ] ++ [ dotnet-sdk.packages ] ++ _nugetDeps ++ projectReferences;
|
||||
|
||||
# Parse the version attr into a format acceptable for the Version msbuild property
|
||||
# The actual version attr is saved in InformationalVersion, which accepts an arbitrary string
|
||||
@ -233,13 +227,13 @@ let
|
||||
{
|
||||
nugetDeps = _nugetDeps;
|
||||
}
|
||||
// lib.optionalAttrs (!lib.isDerivation nugetDeps) {
|
||||
// lib.optionalAttrs (nugetDeps == null || lib.isPath nugetDeps) {
|
||||
fetch-deps =
|
||||
let
|
||||
pkg = finalAttrs.finalPackage.overrideAttrs (
|
||||
old:
|
||||
{
|
||||
buildInputs = lib.remove _nugetDeps old.buildInputs;
|
||||
buildInputs = lib.subtractLists _nugetDeps old.buildInputs;
|
||||
keepNugetConfig = true;
|
||||
}
|
||||
// lib.optionalAttrs (runtimeId == null) {
|
||||
@ -258,7 +252,7 @@ let
|
||||
# Note that toString is necessary here as it results in the path at
|
||||
# eval time (i.e. to the file in your local Nixpkgs checkout) rather
|
||||
# than the Nix store path of the path after it's been imported.
|
||||
if lib.isPath nugetDepsFile && !lib.hasPrefix "${builtins.storeDir}/" (toString nugetDepsFile) then
|
||||
if lib.isPath nugetDeps && !lib.isStorePath nugetDepsFile then
|
||||
toString nugetDepsFile
|
||||
else
|
||||
''$(mktemp -t "${finalAttrs.pname ? finalAttrs.finalPackage.name}-deps-XXXXXX.nix")'';
|
||||
|
@ -38,8 +38,7 @@ buildPythonPackage {
|
||||
|
||||
buildInputs = [
|
||||
dotnetCorePackages.sdk_6_0.packages
|
||||
dotnet-build.nugetDeps
|
||||
];
|
||||
] ++ dotnet-build.nugetDeps;
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
|
@ -37,7 +37,7 @@ buildPythonPackage {
|
||||
--replace 'dynamic = ["version"]' 'version = "${version}"'
|
||||
'';
|
||||
|
||||
buildInputs = [ dotnet-build.nugetDeps ];
|
||||
buildInputs = dotnet-build.nugetDeps;
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
|
Loading…
Reference in New Issue
Block a user