I’m just trying to add a new top-level package and don’t know where to add it in the humongous file pkgs/top-level/all-packages.nix
. This made me ask myself why the entries in this file are neither sorted nor categorized. The only message I can find is the friendly but unhelpful comment at the beginning of the file:
/* The top-level package collection of nixpkgs.
* It is sorted by categories corresponding to the folder names
* in the /pkgs folder. Inside the categories packages are roughly
* sorted by alphabet, but strict sorting has been long lost due
* to merges. Please use the full-text search of your editor. ;)
* Hint: ### starts category names.
*/
It is unhelpful because it is untrue. The packages jump wildly between folder structures. A snippet:
aether = callPackage ../applications/networking/aether { };
alda = callPackage ../development/interpreters/alda { };
align = callPackage ../tools/text/align { };
althttpd = callPackage ../servers/althttpd { };
among-sus = callPackage ../games/among-sus { };
There is some vague alphabetic sorting going on, but it’s not kept throughout the file. I tried to search with Issues · NixOS/nixpkgs · GitHub, but didn’t find anything helpful.
I don’t understand why we don’t split this big file up. We have a great categorisation in form of the folder structure already. Why doesn’t every folder simply contain a file e.g. tools/text/all-packages.nix
which contains all packages of that subcategory, and further up the tree we simply merge these sets?
Some advantages I can see:
- Maintainers will immediately know where to put their packages
- Great for newcomers
- No need to scroll and search and ponder endlessly
- Github will be able to display
all-packages.nix
- My guess: Merge conflicts are reduced, because adding new packages is split up on many files, sorted by topic
- We could even add the category to the
meta
attribute in an orderly way, in the long run allowing people to filter on that information e.g. in the NixOS Search search
Some disadvantages:
- It’s a tiny bit harder to search for an existing package. Rebuttal: You probably have a text editor capable of searching for the string
my-package =
, and you might even know the category of your package. - Extra evaluation when merging the sets. Are there some reliable estimates how much that would be?
- Might take some time to convert to this new structure. Rebuttal: Work can maybe be automatized in a simple way. In any case it can be split efficiently between categories.