diff options
author | Kevin Cox <kevincox@kevincox.ca> | 2021-10-12 09:13:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 09:13:44 -0400 |
commit | f6e161d60a0549a7e2077929e474b555d884f528 (patch) | |
tree | 135259cb0ae88841b534aa18544c860f14d1153f /doc | |
parent | f8d52833c31e4c93cac0f6ac8b98b662eb1584c9 (diff) | |
parent | e93d52e69eb438ca45ab8dc3b2bead4d18ade8fd (diff) | |
download | nixlib-f6e161d60a0549a7e2077929e474b555d884f528.tar nixlib-f6e161d60a0549a7e2077929e474b555d884f528.tar.gz nixlib-f6e161d60a0549a7e2077929e474b555d884f528.tar.bz2 nixlib-f6e161d60a0549a7e2077929e474b555d884f528.tar.lz nixlib-f6e161d60a0549a7e2077929e474b555d884f528.tar.xz nixlib-f6e161d60a0549a7e2077929e474b555d884f528.tar.zst nixlib-f6e161d60a0549a7e2077929e474b555d884f528.zip |
Merge pull request #139222 from IvarWithoutBones/init/buildDotnet
buildDotnetModule: init
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" /> |