buildDotnetModule: add documentation
This commit is contained in:
parent
b41e7b572c
commit
a87e6645dd
@ -70,6 +70,40 @@ The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given
|
||||
|
||||
## Packaging a Dotnet Application {#packaging-a-dotnet-application}
|
||||
|
||||
Ideally, we would like to build against the sdk, then only have the dotnet runtime available in the runtime closure.
|
||||
To package Dotnet applications, you can use `buildDotnetModule`. This has similar arguments to `stdenv.mkDerivation`, with the following additions:
|
||||
|
||||
TODO: Create closure-friendly way to package dotnet applications
|
||||
* `projectFile` has to be used for specifying the dotnet project file relative to the source root. These usually have `.sln` or `.csproj` file extensions.
|
||||
* `nugetDeps` has to be used to specify the NuGet dependency file. Unfortunately, these cannot be deterministically fetched without a lockfile. This file should be generated using `nuget-to-nix` tool, which is available in nixpkgs.
|
||||
* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`.
|
||||
* `runtimeDeps` is used to wrap libraries into `LD_LIBRARY_PATH`. This is how dotnet usually handles runtime dependencies.
|
||||
* `buildType` is used to change the type of build. Possible values are `Release`, `Debug`, etc. By default, this is set to `Release`.
|
||||
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used.
|
||||
* `dotnet-runtime` is useful in cases where you need to change what dotnet runtime is being used.
|
||||
* `dotnetRestoreFlags` can be used to pass flags to `dotnet restore`.
|
||||
* `dotnetBuildFlags` can be used to pass flags to `dotnet build`.
|
||||
* `dotnetInstallFlags` can be used to pass flags to `dotnet install`.
|
||||
* `dotnetFlags` can be used to pass flags to all of the above phases.
|
||||
|
||||
Here is an example `default.nix`, using some of the previously discussed arguments:
|
||||
```nix
|
||||
{ lib, buildDotnetModule, dotnetCorePackages, ffmpeg }:
|
||||
|
||||
buildDotnetModule rec {
|
||||
pname = "someDotnetApplication";
|
||||
version = "0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
projectFile = "src/project.sln";
|
||||
nugetDeps = ./deps.nix; # File generated with `nuget-to-nix path/to/src > deps.nix`.
|
||||
|
||||
dotnet-sdk = dotnetCorePackages.sdk_3_1;
|
||||
dotnet-runtime = dotnetCorePackages.net_5_0;
|
||||
dotnetFlags = [ "--runtime linux-x64" ];
|
||||
|
||||
executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`.
|
||||
executables = []; # Don't install any executables.
|
||||
|
||||
runtimeDeps = [ ffmpeg ]; # This will wrap ffmpeg's library path into `LD_LIBRARY_PATH`.
|
||||
}
|
||||
```
|
||||
|
@ -12,6 +12,7 @@
|
||||
<xi:include href="coq.section.xml" />
|
||||
<xi:include href="crystal.section.xml" />
|
||||
<xi:include href="dhall.section.xml" />
|
||||
<xi:include href="dotnet.section.xml" />
|
||||
<xi:include href="emscripten.section.xml" />
|
||||
<xi:include href="gnome.section.xml" />
|
||||
<xi:include href="go.section.xml" />
|
||||
|
Loading…
Reference in New Issue
Block a user