NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.45k stars 13.65k forks source link

Package request: vscode extension ms-dotnettools.csdevkit #270423

Closed mausch closed 4 months ago

mausch commented 9 months ago

Project description

C# Dev Kit helps you manage your code with a solution explorer and test your code with integrated unit test discovery and execution.

Builds on top of ms-dotnettools.csharp which is already packaged.

I tried:

  (pkgs.vscode-utils.buildVscodeMarketplaceExtension {
    mktplcRef = { 
      name = "csdevkit";
      publisher = "ms-dotnettools"; 
      version = "1.1.12"; 
      sha256 = "sha256-otdTCATJ277gBLVL1UvsO3xdT4+7c9U5bwRqgFSPxMw=";
    };
  })

but it fails to build:

> unpacking sources
> unpacking source archive /nix/store/zfrdm3ms0svi0xivfcrlzmwpc31ly5cc-ms-dotnettools-csdevkit.zip
> unpacker produced multiple directories

I have no idea about vscode extension packaging.

Plus, like many other vscode extensions, it cannot be installed directly from the marketplace because it tries to write to the nix store:

2023-11-27 14:28:16.971 [error] EROFS
2023-11-27 14:29:49.568 [error] Extract: ENOENT: no such file or directory, mkdir '/nix/store/lvhxnnxdafarzmyldnbgshj1iksr3yr9-vscode-extensions/share/vscode/extensions/.e0040578-8f80-4f5d-bd48-35a197eb216c'
    at W.extractUserExtension (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:12069)
    at async B.u (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:18230)
    at async B.x (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:19867)
    at async B.h (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:17797)
2023-11-27 14:29:49.606 [error] ENOENT: no such file or directory, mkdir '/nix/store/lvhxnnxdafarzmyldnbgshj1iksr3yr9-vscode-extensions/share/vscode/extensions/.e0040578-8f80-4f5d-bd48-35a197eb216c': Extract: ENOENT: no such file or directory, mkdir '/nix/store/lvhxnnxdafarzmyldnbgshj1iksr3yr9-vscode-extensions/share/vscode/extensions/.e0040578-8f80-4f5d-bd48-35a197eb216c'
    at W.extractUserExtension (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:12069)
    at async B.u (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:18230)
    at async B.x (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:19867)
    at async B.h (/nix/store/d6867yvmb4xh13ka1bdlbhmny3wns6fm-vscode-1.82.1/lib/vscode/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:92:17797)

Metadata

Priorities

Add a :+1: reaction to issues you find important.

ablearthy commented 8 months ago

Seems, it will be hard due to this.

UPD: after installation it tries to create cache folder inside extension folder (but it's read-only):

Error: ENOENT: no such file or directory, mkdir '/home/tux/.vscode/extensions/ms-dotnettools.csdevkit/cache'
ablearthy commented 8 months ago

Seems, it works:

Code ```nix (pkgs.vscode-utils.buildVscodeMarketplaceExtension { mktplcRef = { name = "vscode-dotnet-runtime"; publisher = "ms-dotnettools"; version = "2.0.0"; sha256 = "sha256-oTeVskg9yfohlBW4GhgQj3TsweUoZ6WuxmntsispxOo="; }; postPatch = '' chmod +x "$PWD/dist/install scripts/dotnet-install.sh" ''; }) (pkgs.vscode-utils.buildVscodeMarketplaceExtension { mktplcRef = { name = "csdevkit"; publisher = "ms-dotnettools"; version = "1.3.4"; sha256 = "sha256-36lL754/kRwlnMXRiiTvHM80oWPR3MW5GBUCdHpefFc="; arch = "linux-x64"; }; sourceRoot = "./extension"; postPatch = with pkgs; '' patchelf_add_icu_as_needed() { declare elf="''${1?}" declare icu_major_v="${ lib.head (lib.splitVersion (lib.getVersion icu.name)) }" for icu_lib in icui18n icuuc icudata; do patchelf --add-needed "lib''${icu_lib}.so.$icu_major_v" "$elf" done } patchelf_common() { declare elf="''${1?}" chmod +x "$elf" patchelf_add_icu_as_needed "$elf" patchelf --add-needed "libssl.so" "$elf" patchelf --add-needed "libz.so.1" "$elf" patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc openssl zlib icu.out ]}:\$ORIGIN" \ "$elf" } sed -i -E -e 's/(e.extensionPath,"cache")/require("os").homedir(),".cache","Microsoft", "csdevkit","cache"/g' "$PWD/dist/extension.js" sed -i -E -e 's/o\.chmod/console.log/g' "$PWD/dist/extension.js" patchelf_common ./components/vs-green-server/platforms/linux-x64/node_modules/@microsoft/visualstudio-server.linux-x64/Microsoft.VisualStudio.Code.Server patchelf_common ./components/vs-green-server/platforms/linux-x64/node_modules/@microsoft/servicehub-controller-net60.linux-x64/Microsoft.ServiceHub.Controller patchelf_common ./components/vs-green-server/platforms/linux-x64/node_modules/@microsoft/visualstudio-code-servicehost.linux-x64/Microsoft.VisualStudio.Code.ServiceHost patchelf_common ./components/vs-green-server/platforms/linux-x64/node_modules/@microsoft/visualstudio-reliability-monitor.linux-x64/Microsoft.VisualStudio.Reliability.Monitor ''; }) ```

ms-dotnettools.vscode-dotnet-runtime

Make dotnet-install.sh script executable.

ms-dotnettools.csdevkit

  1. Specify arch.
  2. Use extension folder (since in archive there are multiple folders).
  3. Patch binaries as in ms-dotnettools.csharp/default.nix: add libstdc++.so, icu, openssl, zlib and make it executable.
  4. Change cache folder from extensionPath/cache (read-only) to $HOME/.cache/Microsoft/csdevkit/cache (maybe, the path should be changed to tmp directory).
  5. On startup the extension sets changes permissions of executables that are already patched, so, just suppress errors.
haras-unicorn commented 4 months ago

can this be closed because #295101 was merged? note that ms-dotnettools.vscode-dotnet-runtime is needed in order to run it i can confirm that the package added with #295101 is working on my machine if i use ms-dotnettools.vscode-dotnet-runtime from nix-vscode-extensions btw thx yall - i required to use c# at work so all of these extension packages help a ton

pluiedev commented 4 months ago

If it's already added and it works, then I think we can safely close this issue

lostmsu commented 3 months ago

@pluiedev it does not work without https://github.com/nix-community/nix-vscode-extensions

Either ms-dotnettools.csdevkit and ms-dotnettools.csharp need both to be moved there, or the .vscode-dotnet-runtime should be moved here (imho preferred considering importance for .NET ecosystem on NixOS).