Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mausch opened this issue Nov 27, 2023 · 5 comments
Closed

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

mausch opened this issue Nov 27, 2023 · 5 comments

Comments

@mausch
Copy link
Member

mausch commented Nov 27, 2023

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 👍 reaction to issues you find important.

@ablearthy
Copy link

ablearthy commented Jan 20, 2024

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
Copy link

Seems, it works:

Code
(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
Copy link

haras-unicorn commented May 6, 2024

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
Copy link
Contributor

pluiedev commented May 6, 2024

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

@pluiedev pluiedev closed this as completed May 6, 2024
@lostmsu
Copy link

lostmsu commented Jun 22, 2024

@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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants