Basically the gist is that Cypress binary is usually downloaded into ~/.cache/Cypress dir so in the hook the env vars tell npm not to download the binary and also where the binary is located when a node script tries calling Cypress.
To use nix-ld you need to enable it on the system. On NixOs you need to use programs.nix-ld.enable = true; in your configuration.nix. It will then create for you a file in /lib64/ld-linux-x86-64.so.2 that will read the NIX_LD environment variable to find the loader. As I understand it it is mostly for NixOs and I don’t think it is usable on other systems as they already come with their own loaders.
You probably also don’t want to read the contents of a binary into a string and then specify that as an env variable. Just specify the path, don’t read its contents.
The doc mentions NIX_LD = lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; and I used it succesfully. The reason is that this file contains the path of the actual binary:
It’s enabled.
I still get same erro when trying to run Cypress:
/nix/store/md1w04lvylr42j8j2bdzy1zp5x7044wj-cypress-9.6.0/bin/Cypress 1102ms Thu 01 Sep 2022 03:21:31 AM PDT
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Can you check then if the file /lib64/ld-linux-x86-64.so.2 exists? Note also that you need to graphically logout (for some reasons restarting a terminal is not enough) to reload the variables, even if I don’t think the problem is that.
Oh wait, I can see the line aarch64 so the M1 is maybe running arm instead of x86_64. In this case it may simply be the case that you are using a bad software, compiled for the x86_64 architecture. Now, if you installed this software via NixOs it may be the case that the NixOs derivation for Cypress is wrong…
Yea I suspected it was architecture problem because my error starts with the qemu-x86_64 . Isn’t that why it’s looking for the x86_64 library ? Doesn’t qemu emulation convert x86_64 architectures?
To be honest I’m not sure where this qemu is coming from, as I don’t know how cypress internally works. However the nixpkgs instructions only target x64 so this should not even be installable on your system… So I’m curious, what is your stdenv.system (see above)? I guess your best chance is to update the cypress expression to make it work on your architecture. For instance you can download the latest arm64 at https://cdn.cypress.io/desktop/10.7.0/linux-arm64/cypress.zip hopefully it should be enough to just write an overlay with this url