Remix.run Logo
▲ dark-star a day ago

Isn't this possible on any Linux distro? Fetch the source package, patch it, rebuild, install?

▲cloudfudge a day ago | parent | next [-]

The difference is in what "install" means. With most install methods, you're just blasting bits onto a disk and the connection between those bits, the package that created them, and their dependencies, is maybe tracked in a database. A database that can be inconsistent. And uninstalling things doesn't necessarily restore everything to the state that it was in before the install. This is deeply unsatisfying once you've seen how it can be.

As an example, you can install app A that depends on packages P and Q and then uninstall A, but P and Q won't necessarily be uninstalled. Or you can also have app B that depends on a different version of P and there's a conflict. This completely goes away with nix because a thing and its dependencies are represented as a completely standalone closure, and the state of your machine is just the sum of all the closures you want. It's trivial to go back to the set of closures you had 30 seconds ago if you didn't like the result of the change you just made.

It's truly magical.

▲pitchlatte a day ago | parent | next [-]

i’ve been reading about Nix and trying to get it for a while and reading your comment made me think about journaling file systems. would that be an appropriate comparison here? i understand that the declarative paradigm is a fundamentally different design of course.

▲cloudfudge 21 hours ago | parent | next [-]

That would be another way to get the rollback property, but that doesn't solve for example the dependency collision problem. It also doesn't solve the problem of deleting something another package depends on, other than that you can roll it back. With nix, if the package is referenced in a closure, it simply isn't deleted. It's like magical garbage collection for every part of your system.

And it isn't just a snapshot of your machine state, it's a definition of how the machine state got that way, plus a mechanism for arbitrarily applying any such definition. You don't even have to restrict yourself to a linear roll-forward-roll-back path. You can install A, B, C, D, E and then remove C and know that you aren't breaking anything, even though you were never in that state before.

▲krautsauer a day ago | parent | prev [-]

You can e.g. use btrfs, put /usr in a subvolume, regularily snapshot it, and roll back when you don't like some modification. What you still don't get is the state in /usr being defined by some manageable amount of code, where you can easily say "rip out this part" without rolling back everything you did afterwards.

▲dark-star 6 hours ago | parent | prev [-]

most package managers these days know about "orphaned packages" and offer to uninstall those as well, if no other package needs them.

Also, you are claiming that a package manager database can become corrupted. While that is true (but unlikely), it is equally true that some part of your Nix installation can become corrupted. Combined with an advanced filesystem like btrfs you can also go back to the exact system state before the installation of your package.

Worse comes to worst, you can re-install with a list of your dpkg --get-selections to get the exact same state as before (similar to how a declarative installation of Nix would be reset from scratch)

I mean I see the advantages of Nix from the point of view of a daily-driver desktop (or server) OS, but I don't see any benefit from using it to sandbox an AI agent. If you are already a NixOS user, then yeah, it's probably the easiest pick for a VM. But the learning curve is rather high, and if you're, say, an Arch user you would probably just stick to an Arch VM which offers the same benefits (maybe in a slightly less user-friendly way) but doesn't require you to commit to the admittedly bizarre way of how NixOS works, and its two config languages etc.

▲cloudfudge an hour ago | parent [-]

> it is equally true that some part of your Nix installation can become corrupted

I think a [citation needed] is in order here. The number of times other package dbs have failed me and required reinstallation of packages that otherwise should be in a good state (countless)*, vs the number of times a nix installation has become corrupted (zero) tells me otherwise. I think the fact that the nix store is readonly and the packages are absolutely required to declare their dependencies in a strong way (as opposed to being able to accidentally rely on stuff that happens to be installed) is a huge part of this. When your entire system is symlinks into a set of readonly self-contained blobs, the only "corruption" is basically "your disk is broken."

* There's a reason apt has a "--fix-broken" option and when I type "rpm" into google the first autocomplete is "rpm database corruption".

▲kam a day ago | parent | prev | next [-]

Possible, yes. Easy, no.

For example on most distros an updated package will supersede your rebuilt one and you'd need to build it again manually. On NixOS, it will rebuild your with your patch automatically.

▲orbital-decay a day ago | parent | prev | next [-]

Of course, though maintaining a bunch of these is hell unless it's automated. Nix does exactly that, it automates what should be automated.

▲drdexebtjl a day ago | parent | prev | next [-]

Yeah, but you don’t have to do anything when upstream updates, provided your patch still applies. You continue getting updates normally.

▲bigstrat2003 a day ago | parent | prev [-]

In particular, Gentoo makes it really easy to patch packages you install. It's one of the ways in which the source-based nature really gives you a lot of power.