187
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 28 Aug 2023
187 points (100.0% liked)
Linux
48376 readers
967 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
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
In the case of NixOS at least, 'immutable' doesn't mean you can't change the system at all.
It just means you cannot change the currently installed set of packages and services (generation in NixOS parlance); all you can do is create new ones and delete old ones.
Basically every update might as well be a complete reinstall of
/usr
,/etc
and whatnot if you compare it to traditional distros.If you can't change etc, how do you configure your software?
Unlike a traditionally managed system, you manually keep an install list of all used system packages (including current version). It's conceptually similar to how conventional package managers might have a mirror configuration list. Within this list, you're also sprinkling in individual package options which Nix will automatically apply for you (the options that Nix "sees" are manually coded in by whoever did the bundling of that particular Nix package).
In other words: you're treating packages as if they were configuration and bundling that in with the actual configuration under a unified framework. This basically means that you can think of Nix packages as wrappers bundling the base software plus instructions for a config file generator. That's effectively the "gimmick" of Nix: config files are routinely regenerated, so in everyday use they're conceptually equivalent to an abstract interface between the Nix package manager and the software proper.
Worth mentioning at this point is the fact that the core Nix ecosystem is all about managing system-level software; Nix handles sudoer stuff and steers clear of interfering with user-level dotfiles. Using the hyprland wayland compositor as an example, you can see that the module only provides flags for things like NVIDIA patches and allowing xwayland -- options for shadows/colors/animations are omitted entirely because they should (under the Nix philosophy) be configured with user dotfiles.
Now with that being said, Nix itself is merely a package manager, so it's entirely possible to splash in as a companion to your distro's main package manager (similar to how you can globally install npm/pip packages). This is handy because Nix's ecosystem is highly invested in enabling users to write their own packages (i.e.: Nix Flakes). In fact, some Nix users exclusively use it as a framework for creating and managing custom packages whenever the need arises to install something not already provided in their distro's package repository.
Of course, the most vocal Nix users are all-in and use NixOS. With NixOS, Nix is your native system package manager. Everything system-level becomes Nix-managed, though the same leave-userspace-to-dotfiles philosophy still applies on the user level. This strategy enables cool stuff like seamlessly syncing your system environment between multiple workstations and having guaranteed safe restore points through the use of nothing but a handful of config files.
Beyond that, for the total Nix freaks, there's the Home Manager Nix package, which allows you to install and manage userspace applications Nix-style. This is handled separately from Nix/NixOS proper because userspace configuration is a much larger and faster-moving target. If you use Home Manager to fully capture your userspace, it's nigh-guaranteed that you'll need to get your hands dirty by writing custom Nix modules. As you may imagine, this process can be a big pain... though it comes with the benefit of being able to seamlessly carry user applications & dotfiles across any distro that supports the Nix package manager (including Darwin).
Thank you for this comment! I've been flirting with Nix for a few months now, and this helped me understand a lot of the core concepts better.
Using NixOS options
By having the right configuration file there as part of the package's options, like:
globalProgram.doFoo = true;
or something likeglobalProgram.extraConfig = "barCount=4567";
Are those changes system-wide or stored in user space? Where are those files stored?
It's system-wide (unless home-manager is involved).
They're a part of the immutable install, whose components reside in
/nix/store
and are symlinked to/etc
.Example from my computer: