diff options
author | IvarWithoutBones <ivar.scholten@protonmail.com> | 2021-09-23 21:40:09 +0200 |
---|---|---|
committer | IvarWithoutBones <ivar.scholten@protonmail.com> | 2021-10-06 22:14:24 +0200 |
commit | a87e6645dd580baac85314fceb67431293054fec (patch) | |
tree | 0861510d559600f10be3a1de8a778b927092f3ff /doc | |
parent | b41e7b572ca46d906cdf976c0db1c924e63bc6ab (diff) | |
download | nixlib-a87e6645dd580baac85314fceb67431293054fec.tar nixlib-a87e6645dd580baac85314fceb67431293054fec.tar.gz nixlib-a87e6645dd580baac85314fceb67431293054fec.tar.bz2 nixlib-a87e6645dd580baac85314fceb67431293054fec.tar.lz nixlib-a87e6645dd580baac85314fceb67431293054fec.tar.xz nixlib-a87e6645dd580baac85314fceb67431293054fec.tar.zst nixlib-a87e6645dd580baac85314fceb67431293054fec.zip |
buildDotnetModule: add documentation
Diffstat (limited to 'doc')
-rw-r--r-- | doc/languages-frameworks/dotnet.section.md | 38 | ||||
-rw-r--r-- | doc/languages-frameworks/index.xml | 1 |
2 files changed, 37 insertions, 2 deletions
diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md index 1bcb6e45210e..738d7bad271e 100644 --- a/doc/languages-frameworks/dotnet.section.md +++ b/doc/languages-frameworks/dotnet.section.md @@ -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: + +* `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`. -TODO: Create closure-friendly way to package dotnet applications + 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`. +} +``` diff --git a/doc/languages-frameworks/index.xml b/doc/languages-frameworks/index.xml index b010f27cac02..f221693e764c 100644 --- a/doc/languages-frameworks/index.xml +++ b/doc/languages-frameworks/index.xml @@ -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" /> |