Advice requested on whether this is the correct way to use pkgs/by-name

I’ve been using nixos for a while, but mostly as an end-user and I am trying to slowly learn how to contribute. I would like to contribute an update for pdfstudio, which has a new version each year. pdfstudio2021, pdfstudio2022, etc. are defined in all-packages.nix and use callPackage to call the same code with different parameters for the different years. I created a pull request to add pdfstudio2024 and it worked locally but failed the CI because of the check to add it to pkgs/by-name.

I have since figured out how to make it work under pkgs/by-name, but as far as I can tell, it isn’t possible to reuse the same code for each version, rather that a separate directory will be needed for each version. This discussion seems to confirm that pkgs/by-name can’t handle multiple versions, but before I submit a new pull request I wanted to check that I was approaching this in the right way. If this is the right thing to do, this would mean that the older versions would be in all-packages.nix and under the old hierarchy, while this version would be under pkgs/by-name.

Is this the correct thing to do?


I think yes, this can’t go in pkgs/by-name, but to please CI you need to put that block with inherit in pkgs/top-level/all-packages.nix, maybe replacing the previous couple of eg. pdfstudio2023 = callPackage ../applications/misc/pdfstudio { year = "2023"; }; in that file, if I understand correctly nixpkgs/pkgs/by-name/ at 614d4b0abbcc78acc950fa8fbca375cb341834e4 · NixOS/nixpkgs · GitHub.

At least, this is what I did in gruppled-cursors, gruppled-lite-cursors: init at 1.0.0 by nim65s · Pull Request #242667 · NixOS/nixpkgs · GitHub.


Thank you! That example of yours was what I needed. I couldn’t figure out from the README where I should add the inherit and accompanying code. I’ve re-written it and my PR has passed the checks.