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

Wrong hash for jupyter extension #18

Closed
leon-erd opened this issue Mar 2, 2024 · 19 comments · Fixed by #21
Closed

Wrong hash for jupyter extension #18

leon-erd opened this issue Mar 2, 2024 · 19 comments · Fixed by #21

Comments

@leon-erd
Copy link

leon-erd commented Mar 2, 2024

Somehow I get a wrong hash for the jupyter extension.

vscode_version  = "1.86.2"
[[extensions]]
publisher_name = "ms-toolsai"
extension_name = "jupyter"

returns this:

"ms-toolsai"."jupyter" = vscode-utils.extensionFromVscodeMarketplace {
    name = "jupyter";
    publisher = "ms-toolsai";
    version = "2024.1.2024012502";
    sha256 = "11dq86kxm3yqyykrv7xnq8nfim0jx16ni6hj75chbhsynvdjkb8x";
  };

When trying to build the system with this it gives me the following error. Inserting the correct hash into the nix expression manually works. For all my other extensions it works as well. Its just jupyter...

error: hash mismatch in fixed-output derivation '/nix/store/qsz7qn7ixnqf2x86x1inrwbyn8ls7rhp-ms-toolsai-jupyter.zip.drv':
         specified: sha256-Ha0p27ZewwVZORKaaE3oEtToLMK2n52n99iP2qdBuIU=
            got:    sha256-q4y8TGEzqd0J6GREvDdXnkL7/xYXOXk+TkvEaX3A40o=
error: 1 dependencies of derivation '/nix/store/rf6d3b6qpbwi8arbidb953bakwf202mq-vscode-extension-ms-toolsai-jupyter-2024.1.2024012502.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f917lzb28jnb0jy9yswkml6skdwv3cna-hm_.vscodeossextensions.extensionsimmutable.json.drv' failed to build
error: 1 dependencies of derivation '/nix/store/r7c4k4abqcdlhdj62xkirh5bw77qkbhy-home-manager-files.drv' failed to build
error: 1 dependencies of derivation '/nix/store/788vkjbr60h6k7dxbsswx3ixk6bcp8m3-home-manager-generation.drv' failed to build
@cathaysia
Copy link
Collaborator

This bug can be reproduced. nix4vscode uses nix-prefetch-url to calculate the hash of the file. However, the inconsistency between nix-prefetch-url and the hash calculated by nix causes this problem.

Consider this a bug in nix-prefetch-url. The following are related issues:

NixOS/nix#10127

@thufschmitt
Copy link

I compared the output of nix-prefetch-url and the one that the Nix expression tries to fetch:

$ echo $NIX_PREFETCH_URL_OUTPUT
11dq86kxm3yqyykrv7xnq8nfim0jx16ni6hj75chbhsynvdjkb8x
/nix/store/2di7lv008fv7b71zd9p2w94dq3j6lfa9-Microsoft.VisualStudio.Services.VSIXPackage
$ NIX_PREFETCH_URL_OUTPUT=$(nix-prefetch-url https://ms-toolsai.gallerycdn.vsassets.io/extensions/ms-toolsai/jupyter/2024.1.2024012502/1706210577096/Microsoft.VisualStudio.Services.VSIXPackage --print-path | tail -n1)
$ NIX_BUILD_OUTPUT=$(nix-build --expr 'with import <nixpkgs> { }; (vscode-utils.extensionFromVscodeMarketplace {
    name = "jupyter";
    publisher = "ms-toolsai";
    version = "2024.1.2024012502";
    sha256 = "sha256-q4y8TGEzqd0J6GREvDdXnkL7/xYXOXk+TkvEaX3A40o=";
  }).src')
$ diffoscope $NIX_PREFETCH_URL_OUTPUT $NIX_BUILD_OUTPUT 
...

The diffoscope result shows that the file are fairly different. The interesting bit, I guess is:

-    <Identity Language="en-US" Id="jupyter" Version="2024.1.2024012502" Publisher="ms-toolsai" TargetPlatform="alpine-x64"/>
+    <Identity Language="en-US" Id="jupyter" Version="2024.1.2024012502" Publisher="ms-toolsai" TargetPlatform="alpine-arm64"/>

(notice the different TargetPlatform).

If I force the arch in the call to extensionFromVscodeMarketplace (by passing arch="alpine-x64"), I get the same path for nix-prefetch-url and nix-build

@cathaysia
Copy link
Collaborator

Confirmed to be a problem with nix4vscode. it does not handle target_platform

@cathaysia cathaysia mentioned this issue Mar 3, 2024
cathaysia added a commit that referenced this issue Mar 3, 2024
close #18

Signed-off-by: DragonBillow <[email protected]>
@cathaysia
Copy link
Collaborator

I add a patch fix this: #21 . Is it suitable for you?

cathaysia added a commit that referenced this issue Mar 3, 2024
close #18

Signed-off-by: DragonBillow <[email protected]>
cathaysia added a commit that referenced this issue Mar 3, 2024
close #18

Signed-off-by: DragonBillow <[email protected]>
@leon-erd
Copy link
Author

leon-erd commented Mar 4, 2024

Yes it fixes the hash problem! :)
However, I noticed two other things (problems).
FIrst: I get a bunch of warning (see below). They are printed out on stdout and not stderr so ./nix4vscode extensions.toml > file.nix won't work.

swappy-20240304_012749

Second: lib.attrsets.optionalAttrs seems to override (delete) all other extensions from the same publisher when evaluated.
Having

[[extensions]]
publisher_name = "ms-toolsai"
extension_name = "jupyter"

[[extensions]]
publisher_name = "ms-toolsai"
extension_name = "jupyter-keymap"

and then building with the generated extensions.nix file will raise error: attribute 'jupyter-keymap' missing

@cathaysia
Copy link
Collaborator

I add two commit fix these questions, now the log will always print to stderr, and ensure previous attr not be overrited.

note that nix4vscode have a option -o used write result to file but not stdoput. :)

cathaysia added a commit that referenced this issue Mar 4, 2024
close #18

Signed-off-by: DragonBillow <[email protected]>
@leon-erd
Copy link
Author

leon-erd commented Mar 4, 2024

Ah I didn't know about the -o option maybe should add this to the README.
And yeah the fixes work!
However, the new branch seems to pull outdated versions for some extensions (see below) compared to the main branch.

swappy-20240304_151601

@cathaysia
Copy link
Collaborator

cathaysia commented Mar 4, 2024 via email

@leon-erd
Copy link
Author

leon-erd commented Mar 4, 2024

Sure sure! Should I open a new issue for the outdated versions? :)

@cathaysia
Copy link
Collaborator

cathaysia commented Mar 4, 2024 via email

@cathaysia
Copy link
Collaborator

cathaysia commented Mar 5, 2024 via email

@leon-erd
Copy link
Author

leon-erd commented Mar 5, 2024

I think it works as you want. It pulls the same versions as the main branch and the other bugs also seem fixed.
However, I once again discovered something odd 😅.
I think for some extensions it pulls versions that are too new. But this is already the case in the main branch so nothing introduced by these commits.
An example is once again jupyter. With vscode_version = "1.86.2" in config.toml it generates jupyter with version 2024.1.2024012502. This version does not work with my vscodium. If I install the extension manually in vscodium it installs version 2023.9.100 which works. So I assume this is the latest compatible version with vscode 1.86.2 which should also be generated by this repo.

@cathaysia
Copy link
Collaborator

as a interesting result, the engine compatible in the package.json of jupyter 202401 is ^1.86.0, so it should work with 1.86.2. Is your vscodium really 1.86.2, or you should use openvsx instead?

@leon-erd
Copy link
Author

leon-erd commented Mar 7, 2024

Yes it is 1.86.2 😅. Maybe its something with my setup even though I don't think this is the case bc vscodium itself installs a lower version.

@cathaysia
Copy link
Collaborator

is your system linux or macos? On macos, when you upgrade your flake, you need recreate icon in the dock. The best way is check the code's version by codes' reference, but not flake.

@leon-erd
Copy link
Author

leon-erd commented Mar 7, 2024

Running linux

~ disfetch
       \\    \\  //      WE| leon @ leon-inspiron
        \\    \\//       RD| OS:        nixos 24.05 (uakari)
    ::::://====\\  //    GN| KERNEL:    6.7.6
       ///      \\//     YW| ARCH:      x86_64
  """"//\\      ///""""  BE| UPTIME:    4 hours 23 minutes
     //  \\====//:::::   MA| PACKAGES:  2634
        //\\    \\       CN| SHELL:     zsh
       //  \\    \\      BK| DESKTOP:   hyprland
➜  ~ codium --version
1.86.2
27d855b2b4105a2aca2445223c8f3dc4694fbd58
x64

@cathaysia
Copy link
Collaborator

the reason is vscodium using openvsx but not vscode marketplace, but openvsx is outdated. If you Making vscoduim using vscode marketplace, you can using latest extension:

image
image

if does not:
image
image

@cathaysia
Copy link
Collaborator

nix4vscode doesn't support openvsx for now, If you use vscodium, I recommend you use vscode marketplace

@cathaysia
Copy link
Collaborator

I plan to merge PR into the branch first. If you have other questions, please be free open a new issue.

cathaysia added a commit that referenced this issue Mar 9, 2024
close #18

Signed-off-by: DragonBillow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants