jeff-hykin / nix_version_search_cli

Nix Version Search CLI - user friendly way to find any version
MIT License
28 stars 3 forks source link

Does `nvs` not support using `nix run` / `nix shell`? #8

Open kanielrkirby opened 1 month ago

kanielrkirby commented 1 month ago

I find this to be strange behavior from a nix focused project. Is there a reason this might not be supported / currently work?

❯ nix run github:jeff-hykin/nix_version_search_cli
Could not start dynamically linked executable: /nix/store/lnpwfdzjmrjwcijjcrlyxrg7zy8iyg4c-nvs/bin/nvs
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld

❯ nix shell github:jeff-hykin/nix_version_search_cli

❯ nvs
Could not start dynamically linked executable: /nix/store/lnpwfdzjmrjwcijjcrlyxrg7zy8iyg4c-nvs/bin/nvs
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
jeff-hykin commented 1 month ago

Thanks for letting me know this doesn't work.

Is there a reason this might not be supported / currently work?

Yes. Right now, inside the nix derivation, the binary is compiled using Deno. And deno definitely doesnt have a static linking option. So the final executable links to a bunch of standard Linux shared object files (probably). And thats what NixOS is complaining about.

Theres probably a way to patch it with patchelf but I'm not sure how much elbow greese thats going to need. I'll need to find equivalent .so files inside the nix store, add those as runtime dependencies, and patch the binary so it dynamically links to them instead of standard Linux ones.

Usually this would be handled by autoPatchElf in mkDerivation, but mkDerivation breaks the deno executable, so I have to call derivation manually, which means I also need to manually do the Patchelf steps.

kanielrkirby commented 1 month ago

Ah, I see. I was going to ask if deno2nix would be a solution, but it seems to be unmaintained unfortunately, with no definitive fork.

kanielrkirby commented 1 month ago

There's a few (very few) deno packages in NixOS/nixpkgs that could potentially be some inspiration as well, if you end up wanting to solve this. Unfortunately, systems with Deno are a bit outside my expertise, or I'd happily mess with it a bit / make a PR.

jeff-hykin commented 1 month ago

I don't think this is a deno specific problem, I just need to patch the dynamic links. I appreciate the effort to help though!

I found theres 4 dynamic links, all go to the nix store, but 3 are not hardcoded to the nix store so I'm assuming those are the ones I need to fix with patchelf