NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.42k stars 13.63k forks source link

Question on how to use fetchNuGet #127855

Open kirinnee opened 3 years ago

kirinnee commented 3 years ago

Issue description

I'm fairly new to Nix, so I apologise if the question is simple.

I would like to know how to use fetchNuGet, but it seems to have read permission problems.

I have tried installing with --daemon and turning sandbox = false, and still have this problems.

Steps to reproduce

default.nix

{ nixpkgs ? import <nixpkgs> { } }:
with nixpkgs;
{
  dotnetsay = fetchNuGet {
    baseName = "dotnetsay";
    version = "2.1.7";
    sha256 = "121p4531ai08k9bqf2jb2d9cnpjw8iyj8474g779lk8jvvaz17y1";
    outputFiles = [ "*" ];
  };
}

I'm trying to package a dotnet demo CLI dotnetsay (like hello world) for dotnet's global tool.

Logs:

unpacking sources
unpacking source archive /nix/store/1jiqhwgp529hrqbpw9606j0vx4s6y4vx-dotnetsay.2.1.7.zip
source root is .
setting SOURCE_DATE_EPOCH to timestamp 1598038334 of file ./tools/netcoreapp2.1/any/dotnetsay.pdb
patching sources
configuring
Placating Nuget in nuget.targets
Just to be sure, replacing Nuget executables by empty files.
Placating Paket in paket.targets
Just to be sure, replacing Paket executables by empty files.
Patching F# targets in fsproj files...
installing
'[Content_Types].xml' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/[Content_Types].xml'
cp: cannot open '[Content_Types].xml' for reading: Permission denied
'_rels' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/_rels'
'_rels/.rels' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/_rels/.rels'
cp: cannot open '_rels/.rels' for reading: Permission denied
'dotnetsay.nuspec' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/dotnetsay.nuspec'
cp: cannot open 'dotnetsay.nuspec' for reading: Permission denied
'env-vars' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/env-vars'
'package' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/package'
'package/services' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/package/services'
'package/services/metadata' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/package/services/metadata'
'package/services/metadata/core-properties' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/package/services/metadata/core-properties'
'package/services/metadata/core-properties/d875c06b20544e639c169042a1ae0ee9.psmdcp' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/package/services/metadata/core-properties/d875c06b20544e639c169042a1ae0ee9.psmdcp'
cp: cannot open 'package/services/metadata/core-properties/d875c06b20544e639c169042a1ae0ee9.psmdcp' for reading: Permission denied
'tools' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools'
'tools/netcoreapp2.1' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1'
'tools/netcoreapp2.1/any' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1/any'
'tools/netcoreapp2.1/any/DotnetToolSettings.xml' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1/any/DotnetToolSettings.xml'
cp: cannot open 'tools/netcoreapp2.1/any/DotnetToolSettings.xml' for reading: Permission denied
'tools/netcoreapp2.1/any/dotnetsay.dll' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1/any/dotnetsay.dll'
cp: cannot open 'tools/netcoreapp2.1/any/dotnetsay.dll' for reading: Permission denied
'tools/netcoreapp2.1/any/dotnetsay.runtimeconfig.json' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1/any/dotnetsay.runtimeconfig.json'
cp: cannot open 'tools/netcoreapp2.1/any/dotnetsay.runtimeconfig.json' for reading: Permission denied
'tools/netcoreapp2.1/any/dotnetsay.pdb' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1/any/dotnetsay.pdb'
cp: cannot open 'tools/netcoreapp2.1/any/dotnetsay.pdb' for reading: Permission denied
'tools/netcoreapp2.1/any/dotnetsay.deps.json' -> '/nix/store/l6kd5dvhg7j0r31dhnb16y99nyq7kzrj-dotnetsay-2.1.7/lib/dotnet/dotnetsay/tools/netcoreapp2.1/any/dotnetsay.deps.json'
cp: cannot open 'tools/netcoreapp2.1/any/dotnetsay.deps.json' for reading: Permission denied
builder for '/nix/store/h9vazib24xr2ckbzwq83n7hhl8k45dra-dotnetsay-2.1.7.drv' failed with exit code 1
error: build of '/nix/store/h9vazib24xr2ckbzwq83n7hhl8k45dra-dotnetsay-2.1.7.drv' failed

Technical details

 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.128-microsoft-standard, Ubuntu, 20.04.2 LTS (Focal Fossa)`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.12`
 - channels(kirin): `"nixpkgs-21.11pre295944.0747387223e"`
 - nixpkgs: `/home/kirin/.nix-defexpr/channels/nixpkgs`

I've replicated this in ubuntu and alpine (within container) and osx.

Some guidance on how I can debug this, or track down the problem will be appreciated. I tried to track on nixpkgs fetchNuGet and buildDotnetPackage, but I'm not too sure how to breakdown/debug it.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

dustinlacewell commented 2 years ago

Not stale, just ran into this with Terminal.Gui. Send help!

Infinidoge commented 2 years ago

I ran into this same issue just now, and I think I managed to figure out a solution:

postUnpack = ''
  chmod -R +r .
'';

This makes the unpacked directory have permission to read, thus letting it copy properly.

kirinnee commented 2 years ago

How do you allow it to be used as a tool?

Infinidoge commented 2 years ago

Not sure about that yet. (I'm relatively new to the dotnet ecosystem overall, so I'm not sure how far my knowledge would go to making that happen lol). I got a bit farther in trying to use buildDotnetModule, which could at least try to build it, but not sure how that would apply to fetchNuGet. (In my case, I've been trying to package https://github.com/belav/csharpier)

YoshiRulz commented 1 year ago

I think when you opened this issue it was still a work-in-progress, but fetchNuGet currently works fine for its intended purpose: in auto-generated Nix expressions to be imported as e.g. buildDotnetModule { nugetDeps = ./deps.nix; }, as documented here (official).

However, that's only for normal NuGet packages. For dotnetsay and other .NET tools, you can add them to a project in the usual way: dotnet new tool-manifest if absent, then dotnet tool install dotnetsay. For --global, see #216285.

toraritte commented 10 months ago

Related: dream2nix issue #288: Language request: dotnet