How to find needed librarys for closed source bin applications

That looks like the output of nix-index… But what I still didn’t understand, i run the stereotool-gui… and it says that he is missing libx11. Then i added these lines together with nix-ld enable.

programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
xorg.libX11 <<<<<<
];

Then switch, then stereotool misses the next one… Is there a tool to automaticaly create a list of missing libs and tools…so i don’t have to add more libs that i need.

For example. I never will play games on my systems. But i can imagine that non game software will use them though…

The list you quote point to a list of libraries that I find useful to run most things, including blender, so it gives you a first start. Then, you can also use as described in Different methods to run a non-nixos executable on Nixos - Unix & Linux Stack Exchange

  1. nix-alien provides nix-alien-find-libs yourBinary
  2. nix-autobahn, that provides nix-autobahn-find-libs (seems like it is not maintained as much as nix alien)

OK, understand.
I hope I didn’t annoy you too much. I want to avoid unnecessarily filling the HDD with libs that are not needed. Autobahn is a funny name for a program. Maybe it would make sense if there was an official solution for binaries and appimages… at some point.

Ahah no worries ^^

I see. Then, you don’t even need to install them, you should be able to just run nix-alien-ld -- ~/myapp, and it will just download the needed libraries the time to run your program, this should be gone when you garbage collect next time.

Well nix-ld is quite official, what’s wrong with this? You also have appimage-run (also “official”) but I find it less reliable than nix-ld.

Probably nothing. As Nixos beginner, you ask yourself how to find out the missing LIBS without installing a large collection for suspicion.

That could mean that a program that you rarely use has suddenly disappeared and cannot start without the Internet in an outdoor situation? Rather not. Then it’s better to have too many libs…:wink:

sure :wink:

If you use his solution, yes (well technically it would not disappear, just running it from command line will give you an error). Yeah, it’s a tradeoff to choose ^^ I also prefer to have too many libs… and anyway most of them are already present, like I guess firefox needs most of them for instance, so I don’t even think it costs you any space at all.

:thinking:

error: attribute ‘lib’ missing
at /nix/store/3invshwnxknmr79v957rid6wi649djlj-source/configuration.nix:244:9:
243| libva
244| pipewire.lib
| ^
245| xorg.libxcb

Pipewire doesn’t have a lib output.

I think this changed recently: in my current system, I do have a lib output, but not in github:NixOs/nixpkgs, maybe the database is not yet up to date? I guess pipewire should work.

Yes, no error messages. Later i can do a reboot and test some applications. And give a feedback of cource!

Ok, it won’t run.

[wolf@daw:~/APP]$ ./stereo_tool_gui_64
./stereo_tool_gui_64: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

Then i tried:

[wolf@daw:~/APP]$ nix run “github:thiagokokada/nix-alien#nix-alien-find-libs” – /home/wolf/APP/stereo_tool_gui_64
[nix-alien] Selected candidate for ‘libX11.so.6’: xorg.libX11.out
[nix-alien] Selected candidate for ‘libasound.so.2’: alsa-lib.out
[nix-alien] Selected candidate for ‘libbz2.so.1.0’: bzip2.out
[nix-alien] Selected candidate for ‘libz.so.1’: zlib.out
[nix-alien] Selected candidate for ‘libXpm.so.4’: xorg.libXpm.out
alsa-lib.out bzip2.out xorg.libX11.out xorg.libXpm.out zlib.out

Do i’m right, adding these 10 .out files in my configuration.nix, if not already there?

Do i’m right, adding these 10 .out files in my configuration.nix, if not already there?

You could, but I think it would be better to properly create a derivation for that application and patch the ELF file. If you install libraries globally to your system config, then why use NixOS in the first place? Seems like you’d be getting a lot of the downsides of using NixOS while not leveraging the upsides.

Sure you can do it. Actually, the .out is optional, you can just type zlib instead of zlib.out. As @polygon pointed it, if you often use this package, it might be cleaner to package it as we discussed previously, just nix-ld is maybe a bit easier to use if you quickly want to test a package or for stuff that are not easy to package like pip/npm stuff.

Maybe ur right. The main reason to use NixOs is the huge package repo. Just like on Arch with AUR, but there i had sometimes a broken system after updates. That’s why i switched to Nix for testing. And i have maybe 4 or 5 programs not direct available in the package repo… I like the idea of having nearly all configs in only a few nix files. Should i stop using Nix only bec. of these 5 progs, or i’m not a developer…?

Yes, that was a great job. But honestly after looking in the editcp.nix file, i don’t know how to do it with stereotool or luci audio codec. And i know i could, but i don’t want to ask everytime in this board. If i can’t manage that by myself, Nix is maybe not the best distro for my needs…

To be honest, if you want a more standard experience with Nix, just use nix-ld, and you might enjoy starting to use nix language later. Nix is really not mandatory, just it feels nicer as you can easily add desktop entries for this, keep it in a git repo etc. I configured mine a long time ago with the above set of dependencies, and I never have any trouble to install new stuff… and if I forgot one lib I can just manually add it.

If your file is a simple one-binary file, like an appimage or alike, you should just be able to do something like:

{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, wrapQtAppsHook
, libusb
}:

stdenv.mkDerivation rec {
  pname = "yourbinary";
  version = "1.0";

  src = ./yourbinary;

  unpackPhase = ":";

  nativeBuildInputs = [
    autoPatchelfHook
    # only needed for Qt apps:
    wrapQtAppsHook
  ];
  buildInputs = [
    # but here any lib you need for that program. Usually, I just try to run my program, and add the missing
    # libraries one ofter the others. If you add something here, make sure to add it on the inputs `{…}:` on the first line:
   libusb
  ];
  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/${pname}
    chmod +x $out/bin/${pname}
  '';
}

put it in a file like mybinary.nix and in your package list add (pkgs.libsForQt5.callPackage ./mybinary.nix {}), with the parenthesis, or, if you don’t need wrapQtAppsHook (e.g. your program is not using Qt), just add (pkgs.callPackage ./mybinary.nix {}).

For instance, for your program luci, you can do:

{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, wrapQtAppsHook
}:

stdenv.mkDerivation rec {
  pname = "LuciLive";
  version = "6.0.0";

  src = ./LuciLive_6.0.0.run;
  unpackPhase = ":";
  nativeBuildInputs = [
    autoPatchelfHook
    # only needed for Qt apps:
    wrapQtAppsHook
  ];
  buildInputs = [
    # but here any lib you need for that program. Usually, I just try to run my program, and add the missing
    # libraries one ofter the others. If you add something here, make sure to add it on the inputs `{…}:` on the first line:
  ];
  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/${pname}
    chmod +x $out/bin/${pname}
  '';
}

and call it with (pkgs.libsForQt5.callPackage ./yourlucyfile.nix {}) in your package list. After the switch, it will create a binary called LuciLive.

In that case, i can disable

programs.nix-ld.enable = true;

Or remove the content under

programs.nix-ld.libraries = with pkgs; [

I mean, the stereotool commandline version has worked only with the first entry…

What do you mean with “the first entry”?

Well, if you are that short on disk space you can, but there is no harm to keep it. Who knows, you might need it later to run another program that you don’t want/have time to package.

That one…

programs.nix-ld.enable = true;

Well, of course, if you disable programs.nix-ld.enable, then you will not be able to run stereotool again unless you package it as I showed you for lucilive ^^’ But sure, you can remove programs.nix-ld.libraries if you don’t need them for now. I mean, its your system, do what you prefer :wink:

1 Like