Open JamieMagee opened 1 year ago
A mapping of .NET workload to NuGet packages required is here:
@mdarocha thanks!
@Smaug123 it looks like you had more success with dotnet workloads in https://github.com/Smaug123/nix-maui. Would you be interested in upstreaming your work to nixpkgs?
I'm afraid this isn't something I'd be happy to maintain - it mostly works but is definitely suboptimal and would probably be a decent amount of work to upstream.
If I'll find the time, I'll attempt to expand on @Smaug123's work
Since the dotnet workload installer now supports installing to a user directory, could it be possible to simply relocate the dotnet-sdk nixpkg to user space?
A possible spanner in the works: PublishAot pulls down some binaries from NuGet, and therefore fails out of the box on NixOS because the AOT compiler can't find the linker (or something like that, it's been a while). So there's always going to have to be some amount of Nix wrangling somewhere.
A possible spanner in the works: PublishAot pulls down some binaries from NuGet, and therefore fails out of the box on NixOS because the AOT compiler can't find the linker (or something like that, it's been a while). So there's always going to have to be some amount of Nix wrangling somewhere.
This makes me so very sad, I only recently started using NixOS and I am a .NET developer by trade, I want to daily drive this so badly :(
even if workloads are installed in user space they are still failing to build https://github.com/dotnet/sdk/issues/37706
does no solution to this exist?
Copied from: https://github.com/NixOS/nixpkgs/issues/325667
It is currently impossible to install .NET workloads on NixOS:
❯ dotnet workload install maui
Unhandled exception: System.IO.IOException: Read-only file system : '/nix/store/as1j1inzdjdaca6gdcfdr2bdsppgr3px-dotnet-sdk-8.0.300/metadata'
at System.IO.FileSystem.CreateDirectory(String fullPath, UnixFileMode unixCreateMode)
at System.IO.Directory.CreateDirectory(String path)
at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallerFactory.CanWriteToDotnetRoot(String dotnetDir)
at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallerFactory.GetWorkloadInstaller(IReporter reporter, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, VerbosityOptions verbosity, String userProfileDir, Boolean verifySignatures, INuGetPackageDownloader nugetPackageDownloader, String dotnetDir, String tempDirPath, PackageSourceLocation packageSourceLocation, RestoreActionConfig restoreActionConfig, Boolean elevationRequired, Boolean shouldLog)
at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand..ctor(ParseResult parseResult, IReporter reporter, IWorkloadResolverFactory workloadResolverFactory, IInstaller workloadInstaller, INuGetPackageDownloader nugetPackageDownloader, IWorkloadManifestUpdater workloadManifestUpdater, String tempDirPath, IReadOnlyCollection`1 workloadIds)
at Microsoft.DotNet.Cli.WorkloadInstallCommandParser.<>c.<ConstructCommand>b__6_0(ParseResult parseResult)
at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
Steps to reproduce the behavior:
environment.systemPackages = [ pkgs.dotnet-sdk_8 ];
dotnet workload install maui
dotnet workload install maui
should install the workload in a user-writeable location.
According to https://github.com/dotnet/sdk/pull/18823 this can be fixed by writing a file <DOTNET_ROOT>/metadata/workloads/<sdkfeatureband>/userlocal
. https://discourse.nixos.org/t/dotnet-maui-workload/20370 contains shell code examples how to do that.
@kuznero, @mdarocha
❯ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 6.9.7, NixOS, 24.05 (Uakari), 24.05.20240702.706eef5`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.18.4`
- channels(root): `"nixos"`
- nixpkgs: `/nix/store/0z4i8wyg3ymm7kkb1gk2wyh08x230c6z-source`
Add a :+1: reaction to issues you find important.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
@float3 take a look at workaround here, seems to work for some
thanks, it helped me with android workflow
@EmVee381 have you found a workaround? Could you please share? Safely I never got it to work on my nixos machine
@EmVee381 have you found a workaround? Could you please share? Safely I never got it to work on my nixos machine
i use devenv, but you can use it similar way
is it clear? it is just copy pasted from from your link :) it works for me very well, you just define overrieded package in between "let" block then use it as package in your derivation or shell.nix or anything and set environment variable DOTNET_ROOT edited: pkgs-stable is not needed it is another input for my devenv testing purposes :)
{ pkgs, lib, config, inputs, ... }:
let
pkgs-stable = import inputs.nixpkgs-stable { system = pkgs.stdenv.system; };
dotnet-combined = (with pkgs.dotnetCorePackages; combinePackages [
sdk_8_0
]).overrideAttrs (finalAttrs: previousAttrs: {
# This is needed to install workload in $HOME
# https://discourse.nixos.org/t/dotnet-maui-workload/20370/2
postBuild = (previousAttrs.postBuild or '''') + ''
for i in $out/sdk/*
do
i=$(basename $i)
length=$(printf "%s" "$i" | wc -c)
substring=$(printf "%s" "$i" | cut -c 1-$(expr $length - 2))
i="$substring""00"
mkdir -p $out/metadata/workloads/''${i/-*}
touch $out/metadata/workloads/''${i/-*}/userlocal
done
'';
});
in
rec
{
env.GREET = "avalonia";
env.DOTNET_ROOT = "${dotnet-combined}";
languages.dotnet.enable = true;
languages.dotnet.package = dotnet-combined;
packages = [
pkgs.git
pkgs.omnisharp-roslyn
];
}
Describe the bug
Since .NET 5.0, .NET has shipped as a 'slim' SDK with support for optional workloads^1. Optional workloads are expected to be installed by the user.
Steps To Reproduce
Steps to reproduce the behavior:
nix-shell -p dotnet-sdk_6
dotnet workload install android
Error
Expected behavior
Workloads to be enabled using nix configuration
Screenshots
N/A
Additional context
With the following .NET SDKs installed
The following workloads are available
Notify maintainers
@kuznero @mdarocha
Metadata