Enough with "world files are great". What are they?

I only recently realized that I've only talked about using world files, but never really explained their purpose. I'll try to break down what they are used for, and why knoming how they work is a useful thing. World files are a record of everything that is installed on the system explicitly. When you install, say Firefox, it will not be the only thing that needs installed. It uses shared libraries for audio, video, and many other things, but you generally don't care about any of that. You want Firefox, so you explicitly pull that in. All of the other dependencies are the package manager's problem, and are not recorded in a world file. This is a conenient place that you can go to in order to eassily see what's intentionally installed, let you clean out lines of things you don't care about and even things you have forgotten about over the ages.

What else can I do with world files?

Occasional cleanup is a good thing for any mutable system, but world files can also be used to reconstruct a system. If you back that simple text file up, you can transfer it to a new system, and effectively sync to that, and things will be added and removed automatically in order to make the file in sync with the system. Package sets also let you install sets of packages and enable/disable them together. This may be useful if you want to switch audio subsystems from one to another, and possibly even back. All packages can be swapped out at a time to ensure that nothing can be forgotten, and even lets you know after time what packages are used for that task. It's a great organizational tool, especially as systems get older and you forget what's installed, and why it's there. Because world files are almost exclusive to Gentoo and Alpine, I wrote pmm to emulate this behavior on other platforms.

So what about Nix?

Nix takes this concept further. Not only can you treat it like a "normal" package manager, but by default, it has access to generations. This allows you to roll back to previous versions if you decide that you don't like the changes. When paired with add-ons like NixOS, darwin-nix, or home-manager to extend this to your operating system and give you files to define "what the system looks like" similar to a world file. This isn't the limit to Nix however. You can tie other things like configs into the system, allowing Nix to manage not only installed packages, but how they are configured. You can take an nginx server config along with the package and bring it to a new system all in one tool as opposed to having packages and configs not be aware of each other in terms of the package management. Tooling like Nix Flakes is currently marked as unstable as the API is changing rapidly, but this allows you to even version lock packages or dependancies in order to increase stability and reproducability. This all goes far beyond what world files are capable of, but none of it forced on you other than generations, which is hard to complain about if you have a bit of free disk space to store it. It also allows having multiple versions of the same package installed, which is not common on most package managers, and is useful for having multiple versions of libraries, or just testing new versions before switching. Not having that ability has caused a lot of breakage on other systems, and is one of the reasons that projects like Flatpak are trying to solve.

That got quite a bit off the scope of world files, but that's why this has the "ramble" tag. Hopefully this off the wall post helped someone understand why world files are so great, or at least learned something in the ramble.