miniblog.

← Back to all posts
87
The most common selling point I hear for Nix is having a list of all the packages you need. On a traditional Linux distro, I just install things and forget about them. A curated, commented list would certainly be handy when I have a new system.

7 Comments

Not really, u can do this on a traditional distro as well. Eg for Debian-based u could have a script like: #!/bin/bash sudo apt update packages=( package1 package2 package3 ) sudo apt install -y "${packages[@]}" Which is easy to understand & maintain, without learning the Nix language
What I *do* like about Nix however is its portability. I can install programs, without root or special privileges, on any Linux distro, independently of the system package manager, without messing with system packages. Which is great for immutable distros and limited access environments.
That doesn't have the nice declarative properties though. It doesn't guarantee the version installed (running it next week could give a different version), and removing an item from the list doesn't uninstall it.
@wilfredh, also nix-shell (and later garbage collection) when one does lotta drive-by contributions
Version guarantees is pointless for most people, unless you're a dev/tester, in which case you'd be using a dedicated container/sandboxed environment anyways. And how many people remove packages frequently that it's a big requirement? And if it is, it's simple enough to amend the script to do so:
manual_packages=$(apt list --manual-installed=true 2>/dev/null | grep -v "Listing..." | awk -F'/' '{print $1}') for pkg in $manual_packages; do if ! printf '%s\n' "${packages[@]}" | grep -q "^${pkg}$"; then echo "Removing package: $pkg" sudo apt remove -y "$pkg" fi done
@wilfredh You get a similar thing with distros that use apk like Alpine and Chimera. The /etc/apk/world file tracks constraints and apk will solve those constraints to get the system into the desired state. https://man.archlinux.org/man/apk-world.5.en