I think the least that distros can do, is allow listing all packages and system settings in config files like .toml
rather than having to type in every single package to install, or click through system setting GUIs to setup. Would that require using a whole programming language or system like NIx?
While NixOS works much differently from most distros, that’s the only reason I use it: package and system settings in text files. If I fix something, it’s fixed permanently, I don’t need to hunt down files in random directories if I want to change a setting. If I ever need to reinstall the OS I don’t have to write dnf install every single damn package
and manually setup all that up all over again. Having daily-drove Windows macOS & Fedora as throughout the years, my setups have felt hacky as well as houses of cards as I’ve wanted or had to set them up again (I don’t mean Fedora specifically, but distros in general).
Basically it feels insane that it’s the way most linux users and servers in the world operate. If I, a humble computer hobbyist can figure out Nix, why don’t more users do so, and why is Nix so niche?
I’m sure many people don’t even think about that. Having to reinstall all your packages from scratch is not something they do frequently.
And for the people who are looking to optimize the initial setup, there are many ways to do it without a declarative package manager. You can:
- Write a script for your initial setup that includes installing packages
- Use a tool like ansible
- Use meta-packages
- Export your currently installed packages to a file and pass that to the package manager on the new installation
Package metadata isn’t stored in text files because there’s an amazing technology called the database.
All you have to do is learn how to use your package manager. Spend time reading the man pages and learn the options, and you can query everything you need.
Maybe try guix
You can backup your list of packages to .txt and install from .txt using
apt
so I don’t really know what more you would need. I literally just did it last week to install a new distro.apt list --manual-installed > ubuntu_system_pkgs.txt
But then you need the pins and repositories you had before. I end up pasting a long ass chain of commands every time I get a VPS up just to set it up.
You don’t backup
/etc/apt/sources
? .dI’d have to also back up /etc/apt/preferences.d
Much easier to just copy and paste a block of commands when I get a VPS up
deleted by creator
But they do.
Yeah and on Arch-based systems:
Backup Packages
Back up explicitly installed package list:
pacman -Qqe > ~/packages.txt
Back up explicitly installed foreign packages list (i.e. the AUR):
pacman -Qqm > ~/foreign_packages.txt
Backup the pacman config/mirrors:
cp /etc/pacman.conf ~/pacman.conf.backup cp -r /etc/pacman.d/ ~/pacman.d.backup
Restore Packages
Restore the pacman config/mirrors:
sudo cp ~/pacman.conf.backup /etc/pacman.conf sudo cp -r ~/pacman.d.backup/* /etc/pacman.d/
Sync the system and update packages:
sudo pacman -Syu
Reinstall packages:
sudo pacman -S --needed - < ~/packages.txt
Reinstall foreign packages:
yay -S --needed - < ~/foreign_packages.txt
Can I replace yay with Paru and it still works?
Sure can! Paru is a drop-in replacement, so you can just replace
yay
withparu
and the rest of the command remains the same.Alr thanks
Sounds like it also lists all dependencies. I would only want a list of those packages that I asked for. Package manager should handle dependencies, not me.
You can filter for manually installed packages yes.
There are some package managers that do that.
Alpine Linux’s
apk
stores a list of required packages for the current system in a single file,/etc/apk/world
. usingapk add
orapk del
adds or removes a package from this list, then calculates how to get to that stage (adding all the dependencies, resolving conflicts…) and then installs the needed stuff (and removes the unneeded) to make it match.The file can be edited or replaced using any other tools, then
apk fix
will do the same recalculation and installation/removal steps.You need some ansible love in your life!
This is the way. Ansible is underrated by the self hosting community.
If i remember correctly you can pass a txt file to pacman when installing packages, but i could be wrong. There is also BlendOS, which from what i can tell has an immutable base, with a toml config on top of it to install the additional packages you want. Never tried it myself though. I also use NixOS because i wanted to be able to reproduce my riced out system more easily if i have to reinstall. I do wish this space had some more competition, because it might make this way of running a distro more approachable. The closest thing i’ve seen aside from guix is probably those ublue customized images that you can build, but i’m not sure how comparable that is.
If I, a humble computer hobbyist can figure out Nix, why don’t more users do so, and why is Nix so niche?
My guess as to why this isn’t a more central feature of Linux distros is that this is not something most users need. If you need to reinstall the OS because you broke it, then a full system backup is probably more convenient, even if it’s less than optimal to back up packages which you could download. If you need to reinstall the OS because you want a clean slate when upgrading to a new version, then your package list for the old version could cause a lot of conflicts as maintainers regularly remove and add new packages.
I have backed up my zsh, vim, tmux, etc. configs and written a few shell scripts which install them and download vim plugins etc. If I ever need to reinstall the OS I would use these. However, in the last 20 years since I ditched Windows I have reinstalled Linux exactly two times: Once because I was an idiot and didn’t have a proper backup when I accidentally formatted the wrong HDD, and once when I switched from Xubuntu to Fedora in which case a package list wouldn’t have been usable.
I want to conveniently share setups between my desktop and laptop. If you do this manually you will find out one both have small differences
At the same time, I may document that this computer works better with pipewire (or with pulse, depends on which one has issues) and commit to the repository
Gentoo can do this with Portage sets. They’re essentially a more simple way of creating a meta package which just installs other packages. And you can also write config packages which installs configuration for other packages.
Unless I’m missing something, you can do this fairly simply already. I have a post-install script I run on all of my machines which sets up all network shares and runs ‘apt install whole bunch of packages’ to get things into a ready-to-roll state.