News for hackers. Stuff that matters.
Re:NixOS Linux by pachico on Sunday January 10, 2021 @02:47PM (#25718836)
Just to see if I understand, does this mean you might end up having dozens of libcurls?
Re:NixOS Linux by ertian on Sunday January 10, 2021 @03:20PM (#25719226)
Yeah, you potentially could.

Generally you don't specify a specific version as a dependency unless it's necessary, but when 'building' the system, specific versions are used. If things break during an upgrade you can roll back to the previous version. Keeping those older builds around will mean keeping older versions of the packages used in those builds (libcurl, for example). Periodically, you can purge older generations (i.e. builds) and collect garbage, which will clear out packages that aren't used anymore. It would be very strange to end up in a situation where you had dozens of instances of libcurl _being used simultaneously_ (though I guess that would be possible if lots of packages had very special requirements, and ended up building libcurl with different flags or something).

There may be circumstances where you have a _specific_ version dependency, and you can specify that too. That would mean having multiple copies of the same package, even in a single generation. Obviously this usually means major versions, so you don't usually see _dozens_ of them. Having specific dependencies on minor versions would be a major code smell IMHO.

Anecdotally, my NixOS systems (both desktops and servers) can grow up to, say, ~50 gb of system files in a few months, at which point I'll clear out older generations and GC, which gets them down closer to a typical Linux distro size. Once or twice, I've seen a system balloon up over 100G when I was doing a lot of experimenting with packages.

Oh, and incidentally, most of the different versions are only visible to the packages that depend on them. Your 'default' environment is one such package, and only sees one of each of it's dependencies. It's not like you have dozens of instances of packages crowding /lib or anything (since /lib doesn't exist in the first place). You have to go looking in the Nix package store to find the actual files.

Re:NixOS Linux by Ericson2314 on Sunday January 10, 2021 @03:50PM (#25719624)
You could or you couldn't. It's your choice:

- Traditional distro: you cannot end up with that

- Flatpack, snap etc.: you cannot avoid that

Nixpkgs doesn't wontonly package multiple versions of libraries. But as you upgrade you will accumulate old builds of libraries until you GC. The meaningful question is not how many of X do you have installed, but whether you have multiple versions of X reachable from GC roots.

Re:NixOS Linux by MetaDark on Sunday January 10, 2021 @03:08PM (#25719089)
It could, depending on your use case, but normally all packages from nixpkgs share the same libcurl, so when libcurl is updated, all packages that depend on it will also be updated.

The old libcurl will still exist on your system to allow you to rollback to previous states of your system, but you can always run nix-collect-garbage if you want to free up disk space.

This is similar to the situation in Arch Linux where pacman keeps all downloaded packages, and you have to run paccache if you want to free space.

Re:NixOS Linux by choward on Sunday January 10, 2021 @03:05PM (#25719040)
If any of software relies on different versions, yes. It beats not being able to use something because you can only have one version of a library shared.
Re:NixOS Linux by 1vuio0pswjnm7 on Sunday January 10, 2021 @03:16PM (#25719170)
How does this work with compiling software. For example, I routinely compile programs that use different versions of openssl. Does NixOS make this process any easier.
Re:NixOS Linux by mcint on Sunday January 10, 2021 @03:45PM (#25719551)
This is the killer use case, and the initial primary(?) design justification.

https://nixos.org/guides/how-nix-works.html

https://edolstra.github.io/pubs/nixos-icfp2008-final.pdf

Re:NixOS Linux by rowanG077 on Sunday January 10, 2021 @03:19PM (#25719212)
Yes that's one of the greatest things about nix. You can have 100 pieces of software installed that all use a different curl version without issues. You can also develop 100 piece of software/compile that all use a different curl version at once.
Re:NixOS Linux by pachico on Sunday January 10, 2021 @03:09PM (#25719096)
I understand, thanks. It wasn't a criticism, I honestly asked out of ignorance.
Re:NixOS Linux by ReactiveJelly on Sunday January 10, 2021 @03:05PM (#25719041)
As an optional fun fact, from my Arch system:

- libcurl is 615,616 bytes

- curl itself is another 192,480 bytes

Not counting man pages.

Re:NixOS Linux by kaba0 on Sunday January 10, 2021 @06:40PM (#25721705)
Not repeating the others: If a package does end up using multiple version of the same lib, nixos can even deduplicate it somewhat, by symlinking one’s documentations to the other’s.
Re:NixOS Linux by smilliken on Monday January 11, 2021 @12:31AM (#25724969)
There's an optimzation I'm aware of where nix will de-duplicate individual files with hard links. This wouldn't be safe in almost any other context, but is safe with nix because the files are immutable. So you have have 100 variations of libcurl and only "pay" for the unique files.
Re:NixOS Linux by colejohnson66 on Sunday January 10, 2021 @03:02PM (#25719006)
Is that any different that Docker?
Re:NixOS Linux by choward on Sunday January 10, 2021 @03:06PM (#25719069)
It's better actually since you can share some libraries when possible.
Re:NixOS Linux by axelf4 on Sunday January 10, 2021 @03:16PM (#25719172)
Nix derivations are also lighter than containers. Just ordinary packages.