opened 09:23AM - 14 Feb 23 UTC
0.kind: packaging request
One thing we're missing for .NET is declarative installation of global tools.
…
# Introduction
.NET has [dotnet tool](https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools), which allows to install .net tools distributed through nuget package format. Each tool can be installed locally and globally. While locally makes sense for tools which should be available within a project, naturally, globally installed tools mutate the system, and we would like to avoid that. Moreover, even mutably installed global tools [don't seem to work](https://github.com/dotnet/sdk/issues/30546).
# How it should be
I think, it would be nice to make it like python's `withPackages`:
```nix
packages = [
(
with dotnetCorePackages; (combinePackages [
sdk_7_0
sdk_6_0
]).withTools [
dotnet-repl # this is a "global" tool
fsautocomplete
];
)
]
```
Then adding and removing them would be a no-brainer
# My Proof of Concept
I wrote a [proof of concept](https://github.com/WhiteBlackGoose/dotfiles/blob/3f7d1b508f75ea87b8f36f3e2be0e2db1f4241c1/envs/dotnet-tool.nix) on how it could work by faking global tools, which otherwise [I didn't manage to run](https://github.com/dotnet/sdk/issues/30546), and the syntax looks like:
## Example of usage
```nix
packages =
let dotnetPkg =
(with dotnetCorePackages; combinePackages [
sdk_7_0
sdk_6_0
]);
dotnetTools = (callPackage ./dotnet-tool.nix {}); # dotnet-tool.nix is the file from the link above
in [
vim
firefox
dotnetPkg
dotnetTools.combineTools dotnetPkg (with dotnetTools.tools; [
# ^^^^^^^^^ here we specify the dotnet package
# that will be invoked for this tool
# Ideally, something like dotnetPkg.withTools
# should be there
fsautocomplete # these are tools from dotnetTools.tools;
csharp-ls # if a package is missing, it can be declared
dotnet-repl # manually, see the sources of dotnet-tools.nix
])
];
```
(it's an example how it could work)
## How tools can be packed
Here's an example how a tool can be packed:
```nix
dotnet-repl = rec {
bin-name = "dotnet-repl";
nuget-name = bin-name;
dll-name = bin-name;
version = "0.1.192"; arch = "net7.0/any";
sha256 = "sha256-iQBBPY/Bg+pcQDkKzpIFHoipts3/+b23mgjjw9a+cNM=";
};
```
# Thoughts?
This isn't really a package request, but a place to discuss *how* to package dotnet tools properly.
@gbtb you seem to have knowledge on the topic, your input is appreciated. I noticed [your PR](https://github.com/NixOS/nixpkgs/pull/206407) and thought, that it would be nice if we didn't have to add dotnet tools as packages separately.