!bxVOQwsVoHhZcmNDGw:nixos.org

Nix + dotnet

99 Members
22 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
10 Apr 2025
@anselmetombarel:matrix.organselmetombarel joined the room.14:47:27
@magikarpz:matrix.org@magikarpz:matrix.org

can somebody with commit permissions take a look at this PR? https://github.com/NixOS/nixpkgs/pull/257489

I'd really want to get going on removing the deprecated buildDotnetPackage stuff, and this PR was blocking it for quite some time

20:54:02
@sandro:supersandro.deSandro 🐧 the right room for that is #review-requests:nixos.org 22:51:51
19 Apr 2025
@corruptcomputer:matrix.orgcorruptcomputer joined the room.02:47:34
@corruptcomputer:matrix.orgcorruptcomputer

Could someone please help me figure out how to get the dotnet sdk to work on NixOS? Neither wiki has any usable information on getting this setup, so I've basically just guessed at which packages I found when searching for 'dotnet' on search.nixos.org were the correct ones. The names of these seemed the most correct to me and thats all I picked based on, so if these aren't right please let me know

I have the following in my configuration.nix (removed the unrelated parts):

environment = {
  sessionVariables = {
    DOTNET_ROOT = "${pkgs.dotnet-sdk_9}/share/dotnet/";
  };
  
  systemPackages = with pkgs; [
    dotnet-aspnetcore_9
    dotnet-runtime_9
    dotnet-sdk_9
  ];
};

I've added the dotnet-sdk_9 dotnet root since the wiki said thats what to do if its not found, but that doesn't seem to have any effect. Its still not able to access the sdk unless I cd to that dir and use the filesystem local dotnet instead of the system one:

[ngupton@armadillo:~]$ dotnet --list-runtimes
Microsoft.AspNetCore.App 9.0.3 [/nix/store/7vpnwiiqjhlqg0d1ar7vk3fdis39xzlp-aspnetcore-runtime-9.0.3/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.3 [/nix/store/7vpnwiiqjhlqg0d1ar7vk3fdis39xzlp-aspnetcore-runtime-9.0.3/share/dotnet/shared/Microsoft.NETCore.App]

[ngupton@armadillo:~]$ dotnet --list-sdks

[ngupton@armadillo:~]$ cd $DOTNET_ROOT

[ngupton@armadillo:/nix/store/6p8ca1aaj3hpswi1b12si274kf550hk1-dotnet-sdk-wrapped-9.0.202/share/dotnet]$ ./dotnet --list-sdks
9.0.202 [/nix/store/h7yk3aivlacy0c0d87ivg7fhvpxkmr44-dotnet-sdk-9.0.202/share/dotnet/sdk]
03:14:52
@corruptcomputer:matrix.orgcorruptcomputer *

Could someone please help me figure out how to get the dotnet sdk to work on NixOS? Neither wiki has any usable information on getting this setup, seems to assume you're trying to build a dotnet nix package instead of actually use dotnet on your system. So I've basically just guessed at which packages I found when searching for 'dotnet' on search.nixos.org were the correct ones. The names of these seemed the most correct to me and thats all I picked based on, so if these aren't right please let me know

I have the following in my configuration.nix (removed the unrelated parts):

environment = {
  sessionVariables = {
    DOTNET_ROOT = "${pkgs.dotnet-sdk_9}/share/dotnet/";
  };
  
  systemPackages = with pkgs; [
    dotnet-aspnetcore_9
    dotnet-runtime_9
    dotnet-sdk_9
  ];
};

I've added the dotnet-sdk_9 dotnet root since the wiki said thats what to do if its not found, but that doesn't seem to have any effect. Its still not able to access the sdk unless I cd to that dir and use the filesystem local dotnet instead of the system one:

[ngupton@armadillo:~]$ dotnet --list-runtimes
Microsoft.AspNetCore.App 9.0.3 [/nix/store/7vpnwiiqjhlqg0d1ar7vk3fdis39xzlp-aspnetcore-runtime-9.0.3/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.3 [/nix/store/7vpnwiiqjhlqg0d1ar7vk3fdis39xzlp-aspnetcore-runtime-9.0.3/share/dotnet/shared/Microsoft.NETCore.App]

[ngupton@armadillo:~]$ dotnet --list-sdks

[ngupton@armadillo:~]$ cd $DOTNET_ROOT

[ngupton@armadillo:/nix/store/6p8ca1aaj3hpswi1b12si274kf550hk1-dotnet-sdk-wrapped-9.0.202/share/dotnet]$ ./dotnet --list-sdks
9.0.202 [/nix/store/h7yk3aivlacy0c0d87ivg7fhvpxkmr44-dotnet-sdk-9.0.202/share/dotnet/sdk]
03:22:11
@corruptcomputer:matrix.orgcorruptcomputer

Ah finally got it figured out, changing the packages to the following fixed it

systemPackages = with pkgs; [
  (with dotnetCorePackages; combinePackages [dotnet_9.sdk dotnet_8.sdk])
];
07:38:26
@gggkiller:matrix.orgGGGyou actually need to have the SDK and no runtimes08:10:20
@gggkiller:matrix.orgGGG

corruptcomputer: ```
environment = let
dotnet-sdk = with dotnetCorePackages; combinePackages [ sdk_9_0 sdk_8_0 ];
dotnetRoot = "${dotnet-sdk}/share/dotnet";
in {
etc = {
"dotnet/install_location".text = dotnetRoot;
};

systemPackages = with pkgs; [
dotnet-sdk
];
};

08:13:21
@gggkiller:matrix.orgGGG *

corruptcomputer:

environment = let
dotnet-sdk = with dotnetCorePackages; combinePackages \[ sdk\_9\_0 sdk\_8\_0 \];
dotnetRoot = "${dotnet-sdk}/share/dotnet";
in {
etc = {
"dotnet/install\_location".text = dotnetRoot;
};

systemPackages = with pkgs; \[
dotnet-sdk
\];
};
08:13:27
@gggkiller:matrix.orgGGG *

corruptcomputer:

environment = let
  dotnet-sdk = with dotnetCorePackages; combinePackages [ sdk_9_0 sdk_8_0 ];
  dotnetRoot = "${dotnet-sdk}/share/dotnet";
in {
  etc = {
    "dotnet/install\_location".text = dotnetRoot;
  };

  systemPackages = with pkgs; [
    dotnet-sdk
  ];
};

this is what I do in my config: https://github.com/GGG-KILLER/nixos-configs/blob/3553a0247d667bd3d83937e52d63625ba592c1c5/hosts/sora/system/programs/default.nix#L10-L18

08:14:02
@gggkiller:matrix.orgGGG *

corruptcomputer:

environment = let
  dotnet-sdk = with dotnetCorePackages; combinePackages [ sdk_9_0 sdk_8_0 ];
  dotnetRoot = "${dotnet-sdk}/share/dotnet";
in {
  etc = {
    "dotnet/install_location".text = dotnetRoot;
  };

  systemPackages = with pkgs; [
    dotnet-sdk
  ];
};

this is what I do in my config: https://github.com/GGG-KILLER/nixos-configs/blob/3553a0247d667bd3d83937e52d63625ba592c1c5/hosts/sora/system/programs/default.nix#L10-L18

08:14:11
@upidapi:matrix.orgupidapi joined the room.17:01:44
21 Apr 2025
@corruptcomputer:matrix.orgcorruptcomputerIs that the most up to date way to do it? I saw this on the Wiki from about a week ago and this is what I had based my change on: https://discourse.nixos.org/t/dotnet-maui-workload/20370/24 There really isn't a ton of documentation around dotnet so I'm really not sure what the best way to do it is, and according to other folks on this same forum discussion for it isn't possible to update? Not really sure how thats the case when its a wiki22:54:43
@corruptcomputer:matrix.orgcorruptcomputer* Is that the most up to date way to do it? I saw this on the forum from about a week ago and this is what I had based my change on: https://discourse.nixos.org/t/dotnet-maui-workload/20370/24 There really isn't a ton of documentation around dotnet so I'm really not sure what the best way to do it is, and according to other folks on this same forum discussion for it isn't possible to update? Not really sure how thats the case when its a wiki22:54:52
@gggkiller:matrix.orgGGG it is the way I use myself. I prefer using a file in /etc because env vars require restarting your window manager or something similar to update them 22:55:18
@gggkiller:matrix.orgGGG but you shouldn't mix sdk_X_Y, runtime_X_Y, aspnetcore_X_Y packages ever 22:55:38
@gggkiller:matrix.orgGGGyou pick one of the three and use that for that version22:55:48
@gggkiller:matrix.orgGGG * it is the way I use myself. I prefer using a file in /etc because env vars require restarting your desktop manager or something similar to update them 22:55:57
@corruptcomputer:matrix.orgcorruptcomputerI need all 3 of them though, I'm developing aspnetcore and desktop applications, so I need to be able to both compile with the sdk and run with the runtime or aspnetcore runtime 22:56:40
@gggkiller:matrix.orgGGGthe SDK comes with the runtime and aspnetcore22:56:49
@gggkiller:matrix.orgGGGaspnetcore comes with the runtime22:56:53
@gggkiller:matrix.orgGGGruntime is just the runtime22:56:56
@corruptcomputer:matrix.orgcorruptcomputerAh ok, didn't realize that. Thats a lot different than I'm familiar with on Arch, on Arch you need to install all 3 separately 22:57:25
@corruptcomputer:matrix.orgcorruptcomputerdoes the sdk_X_Y support only specifying the major version? I'd like to always stay up to date with the latest minor version and just pick the major that I'm using 22:59:04
@corruptcomputer:matrix.orgcorruptcomputerlike sdk_9 or sdk_8 I mean, instead of needing sdk_9_202 or whatever the minor version is22:59:37
@corruptcomputer:matrix.orgcorruptcomputercould see it being very annoying to constantly be updating that 22:59:50
@gggkiller:matrix.orgGGG we don't currently have an option to stick to latest minor, the dotnet_9.sdk is just sdk_9_0 22:59:53
@gggkiller:matrix.orgGGG202 is the patch, so the actual version is 9.0.20223:00:06
@corruptcomputer:matrix.orgcorruptcomputerAh ok so sdk_9_0 will still get me the latest then, thanks!23:00:45

Show newer messages


Back to Room ListRoom Version: 9