this post was submitted on 18 Feb 2024
128 points (93.8% liked)

Linux

47744 readers
733 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Distro agnostic packages like flatpaks and appimages have become extremely popular over the past few years, yet they seem to get a lot of dirt thrown on them because they are super bloated (since they bring all their dependencies with them).

NixPkgs are also distro agnostic, but they are about as light as regular system packages (.deb/.rpm/.PKG) all the while having an impressive 80 000 packages in their repos.

I don't get why more people aren't using them, sure they do need some tweaking but so do flatpaks, my main theory is that there are no graphical installer for them and the CLI installer is lacking (no progress bar, no ETA, strange syntax) I'm also scared that there is a downside to them I dont know about.

(page 3) 36 comments
sorted by: hot top controversial new old
[–] [email protected] 16 points 8 months ago (5 children)

Flatpaks are much better than AppImages because they don't bring in all of their dependencies, they inherit them from a runtime.

load more comments (5 replies)
[–] [email protected] 17 points 8 months ago (10 children)

Nix packages are a pain to manage on non-nix systems and basically all documentation exists for nixos, not nixpkgs.

load more comments (10 replies)
[–] [email protected] 11 points 8 months ago* (last edited 8 months ago) (1 children)

TL:DR; they're the package managers of the future, and I shill for them, but they're still buggy in some areas.

Guix and Nix user here. For all I can shill about store-based file hierarchy, ephemeral environment isn't perfect yet in both of these apps, at least from a GUI application perspective. It's a bug that I've found in Nix, but that should also reflect in Guix. Basically, what's happening here is that due to some impurity in the environment, it uses libraries from the system instead, and apps may stop working. This is a very serious issue, and is directly related to what you're talking about. This problem hides itself when using GuixSD in Guix or NixOS in Nix, but in other foreign distro that have dated libraries, it is very much visible, and you'll be forced to use outdated channels.

[–] [email protected] 2 points 8 months ago (1 children)

Steam Deck is using Flatpaks so.....

[–] [email protected] 6 points 8 months ago

You can also use nixpkgs and AppImages on SteamOS.

[–] [email protected] 5 points 8 months ago* (last edited 8 months ago) (2 children)

Inate complexity that keeps moving as they introduce things like flakes.

Its a declarative configuration management system as package manager. Thats a lot more to handle off the bat than normal linux + flatpak.

[–] [email protected] 3 points 8 months ago (1 children)

It is a whole ecosystem:

  • Nix the package manager
  • Nix the functional language used to declare packages and configurations
  • NixOS that has the package manager and a system configuration in the functional language
  • Home Manager, which provides a configuration on the user level and can be used on NixOS as well as other distros and MacOS

To start out it's completely fine to just install Nix the package manager on a regular distro or on MacOS and use the nix-env command to install some packages. It will automatically use nixpkgs and use working dependencies for each package, whilst also checking if the depency is already installed to avoid installing the same one twice. This is pretty much the same thing as using Flatpak

Flakes explanation:

The Nix package manager has channels to manage package repos. It works like package managers on other distros where you simply have a list of urls to pull packages from, with Nix it would just be the nixpkgs release either a version number for stable or unstable for the unstable rolling release. Any time you install through the package manager or the config in NixOS, it will get the packages from the channel.

The problem is that the channels aren't very reproducible. The repos get updates regularly, especially unstable which updates even faster than Arch. Channels don't provide an easy way to specify a single commit of the repo, except for entering a url with the commit version in it. For stuff like a shell.nix, you'd need to either import nixpkgs from the system's channel or import the url of nixpkgs with a specific commit ID.

Flakes is a feature that for some reason is still experimental after years, but many are already using it. It works like manifest.json and package.lock in a JavaScript project. You have a directory or git repo with a flake.nix file in which you specify your external dependencies like the nixpkgs release in the "inputs" section and your outputs in the "outputs" section, like a NixOS/Home Manager configuration, a shell or a package. Then when you use an output, Nix pulls the inputs and builds the output, it then generates a flake.lock file that contains all the inputs with their specific commit and hash. Now if you use an output again later with the same flake.lock, it will still use the exact same version as last time and should generate the exact same outputs. You just run nix flake update to generate a new flake.lock with new dependencies. You can't use flakes with nix-env simply because installing packages imperatively without a config file defeats the point of reproducibility with flakes.

Flake example with Home Manager:

My Flake Repo/
├── flake.nix - nixpkgs input and home manager configuration output
├── flake.lock - generated by nix
└── home.nix - home manager config import from flake.nix

Here the home.nix file contains the config with the list of packages to install as well as configuration options for those programs. The flake.nix contains the nixpkgs input and a homeManagerConfigurations output that import the home.nix. You can run home manager switch --flake ./My Flake Repo to use that config from the flake. To update run nix flake update.

[–] [email protected] 4 points 8 months ago* (last edited 8 months ago) (4 children)

I appreciate the breakdown, but you've basically made my point for me.

The above, with its many advantages, versus:

Sudo apt install X Y Z G F P -y

Simple, clean, gets it done for near anyone.

load more comments (4 replies)
[–] [email protected] 5 points 8 months ago (2 children)

Inate complexity that keeps moving as they introduce things like flakes.

Flakes solve the problem of reproducibility for which nixpkgs (or other external input) revision to use (e.g. in a software project). The main thing they bring is a npm-like lock file and a predictable interface. You don't have to use them if you don't want that.

Its a declarative configuration management system as package manager.

No it isn't. That's NixOS, which is another thing built on top of Nix and nixpkgs. nixpkgs is first and foremost a package collection.

load more comments (2 replies)
[–] [email protected] 21 points 8 months ago (2 children)

Learning curve? I've meant to get around to it but my to do list is pretty big so far.

Nix is on the destinations to visit but the configurations are still confusing at a glance.

[–] [email protected] 4 points 8 months ago* (last edited 8 months ago) (1 children)

If you use Nix the imperative way (nix profile blah), you don't need to learn the Nix language at all, or write config files. Installing/removing/upgrading packages is just a single command, similar to other package managers.

Eg:

  • To search for bat on nixpkgs: nix search nixpkgs bat
  • To install bat: nix profile install nixpkgs#bat
  • To upgrade all packages: nix profile upgrade '.*'

Ref: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-profile

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 10 points 8 months ago (7 children)

The way nix installs in my root directory in another distro is a no-go for me

load more comments (6 replies)
[–] [email protected] 3 points 8 months ago

My guess would be that it's because Flatpaks are easy. You have a handy GUI tool often pre installed that includes search and one-click install.

If you want something lower level, Arch users have the AUR, and others may actually do that horrifying curl https://... | sh pattern.

Nix pancakes on the other hand.... I have no idea how to use them and generally assume it's the thing NixOS uses. Since I don't use NixOS, I've never given them a second thought.

[–] [email protected] 9 points 8 months ago (2 children)

You're not exactly comparing apples to apples here.

Flatpak and appimages tend to be used in any distro because they can just be downloaded in a one off manner and installed then you're running the application (for the most part). They offer a manager of sorts but you don't need it to use the packages.

For nixpkgs, whike I'm sure I can get a package from the sounds of the sizes the package covers only the application or the library, meaning I still need the dependencies.

So what exactly would make me the user trade my built in tools (apt/pacman/dnf) for nix? Keep in mind no matter how great you feel it is, you need to provide reasoning that motivates me to install and learn this new tool instead of the old ones I have.

[–] [email protected] 7 points 8 months ago* (last edited 8 months ago) (6 children)

For nixpkgs, whike I’m sure I can get a package from the sounds of the sizes the package covers only the application or the library, meaning I still need the dependencies.

When you download/build a nix package, nix will absolutely also download all necessary dependencies.

So what exactly would make me the user trade my built in tools (apt/pacman/dnf) for nix?

Getting a shell with a specific package as a one off. Want ffmpeg? nix-shell -p ffmpeg opens a shell with ffmpeg in its path, and only that shell has it.

Along with that, that means users can install packages for themselves. Limited use for single-user systems, but nonetheless it's possible.

Per-project dependencies. Pretty much the same as above, but the dependencies are declared in a file which is part of the project. In many cases that same file can also be used as a nix package itself, like any other in nixpkgs. Very useful if you write software yourself. Here's an example.

Being a source-based package manager with a cache means that you get all the benefits of prebuilt packages but can easily patch or use other versions of a package, with no difference in use (other than that it will build it locally instead of downloading from the cache).

On a distro with a different main package manager I would probably mainly use it for per-project dependencies though.

[–] [email protected] 1 points 8 months ago

docker run --rm -ti -v "${PWD}:${PWD}" -w "${PWD}" ffmpeg gets me most of the way there. I alias commands like this all the time.

[–] [email protected] 2 points 8 months ago (7 children)

So it sounds like nixpkgs is more akin to virtualenvs in Python rather than a traditional package manager. Is that an accurate statement?

If so, I'd recommend that be your selling point because that's some powerful security.

[–] [email protected] 6 points 8 months ago

Virtualenvs for everything that don't duplicate resources and are reproducible.

load more comments (6 replies)
load more comments (4 replies)
[–] [email protected] 9 points 8 months ago* (last edited 8 months ago) (1 children)

Flatpak still depends on runtimes though, I have a few different runtimes I had to install just because of one or two flatpaks that required them (like for example I have both the gnome and kde flatpak runtimes, despite not running either of those desktop environments)... and they can depend on specific versions of runtimes too! I remember one time flatpak recommended me to uninstall one flatpak program I had because it depended on a deprecated runtime that was no longer supported.

Also, some flatpaks can depend on another flatpak, like how for Godot they are preparing a "parent" flatpak (I don't remember the terminology) that godot games can depend on in order to reduce redundancies when having multiple godot games installed.

Because of those things, you are still likely to require a flatpak remote configured and an internet connection when you install a flatpak. It's not really a fully self contained thing.

Appimages are more self contained.. but even those might make assumptions on what libraries the system might have, which makes them not as universal as they might seem. That or the file needs to be really big, unnecessarily so. Usually, a combination or compromise between both problems, at the discretion of the dev doing the packaging.

The advantage with Nix is that it's more efficient with the users space (because it makes sure you don't get the exact same version of a library installed twice), while making it impossible to have a dependency conflict regardless of how old or new is what you wanna install (which is something the package manager from your typical distro can't do).

[–] [email protected] 5 points 8 months ago

All of these points are completely correct and paint an accurate picture of the inherent issues with both technologies.

My intent with my earlier comment was to show how flatpaks and appimages were different from traditional package managers at a high level so I could ask what made nixpkgs different from something I felt and still kinda feel is a more accurate comparison which are traditional package managers like apt etc.

The big selling point to me now is that nixpkgs seem to work similarly to virtualenvs from Python which is cool.

[–] [email protected] 2 points 8 months ago (2 children)

How does it solve the problem of dependencies without becoming bloated?

load more comments (1 replies)
[–] [email protected] 39 points 8 months ago

One reason is probably that people don't know about them.

load more comments
view more: ‹ prev next ›