diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2021-10-12 18:01:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 18:01:50 +0000 |
commit | 0cb186d33d6600d3adf073ce45920f93088be5f0 (patch) | |
tree | 209a3424ef94c279fc52f8e950e2cd2e014017e1 /doc | |
parent | 9ae6a7c2a286cea45858da76006ea8998ce6ae63 (diff) | |
parent | a80f163b4903df58766469536ec48e5892ff06b4 (diff) | |
download | nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.tar nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.tar.gz nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.tar.bz2 nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.tar.lz nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.tar.xz nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.tar.zst nixlib-0cb186d33d6600d3adf073ce45920f93088be5f0.zip |
Merge staging-next into staging
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" /> |