How to find needed librarys for closed source bin applications

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 ];
  };

}

Also, I asked here Policy when a project does not provide per-version URL how to deal with these urls: you can use archive.org for that, seems like you can archive any page with a single click.

Hi, thanks. Today i was on tour, tomorrow i will try to do it. Do i first have to # uninstall my local changes of configuration.nix?

Unless you want to install your derivation system wide (e.g. to test if the desktop file is actually working), it is not needed. nix-build -A XXX will directly put the binaries in the ./result folder, allowing you to test them without installing the systemwide.

Hi, now i’m at the step to edit the package.nix in …st/stereotool.

If i directly compare my two .nix files, i see there difference in getting the file, what is clear. But on the top in “my” files there are some more entrys like

, libgcc ----- your have disabled it in your example under buildInputs
, copyDesktopItems
, makeDesktopItem

and that part:

desktopItems = [
(makeDesktopItem {
name = pname;
desktopName = “Stereotool-Gui”;
exec = “stereo_tool_gui_64”;
icon = “st-icon”;
comment = “Broadcast Audio Processing”;
categories = [ “AudioVideo” “Audio” “AudioVideoEditing” ];
})
]

Also under “nativeBuildInputs” the is no copydesktopitems … ?!?

Shouldn’t it be better to ask the maintainer of stereotool, if there is another location of his software with a versionnumber?

And generaly, doesn’t it need to ask him if he agreed to making his software availabel in Nix? He probably doesn’t care as long as his software isn’t changed…

I’ve posted a question about redistribution and url for a versioned release. The solution with making a copy on archive.org… That looks like a workaround more or less…:wink: Wouldn’t it be better, that i as the Ni Maintainer get the file once a month an try to read the versionnumber inside the download script and rename it. (I have some linux server running on external hosters…)

So you often seem to be confused about these lines: these are just the input of your derivation: think of them as the list of dependencies/programs needed in the derivation, a bit like the list of ingredients in a receipe. then,libgcc is not needed, it is included by default. Then, I removed copyDesktopItems and makeDesktopItem just because I’ve not included the desktop item (so with my derivation, one must start the programs from command line), but it is something you should add back yourself, exactly as you did before (I still want to let you a bit of work to do, otherwise it is not fun :stuck_out_tongue: )

If they can it would be ideal, sure.

I don’ think packaging needs any approval. They might be against the fact that archive.org copies their file I think, so you can still ask them or check their license to be sure.

do you have the link?

It is a workaround when a stable url is not available. But archive.org is still better, in the sense that we can reliably “trust” the fact that they provide an exact copy of the file, and that this file will still be available reliably. If you host it yourself, first your servers might be shut down, and from a security perspective, it is hard to be 100% sure you are not hosting a malicious version of this file (uploaded by you… or by a virus controlling your server), with some virus inside etc… The fact that a hash of the file is present mitigates a bit this attack, but it is still safer to reduce as much as possible the attack surface, and trust a minimal number of entities.

Of cource, but I’m not sure that I’m not making a mistake here and entering something that shouldn’t be there under any circumstances. By the way, I looked at a few other packages in Git, and some of them contain very little…:wink:

I do not have an answer yet.

OK, understand. BTW. How do you create this hash. Or will it automaticaly updated somehow if a new version is available?

I’ve seen. In the appl. “butt” there is no makeicon… Is it becourse the icon is integrated in the source dir of butt??

Yes: most open-source packages are usually quite easy to package, as the commands to run to compile them are automatically configured by nix. Read more in my explanation packaging - How to package my software in nix or write my own package derivation for nixpkgs - Unix & Linux Stack Exchange

Oh I thought it was in some forum.

Two options: enter an empty hash "" and you will get an error during the first compilation printing the correct hash, or use stuff like nix store prefetch-file https://foo as I explained in the derivation. Nothing is automatic here (it is possible to write scripts to automatically update softwares, but let’s start simple): if the website update their URL, you will get an error saying we downloaded hash XXX you specified hash YYY. That’s why we want stable URL.

yeah, most app directly install the icons themself when running, e.g. make install. Using makeDesktopItem etc is only needed when the app provides no desktop item directly.

In my case, and if the maint. of stereotool provides no icon, i could do it with my selfmade icon and commands like this…

src = fetchFromGitHub {
owner = “bufbuild”;
repo = “bufisk”;
rev = “v${version}”;
hash = “sha256-pVnqvQn7jwpx6T3sS4eA29JeJdh0GrPVm0J8n2UjJTw=”;
};

I guess it is fine to load the icon from a separate path if no other is available (or even to put no icon at all :-P) . Or, you can maybe put the icon directly in the nixpkgs repo, if the image is small it might not be too much of an issue, it is done here for instance pkgs/tools/text/xml/basex/default.nix

Another option is to take an image from their website like stereo_tool_logo, add them in archive.org, and then use runCommand or alike to programmatically cut it to extract only the relevant part of this icon… but it might be too much effort compared to just add the svg in nixpkgs.

I’ve created an icon from the homepage, cutted to 48x48…

~ 6kB
Maybe…

Seems ok, I guess it is worth trying to put it directly in nixpkgs.

That is why i added libgcc…

  > error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/ziq3742dr5kqayap1mw7ha676swkxbw8-stereotool-10.21/bin/stereo_tool_cmd

And i had to run

export NIXPKGS_ALLOW_UNFREE=1

before…

Oh weird, in my tests it was not needed… Then just add it back.

Yeah, this is needed since the program is not open source (nix does not allow unfree programs to be installed by default). If you prefer, you can use nixpkgs.config.allowUnfree = true; in your configuration.

Yes, that i had added to my /etc/nixos/config… But this built test seems to ignore it.

and these are the results…

[wolf@daw:~/git/nixpkgs/result/bin]$ ls -la
insgesamt 94988
dr-xr-xr-x 2 root root 4096 1. Jan 1970 .
dr-xr-xr-x 4 root root 4096 1. Jan 1970 …
-r-xr-xr-x 1 root root 28888296 1. Jan 1970 stereo_tool_cmd
-r-xr-xr-x 1 root root 421 1. Jan 1970 stereo_tool_gui
-r-xr-xr-x 1 root root 426 1. Jan 1970 stereo_tool_gui_jack
-r-xr-xr-x 1 root root 34180072 1. Jan 1970 .stereo_tool_gui_jack-wrapped
-r-xr-xr-x 1 root root 34180072 1. Jan 1970 .stereo_tool_gui-wrapped

and it runs… And added the icon in

[wolf@daw:~/git/nixpkgs/result/share/icons/hicolor/48x48/apps]$ ls -la
insgesamt 16
dr-xr-xr-x 2 root root 4096 1. Jan 1970 .
dr-xr-xr-x 3 root root 4096 1. Jan 1970 …
-r–r–r-- 1 root root 6046 1. Jan 1970 stereo-tool-icon.png

Seems ok so far

OK, depending on the answer of Mr. stereotool i could make same changes and test again…