Running intuit/auto on NixOS

Hi all-

I’d like to run Intuit’s auto tool on NixOS. The standard way to run it is to install it as part of a Node project’s dependencies using yarn et al., but their recommended way to run it outside of that context is to download a binary from a GitHub release, make that file executable, and run it (as detailed in the documentation). Needless to say, this does not work out of the box on NixOS–running the executable gives me no such file or directory: ./auto (which I understand to be an error about not being able to find the linker).

Even though it seems to be a missing linker, I still tried a few things. Running ldd on the downloaded auto gives me:

        linux-vdso.so.1 (0x00007ffc98a7e000)
        libdl.so.2 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libdl.so.2 (0x00007f3c63856000)
        librt.so.1 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/librt.so.1 (0x00007f3c6384b000)
        libstdc++.so.6 => not found
        libm.so.6 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libm.so.6 (0x00007f3c63708000)
        libgcc_s.so.1 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libgcc_s.so.1 (0x00007f3c636ee000)
        libpthread.so.0 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0 (0x00007f3c636cd000)
        libc.so.6 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6 (0x00007f3c6350a000)
        /lib64/ld-linux-x86-64.so.2 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib64/ld-linux-x86-64.so.2 (0x00007f3c6385d000)

To fill in that not found I thought I’d be sneaky and use LD_LIBRARY_PATH to provide a random libstdc++.so.6 to auto, but of course this doesn’t work either. I get the same not found error.

Finally, I used the following shell.nix file to provide libstdc++ the right way:

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "foobar";
  src = null;

  buildInputs = [
    stdenv.cc.cc
  ];

  shellHook = ''
    export LD_LIBRARY_PATH=${lib.makeLibraryPath [stdenv.cc.cc]}
  '';
}

but this gives me the same not found error.

Can you help me understand how to run this on NixOS properly? Thanks in advance!

roni

if you want to run this on nixos ‘properly’, then it’s always best to make a derivation that builds from source.

Nixos can be made to run bninaries, with patching… is there something stopping you creating a deviation, that builds the software from source, rather than downloading a binary and patching the linker?

If you’re desperate to get the binary working, use the autopatchelf hook: Packaging/Binaries - NixOS Wiki - this will modify the binary, patching it so it links to the correct hard-coded library path.

But otherwise I concur on the front of recommending building from source; you have the source already, why not just build it? :slight_smile:

Thank you both for the suggestions. You are right of course. I had some tunnel vision from the fact that their own documentation says to pull a binary off of GitHub and just run it. If I want to stick to that recommendation, I will use patchelf; otherwise you are right that building from source is the correct thing to do.