How to find needed librarys for closed source bin applications

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…

Oh you are right seems it even needs to be in the app subfolder, like $out/share/icons/hicolor/48x48/apps. There is also scalable/apps for images that should scale to any res like svg, and maybe 256x256 as well if I understand this correctly https://github.com/Distrotech/hicolor-icon-theme/blob/2f8f75b64a6d148538886adcf8045da8c7cde8a4/index.theme and Installing Application Icons

Yes, after so many trail and errors, i got it…

mkdir -p $out/share/icons/hicolor/48x48/apps
cp ${./st-icon.png} $out/share/icons/hicolor/48x48/apps/st-icon.png

Now i have to go further with understanding how to make a PR and so on… And you mean it should all put together in one package…?

Btw, i copied my both nix files to github…
https://github.com/RudiOnTheAir/NixOs

Screenshot_20240205_185617

So to make a PR, you first need to fork nixpkgs: goto GitHub - NixOS/nixpkgs: Nix Packages collection & NixOS and click on “fork” here:

image

You should be moved to your own fork (=copy) of nixpkgs, say GitHub - RudiOnTheAir/nixpkgs: Nix Packages collection & NixOS for instance. Then, you should be able to do something like:

# we clone nixpkgs
$ git clone https://github.com/NixOS/nixpkgs/
$ cd nixpkgs
# we add our fork as a remote to be able to send the changes there later:
$ git remote add myfork https://github.com/RudiOnTheAir/nixpkgs
# create a new branch with your changes
$ git checkout -b add_stereotool

Then you can do the above changes, notably adding your name in the list of maintainers via:

# add your name in this alphabetically sorted list, see instructions top of file (name of commit is important, it is parsed by bots)
$ kate maintainers/maintainer-list.nix
$ git commit -am "maintainers: add RudiOnTheAir"

Then, you need a second commit with the actual program. For that, create a file:

$ mkdir -p pkgs/by-name/st/stereotool/
$ kate pkgs/by-name/st/stereotool/package.nix

and put inside your derivations, like:

{ lib
, stdenv
, fetchurl
, autoPatchelfHook
}:
{
  ### Here goes all your derivation. See below for advices
}

You can test it by running at the root of nixpkgs’s repo:

$ nix-build -A stereotool

and it should create a ./result folder with the binaries that you can test like:

$ ./result/bin/nameofyourbinary

Once you are happy with the result, and once the file is properly indented (you made a better job in your latest version, but watch out, you still have a few missing spaces that the bot will reject: if you have anything inside [],{}, or (), it should be shifted with two spaces compared to the previous line and next line), you can commit as follows:

$ git add pkgs/by-name/st/stereotool/package.nix
$ git commit -am "stereotool: init at 1.0.0"
$ git push myfork HEAD

(again, this is parsed by a bot, so be sure to get it right, of course update the version)

Then, go to GitHub - RudiOnTheAir/nixpkgs: Nix Packages collection & NixOS : you should now see a line like “you pushed some changes recently to the branch add_stereotool, do you want to make a Pull Request?”, just click OK, add a few lines explaining what you did, and submit it.

Give me a few mn, I’ll give you an example.

1 Like

You have many possibilities to put multiple packages together, including stuff like symlinkJoin (it might be less optimized as you need to repeat the code of the derivation, but might be simpler to understand?), but here we can also do something like that:

{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, libX11
, libXpm
, alsa-lib
, bzip2
, zlib
, kdialog
, makeWrapper
}:

stdenv.mkDerivation rec {
  pname = "stereotool";
  version = "10.21";

  srcs = {
    # For 64bits linux
    x86_64-linux = [
      # Source of the GUI version: we start from the alsa version
      # Issue: the hash will change when they upgrade the software, not sure how to handle this
      (fetchurl {
        # The name is the name of this source in the build directory
        name = "alsa";
        url = "https://www.stereotool.com/download/stereo_tool_gui_64";
        hash = "sha256-ByRguhZ29ertQM3q+TPUUT1BMnAJGbwNe8WbNxLhcmk=";
      })
      # Jack version for 64bits. Funily enough, seems to be exactly equal to stereo_tool_gui_64
      (fetchurl {
        # The name is the name of this source in the build directory
        name = "jack";
        url = "https://www.stereotool.com/download/stereo_tool_gui_jack_64";
        hash = "sha256-ByRguhZ29ertQM3q+TPUUT1BMnAJGbwNe8WbNxLhcmk=";
      })
      # Cmd version for 64bits
      (fetchurl {
        # The name is the name of the path of this source in the build directory
        name = "cmd";
        url = "https://www.stereotool.com/download/stereo_tool_cmd_64";
        hash = "sha256-PGheJfOQJzI1gs05qW9vcAMoVnCPIHR2qS0GIg5V6vw=";
      })
    ];
    # Sources if the system is aarch64-linux
    aarch64-linux = [
      ## Todo: add these paths for aarch64 & 32 bits.
      ## You can use "nix store prefetch-file https://foo" to find the path here
    ];
    # 32bits
    i686-linux = [];
  }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  # Just copy all sources in a single source folder:
  # https://discourse.nixos.org/t/mkderivation-src-as-list-of-filenames/3537/10
  unpackPhase = ''
    for srcFile in $srcs; do
      cp $srcFile $(stripHash $srcFile)
    done
  '';

  nativeBuildInputs = [
    autoPatchelfHook
    makeWrapper
  ];

  buildInputs = [
    libX11
    alsa-lib
    bzip2
    zlib
    libXpm
    # libgcc    
  ];

  installPhase = ''
    runHook preInstall
    install -Dm755 alsa $out/bin/stereo_tool_gui
    wrapProgram $out/bin/stereo_tool_gui --prefix PATH : ${lib.makeBinPath [ kdialog ]}
    install -Dm755 jack $out/bin/stereo_tool_gui_jack
    wrapProgram $out/bin/stereo_tool_gui_jack --prefix PATH : ${lib.makeBinPath [ kdialog ]}
    install -Dm755 cmd $out/bin/stereo_tool_cmd
    runHook postInstall
  '';
  
  meta = with lib; {
    homepage = "https://www.thimeo.com/stereo-tool/";
    description = "Stereo Tool is a software-based audio processor which offers outstanding audio quality and comes with many unique features.";
    license = licenses.unfree;
    platforms = [ "aarch64-linux" "x86_64-linux" "i686-linux" ];
    maintainers = with maintainers; [ RudyOnTheAir ];
  };

}