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

Doesn't build in NixOS 20.03 #5411

Closed
Xe opened this issue May 14, 2020 · 4 comments
Closed

Doesn't build in NixOS 20.03 #5411

Xe opened this issue May 14, 2020 · 4 comments

Comments

@Xe
Copy link

Xe commented May 14, 2020

I'm trying to play with deno but the binary doesn't work on NixOS:

$ ./deno
Failed to execute process './deno'. Reason:
The file './deno' does not exist or could not be executed.

LDD reports this:

$ ldd ./deno
        linux-vdso.so.1 (0x00007ffece497000)
        libdl.so.2 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib/libdl.so.2 (0x00007f4beb10d000)
        librt.so.1 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib/librt.so.1 (0x00007f4beb103000)
        libpthread.so.0 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib/libpthread.so.0 (0x00007f4beb0e2000)
        libgcc_s.so.1 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib/libgcc_s.so.1 (0x00007f4beb0c8000)
        libc.so.6 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib/libc.so.6 (0x00007f4beaf09000)
        /lib64/ld-linux-x86-64.so.2 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib64/ld-linux-x86-64.so.2 (0x00007f4bed6ae000)
        libm.so.6 => /nix/store/9hy6c2hv8lcwc6clnc1p2jf09cs5q9dp-glibc-2.30/lib/libm.so.6 (0x00007f4beadc9000)

And additionally when I try to build deno from source I get this rust error:

$ cargo build --release
error: failed to run custom build command for `rusty_v8 v0.4.2`

Caused by:
  process didn't exit successfully: `/home/cadey/code/denoland/deno/target/debug/build/rusty_v8-0e9eed1354c7b305/build-script-build` (exit code: 101)
--- stdout
static lib URL: https://github.com/denoland/rusty_v8/releases/download/v0.4.2/librusty_v8_debug_x86_64-unknown-linux-gnu.a
cargo:rustc-link-search=/home/cadey/code/denoland/deno/target/debug/gn_out/obj
Downloading https://github.com/denoland/rusty_v8/releases/download/v0.4.2/librusty_v8_debug_x86_64-unknown-linux-gnu.a

--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1188:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

I'm not entirely sure what could be failing here, but whatever it is it's making this not work for me. I'm using NixOS 20.03:

$ cat /etc/os-release
NAME=NixOS
ID=nixos
VERSION="20.03.1822.5adf2a6c116 (Markhor)"
VERSION_CODENAME=markhor
VERSION_ID="20.03.1822.5adf2a6c116"
PRETTY_NAME="NixOS 20.03 (Markhor)"
LOGO="nix-snowflake"
HOME_URL="https://nixos.org/"
DOCUMENTATION_URL="https://nixos.org/learn.html"
SUPPORT_URL="https://nixos.org/community.html"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"

Do you have any ideas as to why this is failing?

@SyrupThinker
Copy link
Contributor

SyrupThinker commented May 14, 2020

You need to change the dynamic linker in the prebuilt binary.
For the build you need to have the following dependencies available:

nodejs
rustChannels.stable.rust
python2

Additionally here is the current packaging effort.

@SyrupThinker
Copy link
Contributor

The following is my derivation for the prebuilt binary

{ autoPatchelfHook, fetchurl, stdenv, unzip }:

stdenv.mkDerivation rec {
  name = "deno-bin-${version}";
  version = "1.0.0";

  src = fetchurl {
    url = "https://github.com/denoland/deno/releases/download/v${version}/deno-x86_64-unknown-linux-gnu.zip";
    sha256 = "0aknxy9z5cvw091yaw5yf2zynwzxs39ax3jkqdg10xw344jsyn31";
  };

  nativeBuildInputs = [
    autoPatchelfHook
    unzip
  ];

  unpackPhase = ''
    unzip $src
  '';
  
  installPhase = ''
    install -m755 -D deno $out/bin/deno
  '';

  meta = with stdenv.lib; {
    homepage = https://deno.land;
    description = "A secure runtime for JavaScript and TypeScript";
    platforms = platforms.linux;
  };
}

@06kellyjac
Copy link
Contributor

@Xe as @SyrupThinker has said already you needed to use the patchELF tool link

When you've got a binary that looks like the right architecture according to file's output & all the libs are linked according to ldd's output, this is usually the last step to making the binary work 🙂

@06kellyjac
Copy link
Contributor

Are you happy to close this issue or is there anything else we can help you with?

@Xe Xe closed this as completed May 15, 2020
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

No branches or pull requests

3 participants