How to find needed librarys for closed source bin applications

Atm stereotool won’t run, bec. for now i have not added the libs discovered by the alien, so i could stop that and try to do it with a package…

So… Started with stereotool. The cmd variant is succesfully built. But the gui gives as expected some error.

[wolf@daw:/etc/nixos]$ sudo nixos-rebuild switch
building the system configuration…
error: builder for ‘/nix/store/5r3f4xcwlln36bq3854lk11izj68d8xp-stereo_tool_gui_64-10.21.drv’ failed with exit code 1;
last 10 log lines:
setting interpreter of /nix/store/hmkg15bhwdlp49v552vl690jj7nadr3s-stereo_tool_gui_64-10.21/bin/stereo_tool_gui_64
searching for dependencies of /nix/store/hmkg15bhwdlp49v552vl690jj7nadr3s-stereo_tool_gui_64-10.21/bin/stereo_tool_gui_64
auto-patchelf: 2 dependencies could not be satisfied
error: auto-patchelf could not satisfy dependency libasound.so.2 wanted by /nix/store/hmkg15bhwdlp49v552vl690jj7nadr3s-stereo_tool_gui_64-10.21/bin/.stereo_tool_gui_64-wrapped
error: auto-patchelf could not satisfy dependency libXpm.so.4 wanted by /nix/store/hmkg15bhwdlp49v552vl690jj7nadr3s-stereo_tool_gui_64-10.21/bin/.stereo_tool_gui_64-wrapped
auto-patchelf failed to find all the required dependencies.
Add the missing dependencies to --libs or use --ignore-missing="foo.so.1 bar.so etc.so".
/nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 74: pop_var_context: head of shell_variables not a function context
/nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1479: pop_var_context: head of shell_variables not a function context
/nix/store/bknngadwym46j65qs14ic2w79rpav888-stdenv-linux/setup: line 1582: pop_var_context: head of shell_variables not a function context
For full logs, run ‘nix log /nix/store/5r3f4xcwlln36bq3854lk11izj68d8xp-stereo_tool_gui_64-10.21.drv’.
error: 1 dependencies of derivation ‘/nix/store/wl9crab4p2dfa6kx50gnlwb7c52mviw4-system-path.drv’ failed to build
error: 1 dependencies of derivation ‘/nix/store/2w5qik8g75cjyghcb28qzhsly74vhmf7-nixos-system-daw-24.05.20240125.ae5c332.drv’ failed to build

These (only) two libs i have to add in my stereo_tool_gui_64.nix ??

Like this?

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:
libasound
libXpm
];

I also tried the libs from the above alien command – alsa-lib.out bzip2.out xorg.libX11.out xorg.libXpm.out zlib.out with removed .out…

Finaly, and after googling around… It (stereotool-gui) works. Except some file handling, and in terminal i see a

sh: Zeile 1: python: Kommando nicht gefunden.

Wonder that there is no python… OK,

[wolf@daw:/etc/nixos]$ cat stereo_tool_gui_64.nix
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, wrapQtAppsHook
, libX11
, alsa-lib
, bzip2
, zlib
, libXpm
}:
stdenv.mkDerivation rec {
pname = “stereo_tool_gui_64”;
version = “10.21”;
src = ./stereo_tool_gui_64;
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:
libX11
alsa-lib
bzip2
zlib
libXpm
];
installPhase = ‘’
mkdir -p $out/bin
cp $src $out/bin/${pname}
chmod +x $out/bin/${pname}
‘’;
}

Congratulation for your first derivation :wink: (actually, this derivation does not need Qt, so wrapQtAppsHook is not needed and you can replace the libsForQt5.callPackage with simply callPackage) Now if you want to have fun, you can create a desktop entry as we did for editcp, and why not contribute it to nixpkgs :stuck_out_tongue:

You can see in the command line that it is doing many tries with zenity, kdialog etc to find a program, python + tkinter is just one of these tries. You can wrap your program to provide kdialog as:

{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, libX11
, alsa-lib
, bzip2
, zlib
, libXpm
, kdialog
, makeWrapper
}:
stdenv.mkDerivation rec {
  pname = "stereo_tool_gui_64";
  version = "10.21";
  src = ./stereo_tool_gui_64;
  unpackPhase = ":";
  nativeBuildInputs = [
    autoPatchelfHook
    makeWrapper
    # 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:
    libX11
    alsa-lib
    bzip2
    zlib
    libXpm
  ];
  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/${pname}
    chmod +x $out/bin/${pname}
    wrapProgram $out/bin/${pname} --prefix PATH : ${lib.makeBinPath [ kdialog ]}
  '';
}

Stereotool isn’t open source, the downloadable version is limited…

Yes, that is nearly ready. The startentry is there, but no icon and not in Group Audio… OK, step by step. I had to learn, that there is no group multimedia… curios…
Screenshot_20240201_202853

Good job, you are starting to get there!

If you look at some applications there, like audacity, you can see that they register into [ "AudioVideo" "Audio" ] following A. Registered Categories

$ readlink -f $(which audacity)
/nix/store/4456ccdxvx68wyqaa2wwgla87hyvy8hc-audacity-3.2.4/bin/audacity
$ cat /nix/store/4456ccdxvx68wyqaa2wwgla87hyvy8hc-audacity-3.2.4/share/applications/audacity.desktop | grep Categories
Categories=AudioVideo;Audio;AudioVideoEditing;

Regarding the icon, you just need to download your icon, say YOURPROGRAM.png and move it to $out/share/icons/hicolor/YOURPROGRAM.png, via something like that in the install phase:

installPhase = ''
  # ...
  mkdir -p $out/share/icons/hicolor/
  cp ${./YOURPROGRAM.png} $out/share/icons/hicolor/
'';

and in your makeDesktopItem, add a line like icon = "YOURPROGRAM"; (with no extension). Should be all!

Nix does have close source programs, but if the downloadable version is useless, maybe it does not make much sense indeed.

Not useless. You can enter your license and can use more funktions. For now i use only the free available funktions.

Ah ok. So guess it still makes sense to package it if you are motivated.

Always… But there is another question. Stereotool (gui) comes in two versions, one for alsa and one for jackd. That means it needs two packages.?

OK, what to do? And what about updates? Would it be my job to take care of it? And do you mean i’m ready for this??

Either two packages, or a single package containing both binaries (this would maybe be cleaner I think). An even cleaner method would be to provide some options to your derivation to enable one package or the other… but it’s slightly more complicated.

Yeah, you need to add yourself as a maintainer of the package (see below), and typically you are the one supposed to make updates, but as explained here https://github.com/NixOS/nixpkgs/tree/master/maintainers:

Unlike other packaging ecosystems, the maintainer doesn’t have exclusive control over the packages and modules they maintain. This more fluid approach is one reason why we scale to so many packages.

The main responsibility of a maintainer is to keep the packages they maintain in a functioning state, and keep up with updates. In order to do that, they are empowered to make decisions over the packages they maintain.

That being said, the maintainer is not alone proposing changes to the packages. Anybody (both bots and humans) can send PRs to bump or tweak the package.

Also, the nix community recommends:

We encourage people who care about a package to assign themselves as a maintainer. Commit access to the Nixpkgs repository is not required for that.

so if you heavily use these tools, you are the perfect candidate :stuck_out_tongue:

Well, you are definitely young in this ecosystem, but you are not alone here. You will first need to submit a Pull Request, and then reviewers will be asked to review your contribution, and ask you to modify it until it is good enough to integrate in Nixpkgs. Turst me, reviewers will not allow a dirty code to get into the repository, so there is not much risk here… and that’s the beauty of Nix and its strength, everyone can maintain a package :wink: And if you want to help, you can help people to review packages (at least by testing it), we are always in need of more reviewers.

First, are you familiar with git? (this is the tool that nix uses to allow many people to contribute as the same time) If not, you might like to play with https://ohmygit.org/, or just learn basic git clone yourforkOfNixgks, git add yourfile.nix, git commit -am "package: init at 1.0", git push… and it’s basically all you need before creating a PR from github’s website (a message will appear do you want to create a PR). So the rest is just about doing it right in nix.

So first, you need to add yourself as a maintainer: so just add an entry with your name in maintainers/maintainer-list.nix following other existing entries, and create a commit named like maintainers: add wolf with just this. Then, if your derivation does not need Qt, just put the derivation in something like nixpkgs/by-name/st/stereotool/package.nix (this is fairly new system, this way it is automatically added to the top level, otherwise if you put it in a category like nixpkgs/applications/audio/stereotool/default.nix, you need to add the derivation in pkgs/top-level/all-packages.nix). Then, you will also need to specify the source via an url, like fetchzip. You can check the documentation online… or sometimes it is simpler to just go to a clone of nixpkgs and type (after installing rg):

$ rg fetchzip -C 5

and it will print all codes containing fetchzip with 5 lines of context around. Practical to quickly see how people use it in practice etc. If you want to package multiple sources, you might like this explanation: How to create package with multiple sources? - #3 by rkoe To package also stuff for aarch64, darwin etc, you can use a dict like they did here https://github.com/NixOS/nixpkgs/blob/185474c3ec482062b9978969c92c0635f80ab049/pkgs/applications/misc/1password-gui/default.nix#L14-L55

Note that you will need to add a meta entry in the above derivation, like:

  meta = with lib; {
    homepage = "https://github.com//";
    description = "";
    longDescription = ''
      
    '';
    license = licenses.unfree;
    maintainers = with maintainers; [ putYourNameHereAsAddedInTheMaintainerFile ];
    platforms = platforms.linux;
  };

and, importantly, INDENT your code correctly. If you use any decent editor, there is often a way to indent your code more or less automatically. For instance, in Kate, that typically comes with KDE by default:

Peek 02-02-2024 00-50

If you want to read more, there is:

  1. my tutorial packaging - How to package my software in nix or write my own package derivation for nixpkgs - Unix & Linux Stack Exchange
  2. nix/nixpkgs/nixos manuals (warning there are 3!), like Nixpkgs 23.11 manual | Nix & NixOS NixOS 23.11 manual | Nix & NixOS and Introduction - Nix Reference Manual
  3. GitHub - NixOS/nixpkgs: Nix Packages collection & NixOS where you can find countless examples, combine with rg/fd for great efficiency.
1 Like

That would be the best. On linux i prefer using jackd, never had used it with alsa, pulse or whatever. The platform i’m running it is Linux Mint. That tool is used for (in my case) postprocessing of my radioshows created by rivendellaudio… (another story, but maybe interesting for NixOs.) The maintainer of Rivendell is building packages for Ubuntu/Mint. After Centos has “disapeared”… Getting Rivendell as a appliance running on Nix would be the greatest challenge.

Btw. I had to test it first if stereotool runs with jackd on NixOs. If there comes problems, it makes no sense, and enabling jack can be difficult on Nix, as i have read somewhere.

One time a week, after finished my moderation…:wink: Is that heavy??

I’m 56y… :wink: But yes, my linux knowledge is in many cases useless here… But i’m interessted in finding the perfect Linux OS for all my usecases.

Only for getting software, compiling Rivendell software, (as it was only for Centos available). git clone and pull… Thats all…

ok, that takes some time to read and ask and understand. As i am not a nativ english speaker and i don’t like to copy all to google translate, it takes everything a bit more time. (This post is not created by google…:wink:

If that is ok for the community?! Then ok, lets try it.

1 Like

That seems like a great peace of software, but for what I see nothing impossible. One might want to create a NixOs module so that installing rivendellaudio is just a matter of services.rivendell.enable = true;.

I’m surprised, I don’t think it should be too complicated as there is a jack module. But to be honest, do not bother installing jack: now there is pipewire that is implementing both jack protocol & pulseaudio protocol and that is kind of starting to be the norm, replacing pulseaudio and, to some extends, jack. I have pipewire installed, and it works just great, way better than pulseaudio, and I can use jack & pulseaudio applications at the same time, even using bluetooth devices etc, without even wondering if it is pulseaudio or jack… Just check out PipeWire - NixOS Wiki it’s 5 lines to add to your configuration and boom.

Definitely

Great :wink:

Ok, so you are halfway there. So you just need to learn how to create a branch, how to commit, and how to push… so like 3 commands :wink:

Sure :wink: Once you have a working code, maybe show me the file first before doing the PR so that I can give you some first feedbacks. Good luck :wink:

Hahaha, with mariadb and nfs server…?

Already tried with the Ubuntu implementation. The CAED daemon won’t talk with pipewire for now. Jackd has to run in promiscousmode to talk to caed ( and stereotool, audacity…)

And voicetracking to play from rivendell and record the voice at the same time… Latency has to be very low. As i said. A challange… Thats why i use a separate os to do my radiojob. And it really does not need to run on a desktop together with officework and youtube. But a stable OS with the abillity to roll back if an update breaks somethink would ne a benefit for that. There are many radiostations out there, with big ranges via FM and on mediumwave. No webradio with 10 listener… So, availabillity is most important.

Means that what i made yesterday, that one .nix file??

Mission impossible…:slight_smile: Here u can see it running, to playout my friday evening show…

I’ve created a icon ./st-icon.png based on a gui element of the application… But… See Screenshot.
And i have at first created two .nix versions. And have enabled jackd im my configuration. Wtf, it seems to work… :face_with_open_eyes_and_hand_over_mouth:

The publishing part is the next. That content is left atm.

Btw. i had some trouble with the categorie, and have seen that the syntax has changed in unstable. As u may know, i’m running unstable. Hope that is no problem when building packages…

Btw2. What if someone is using XFCE, related to the kdialog integration??

Yeah, the point of services is that database can be easily configured: for instance it is trivial to enable a postgresql database via a service on a dedicated user for security reasons ^^

I’m quite busy this week so I’ll likely answer more next week, but I mostly meant to download the binary from the derivation with fetchurl (we cannot put directly images or binaries in the nix repository) and ideally create a single derivation that installs both the jack and alsa versions… and ideally different versions for 32 bits, aarch64. Make sure also to properly indent, the bot is really picky about that.

For the issue with thi icon, can you show the derivation?

OK, that could be one of the next projects.

Don’t worry, i hve a 40h job and can’t work on Nix every day…

Ah, ok. That should not be a problem. The file has at it seems a fixed url, where i don’t know how to detect an update.
https://www.stereotool.com/download/stereo_tool_gui_jack_64

Maybe that is one of the next steps… :wink:

Sure…
https://paste.simplylinux.ch/view/a5ca6557

Uhm, it’s too bad they don’t provide one url with a fixed, per-version, url… the hash will become wrong when an update occurs. Not sure what it the recommended solution for this, I’ll check.

I can’t test but my guess it that ${./st-icon.png} refers to a file like /nix/store/somehash-st-icon.png, so when you copy it, the name is somehash-st-icon.png, so try to force the name like cp ${.st-icon.png} $out/share/icons/hicolor/st-icon.png.

That changes nothing.
On another application there are some extra dirs for the size… See picture…

My Icon had have 250x250… Added 48x48 to the path an shrinked the icons… Next try… :wink:

Hmm, don’t know. But not the most importent. And i get a new message on rebuild…

building the system configuration…
trace: warning: The option services.xserver.xkbVariant' defined in /nix/store/vw0k4qbnn8qicqal7m42a6m7r9dpkx4k-sou
rce/configuration.nix’ has been renamed to services.xserver.xkb.variant'. trace: warning: The option services.xserver.layout’ defined in /nix/store/vw0k4qbnn8qicqal7m42a6m7r9dpkx4k-source/ configuration.nix' has been renamed to services.xserver.xkb.layout’.
updating GRUB 2 menu…