News for hackers. Stuff that matters.
Re:NixOS 22.11 “Raccoon” Released by codedokode on Thursday December 01, 2022 @07:55AM (#33815632)
I might want to try some new Linux distribution so I wonder: what doesn't work in nix? What are its weaknesses? What about devices with non-free firmware?
Re:NixOS 22.11 “Raccoon” Released by pongo1231 on Thursday December 01, 2022 @08:20AM (#33815844)
- You will have to learn both the nix language and working with nixpkgs. Learning nix is pretty trivial IMO (great resources are nix-1p[0] and Nix Pills[1]) but the documentation, while vast, is pretty shallow at the moment. You will likely have to resort to reading random blog posts, nix configs published by others and the source code of nixpkgs itself.

- As mentioned by another commenter you will not be able to run random binaries by default. You can use nix-alien[2] which will automatically fetch the libraries required and build an FHS shell for the binary.

- It is significantly more bandwidth- / rebuild-heavy. If an input for a derivation changes it will trigger a rebuild, which means either a redownload from the binary cache or a recompilation.

[0] https://github.com/tazjin/nix-1p

[1] https://nixos.org/guides/nix-pills

[2] https://github.com/thiagokokada/nix-alien

Re:NixOS 22.11 “Raccoon” Released by codedokode on Thursday December 01, 2022 @09:00AM (#33816276)
> learn both the nix language

That seems weird to me. I don't have to learn package configuration language in other distributions. I thought that one could just install packages with a package manager.

> You can use nix-alien[2] which will automatically fetch the required libraries and build an FHS shell for the binary.

That's actually fine. I want to put closed source software into a chroot anyway.

Re:NixOS 22.11 “Raccoon” Released by preisschild on Thursday December 01, 2022 @09:05AM (#33816328)
> That seems weird to me. I don't have to learn package configuration language in other distributions. I thought that one could just install packages with a package manager.

NixOS is more like a distro bundled with Ansible, so you can describe your entire system as code.

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:27AM (#33816619)
but in contrast to ansible it uses a real programming language and not turing complete yaml
Re:NixOS 22.11 “Raccoon” Released by colordrops on Thursday December 01, 2022 @09:57AM (#33817019)
And it's reproducible since the entire system is built with it. Ansible is brittle as hell.
Re:NixOS 22.11 “Raccoon” Released by jauco on Thursday December 01, 2022 @09:07AM (#33816351)
If you want to run nixos (i.e. the linux distro) then the configuration file is written in the nix language. Given that you’ll have to configure your installation, you’ll have to learn the nix language

If you just want to use nix for packages, you can run any distro and install nix the package manager into it. This is a good way to dip your toes in the water. And in that case you can just use the cli commands for installing packages.

Re:NixOS 22.11 “Raccoon” Released by codedokode on Thursday December 01, 2022 @09:48AM (#33816915)
I remember reading that nix unlike all other distros can install multiple version of the same package and I want this feature, but I guess programming a package config might be too much for me. Maybe I'll try nix package manager then.
Re:NixOS 22.11 “Raccoon” Released by rssoconnor on Thursday December 01, 2022 @10:26AM (#33817467)
While maybe not impossible, it is quite hard to cox Nix to "install" multiple different versions of the packages. They all cannot be in your path at the same time.

I still encourage you to give it a try. You can build different versions of same package and not "install" them. Instead just execute the binary from the built version (I do this where I have a built-but-not-installed version of openssh-8.6 laying around because I have an old service that modern SSH no longer supports).

You can also run `nix-shell -p <custom-package-version>` to get a shell with a specific package available in the path, overtop of whatever might be globally installed.

Who knows, you might even be tempted to dip your toes into the Nix language by writing a custom `shell.nix` to build a shell with some more complex development environment, or to simply automate a complex `nix-shell -p` command.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @11:15AM (#33818291)
The Nix idioms that are used in configuring NixOS are super simple, mostly just turning things on and off.

You can browse some here: https://search.nixos.org/options

For example, to install an OpenSSH server and run it, you'd write:

  services.openssh.enable = true;
and to run it on an additional port, 2222, instead of just the default of 22, you'd write:

  services.openssh.ports = [
    22
    2222
  ];
For programs you don't need to configure but just want to put on your PATH, you just add them to a list like

  environment.systemPackages = [
    pkgs.firefox
    pkgs.jq
  ];
If configuration management isn't for you, go ahead and mess around with Nix as a standalone package manager. But it really doesn't require much effort or prior knowledge to get up and running and start playing with it!

(For NixOS, the Nix you write only starts looking like real code when you want to add new features or some packages to NixOS.)

Re:NixOS 22.11 “Raccoon” Released by mattarm on Thursday December 01, 2022 @11:41AM (#33818754)
> nix unlike all other distros can install multiple version of the same package

The above is sometimes true and sometimes not. For the most part, Nix can install multiple versions of a program but only one can be in use at any given time.

Nix is for the most part shell based workflow (as in bash, zsh, etc.). The `nix-shell` command lets you switch out the packages (and versions of packages) that are used in any given shell, but it works off of a configuration file written in the Nix language that you write. The programs that are available are controlled by environment variables such as PATH and MANPATH.

Nix is a big shift from the usual way of dealing with packages, programs, etc. It isn't really useful until you really make the effort to understand what is going on, learn the Nix language, etc. If you are not interested in "programming" your system, then it probably isn't for you.

Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:19PM (#33820249)
> Nix can install multiple versions of a program but only one can be in use at any given time.

That’s not really true and is only a limitation of how PATH works on UNIXes (the first match is used). But you can for example add an aliased name for multiple versions of the same package, or for another meaning of use you can have different executables in the same environment different versions of the same lib (e.g. one bash script references python3, the other python3-at-specific-patch/minor-version/whatever)

Re:NixOS 22.11 “Raccoon” Released by chriswarbo on Thursday December 01, 2022 @01:22PM (#33820296)
> or the most part, Nix can install multiple versions of a program but only one can be in use at any given time.

That's a bit hand-wavey. More precisely: when you run a command, like `python3`, you can only associate that with one file. If you want multiple Python 3 interpreters, you'll have to use different names (e.g. making symlinks).

Alternatively, you don't need to bother "installing" anything; e.g. I use Nix for projects which use Scala, Maven, Python, NodeJS, etc. yet I don't have any of those installed. Instead, each project includes a `shell.nix` file which specifies the tools it wants. Running `nix-shell` in different folders gives me access to different tools.

Also, with Nix we only need to care about the end result: we can "install" a bunch of different programs, even if they have incompatible dependencies, since we're not "installing" those dependencies. ("Install" just means putting a symlink in some bin/ folder, like /run/current-system/sw/bin on NixOS or $HOME/.nix-profile/bin on non-NixOS)

Re:NixOS 22.11 “Raccoon” Released by Cloudef on Monday December 05, 2022 @02:44AM (#33862700)
This is only true if you want multiple versions in the same global environment. If you really want them in global environment, you can create meta package that aliases with symlinks. Otherwise you can use nix-shell to get any environment you want.
Re:NixOS 22.11 “Raccoon” Released by opan on Thursday December 01, 2022 @10:14AM (#33817278)
On both NixOS and Guix System you can get by pretty well without learning the config langs or all the more advanced features. Only really becomes a problem if you need something new packaged. You can enjoy declarative package management with easy rollbacks without really learning more than any other distro.
Re:NixOS 22.11 “Raccoon” Released by nextaccountic on Thursday December 01, 2022 @12:07PM (#33819164)
> I thought that one could just install packages with a package manager.

You could use the command

    nix-env -iA mypackage
To install packages, which is like pacman -S mypackage or apt install mypackage.

But... the interesting part of Nix is that it lets you install packages declaratively, by editing a config (like vim and emacs packages). Besides installing packages, all configuration is done through this config file (or bunch of config files): nix generates all files in /etc for you, again, like vim or emacs, but for the whole OS

That way, you easily transfer your setup to another computer or even keep two machines in sync. And you can add it to version control. And you get a grub menu with all your previous setups (until you uninstall them)

If this doesn't appeal you, you probably won't like to use NixOS

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:27AM (#33816631)
you can also use https://github.com/Mic92/nix-ld or build a fhs.
Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:14PM (#33820190)
> It is significantly more bandwidth- / rebuild-heavy. If an input for a derivation changes it will trigger a rebuild, which means either a redownload from the binary cache or a recompilation.

For general usage I didn’t notice it much, like, as an alternative to apt/pacman/etc. Ok, maybe don’t use it from a limited data plan (but isn’t true of every desktop OS?).

But sure, if you patch some lib n layers deep you will have to recompile many things, which is a godsend (in that you can actually do that), but will take a bit of time. But you can usually decrement its impact by really changing what has to be changed and using a “standard” channel for all the rest. With flakes it is especially easy to mix and match multiple nixpkgs repos at different versions.

Re:NixOS 22.11 “Raccoon” Released by stingraycharles on Thursday December 01, 2022 @08:35AM (#33816013)
From my experience, any binary is going to need patching before it runs, because shared libraries are in weird paths. I especially had issues running Steam, but this was about 8 years ago — maybe the situation has improved now.
Re:NixOS 22.11 “Raccoon” Released by iopq on Thursday December 01, 2022 @09:32AM (#33816689)
Steam still needs to be configured

https://nixos.wiki/wiki/Steam

but it's just a few lines in your config and then it works

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @10:05AM (#33817134)
That page is missing the opengl drivers which you also most likely want in the 32 bit variant.
Re:NixOS 22.11 “Raccoon” Released by Filligree on Thursday December 01, 2022 @10:46AM (#33817789)
Setting programs.steam.enable also enables 32-bit opengl, last I checked.
Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @11:48AM (#33818878)
Yes, that's correct and then you need to tell it which driver you need for your hardware. For example like:

hardware.opengl = { extraPackages = with pkgs; [ intel-compute-runtime # OpenCL library intel-media-driver # video encoding/decoding hardware accerlation ]; extraPackages32 = with pkgs.pkgsi686Linux; [ intel-media-driver # video encoding/decoding hardware accerlation ]; };

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:37AM (#33816754)
Yes, you cannot just download any random binary from the internet unless you use a FHS because those libraries are compiled for Distros using a default file system layout.
Re:NixOS 22.11 “Raccoon” Released by aliqot on Thursday December 01, 2022 @08:36AM (#33816023)
If you just want someone to shoot you straight:

Documentation and naming conventions for Nix are absolute shit across the board. This will get downvotes, and people will say I'm wrong, but I'm 100% right. Go see yourself, it's bad. Language is called Nix, OS is actually called Nix, package manager is called Nix, just the whole thing seems like it was written in 1 week by a squirrel with 12 hands and a sack of ritalin.

That being said a lot of smart people here and in my peer group swear it's the truth, despite none being able to elevator pitch it.

Re:NixOS 22.11 “Raccoon” Released by bsnnkv on Thursday December 01, 2022 @08:49AM (#33816146)
That last sentence is so true. I'm all in on Nix and I couldn't elevator pitch it if my life depended on it.
Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:36AM (#33816739)
NixOS is a reproducible, customizable, programmable and adaptable Linux distribution.
Re:NixOS 22.11 “Raccoon” Released by kadoban on Thursday December 01, 2022 @08:59AM (#33816252)
"A completely repeatable setup all the way down."
Re:NixOS 22.11 “Raccoon” Released by darthrupert on Thursday December 01, 2022 @09:21AM (#33816544)
Uber- I mean Haskell for operating systems.

Like Ansible but more bdsm.

Linux not making you feel superior anymore? Try Nix!

Re:NixOS 22.11 “Raccoon” Released by tomrod on Thursday December 01, 2022 @09:18AM (#33816503)
Completely repeatable setup.

Like Docker, but works.

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:34AM (#33816719)
Docker is not repeatable. If I try to build the same Dockerfile in 12 months then I likely do not get the same output and it wouldn't be surprising if it does not build at all.
Re:NixOS 22.11 “Raccoon” Released by tomrod on Thursday December 01, 2022 @09:37AM (#33816755)
Correct and agreed, hence my "but works" portion of the comment!

The notion of portability is Docker's bread and butter. With proper version pinning you _might_ get lucky with repeatability too. Most people anticipate repeatability to be part of portability, but it really is a distinct notion.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @11:30AM (#33818562)
This fits with the usual definition of repeatable. Repeatable means that you can run the same steps, but if the steps are non-deterministic, repeating them doesn't guarantee the same result.

> it wouldn't be surprising if it does not build at all.

This part is a stronger point, and it's true. When you repeat something and what you get is not just a different version or variation but something with totally different or broken behavior, that seems bigger than an ordinary failure of reproducibility.

Re:NixOS 22.11 “Raccoon” Released by JamesSwift on Thursday December 01, 2022 @10:56AM (#33817956)
- Nixpkgs: Content-addressed reproducible package manager. No collisions because of the content-addressed part.

- NixOS: Full OS that says "what if we did the same for the whole OS"

Re:NixOS 22.11 “Raccoon” Released by pxc on Friday December 02, 2022 @12:39AM (#33827232)
Here's one:

Nix solves what Docker merely works around.

The secret of Nix is the application of the common wisdom of memory management discipline in modern programming language design to the process of building and distributing software.

The payoff is, as with garbage collection in the original case, and immense leap in safety, productivity, and maintainability for software build and deployment systems.

Concretely, Nix and the ecosystem of tools built upon it and each other mean:

  - configuration management that never drifts
  - upgrades that can always be rolled back in seconds
  - servers that don't accrue cruft
  - software whose bill of materials comes for free
  - an end to version conflicts
  - packages which can always be bundled into a minimal container image in seconds
  - build artifacts which turn out the same no matter where or when you build them
  - software running as-needed, even locally, without having to be installed or manually cleaned up
  - a single, simple language capable of defining your entire stack, from building individual assets to managing cloud infrastructure to deploying service-oriented systems
  - a final 'works on my machine' bullshit in their development environments without any virtualization, even on macOS
  - user-mode package management for supercomputers or mainframes
  - freely leveraging the largest, most up-to-date package collection in the world
and much more. The benefits and applications and extensions of Nix are so startlingly vast and diverse because ultimately, the Nix ecosystem is not an iteration on a tool— it's a renaissance. You should join it and start shedding obsolete problems.
Re:NixOS 22.11 “Raccoon” Released by preisschild on Thursday December 01, 2022 @09:02AM (#33816290)
> OS is actually called Nix

Not true. The distro is called `NixOS`. The package manager and it's language is called `Nix`.

I do agree that the learning curve is extremely steep.

Re:NixOS 22.11 “Raccoon” Released by tomrod on Thursday December 01, 2022 @09:17AM (#33816493)
That's not a learning curve, that's a brick wall.

Maybe call the package manager something catchy like "pacman" or "update_software_from_repos" :)

Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:25PM (#33820337)
Well, there is a model change as well, traditional package manager doesn’t make as much sense for Nix.
Re:NixOS 22.11 “Raccoon” Released by chriswarbo on Thursday December 01, 2022 @09:25AM (#33816595)
> Language is called Nix

Yep; that's a bummer. The manual calls it the "Nix expression language", and some people refer to it as "nixlang" (similar to Gophers saying "golang")

> OS is actually called Nix

Nope, it's always NixOS; 100% of the time. In fact, the naming confusion goes the other way in this case, since the whole project (Nix, NixOS, etc.) lives on the domain nixos.org, and the GitHub account NixOS!

> package manager is called Nix

The commands are called Nix; but I personally find the idea of "package manager" just complicates things. Nix is more of a build tool, like Make; internally, it uses "derivation" to refer to anything from a text file to an entire OS. An application, like a music player, may involve many derivations (e.g. a derivation for its source code, a couple of derivations containing patches, a derivation for an interpreter with the required libraries, etc.); indeed the "actual program" in our $PATH is often just a script which invokes some other binary defined via a different derivation ;)

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:30AM (#33816667)
> some people refer to it as "nixlang"

more commonly just nix language or you know it out of context

Re:NixOS 22.11 “Raccoon” Released by JamesSwift on Thursday December 01, 2022 @10:53AM (#33817909)
I always refer to nix on mac as "nix package manager" to disambiguate. It seems to be the common way to do so.
Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:29AM (#33816654)
> naming conventions for Nix are absolute shit across the board

No, not really. They are not consistent for every part and not every package is up to date with everything but if you get the gist you can easily guess things. If things are really weird we can always rename them.

Re:NixOS 22.11 “Raccoon” Released by mananaysiempre on Thursday December 01, 2022 @09:45AM (#33816862)
> That being said a lot of smart people here and in my peer group swear it's the truth, despite none being able to elevator pitch it.

OK, I’ll bite.

Nix is a build system. NixOS is a Linux source distro built on top of it (cf Gentoo, gittup, BSDs).

Nix builds (should) execute in an isolated environment, thus the build artifacts are (ideally) bit-for-bit identical no matter where they were built. This means you can have a shared artifact cache (cf Bazel). Now for the clever part: in a distro, such an artifact cache is the same thing as a binary repo. Thus you are in fact using a (somewhat disk-space-hungry) binary distro until you want to patch something, at which point it transparently reverts to a source one (up to and including rebootstrapping the system compiler if you wish).

That’s the gist, but there are some more goodies on top of that.

First, none of this really requires a NixOS-only world. Thus, as an intermediate step, there’s Nixpkgs: a ports-like collection of packages that runs on conventional Linux and macOS systems (*BSD support is possible but has bitrotted). To maintain isolation in such an environment, all binaries it builds refer to dynamic libraries by build hash rather than load whatever’s present, and are usually wrapped to ensure other parts of the ambient environment don’t leak through. But once you’ve done that, more or less the only thing remaining to have a “gimme a shell with P, Q, and R in it” command is to point PATH to the right build directories. Hermetic build environments (cf virtualenv) for any supported language, user-scoped rootless package installs, good stuff.

Second, what NixOS adds on top of that (apart from a kernel) is a system for building system configurations out of Nix-language descriptions. It’s a bit clunky, like all config generators, but once you commit to maintaining all of your /etc that way a full rollback of (the NixOS-managed part of) the system is a single GRUB selection away. There are also things like “run a QEMU with this system config inside”, “build a Docker-compatible image with this system config inside”, etc.

Finally, as to how this works, Nix the build language is really simple, it’s JSON + (pure) functions + laziness + a build recipe type. Usually you just generate some shell or Perl or whatever scripts and stuff them into the recipe, so for Nixpkgs it’s honestly a bit overkill, but NixOS uses it to define a rather clever system with options that (if defined) set values of other options that ... all the way to the options that define the raw content of each file in /etc, with rules for merging option values if you wish (cf CUE, Dhall). If your mental model of your system is more abstract than the configuration of each individual service, it’s not hard to write it down as Nix code that defines some new NixOS options, then define your system—or several—in terms of those options.

Bad parts:

Apart from the build system as such, the CLI includes support for a lot of the idioms I mentioned above, so the separation may not look that clean. (This is not helped by the fact that a complete CLI overhaul is in progress, with old commands like nix-build and nix-env being superceded by a single new one, nix. The nixos-* ones are separate for now.)

The language is perhaps a bit too minimal and lacks a standard library, so Nixpkgs ends up containing that as well, without much in the way of documentation. You will have to refer to the source there. The library is mostly simple list and mapping utilities, so it’s not difficult, but figuring out whether the thing you want is in it or not can be frustrating, and the API won’t win any beauty contests.

It can be slow.

Re:NixOS 22.11 “Raccoon” Released by JamesSwift on Thursday December 01, 2022 @10:57AM (#33817978)
Thats quite a lengthy elevator ride : )
Re:NixOS 22.11 “Raccoon” Released by mananaysiempre on Thursday December 01, 2022 @11:50AM (#33818903)
Right? :) I intended only the first two paragraphs to be the pitch and the rest to be an extended explanation, but I have to admit they aren’t really a summary of the rest.

Now that I’ve written this, I see I can’t really phrase the benefits such that the result is neither a shallow-sounding platitude nor a laundry list of features, when the reality is a laundry list of features that mostly fall out of a couple of overarching ideas. And it’s not like each of those features haven’t been done before, but this particular implementation comes out remarkably simple and sane given the length of the list.

Re:NixOS 22.11 “Raccoon” Released by colordrops on Thursday December 01, 2022 @10:00AM (#33817072)
Sounds like they aren't very smart if they can't elevator pitch it.

Perfectly reproducible OS with easy rollbacks. OS never gets crufty, no need to reinstall every release version or two. Single configuration language for all apps and system components. Composable and shareble config modules at any level of abstraction, e.g. you can piece together many git repos to custom roll your OS. Isolated dependencies for every package, meaning no dependency hell (similar to docker). You can have multiple versions of everything running live. Ability to run temporary environments using the same config language.

Current OSes are like VAX or TRS-80 in comparison. Nix-likes are the future.

Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:23PM (#33820322)
My Litmus test for package managers is the ability to install gnome, switch it out for kde and back. (Or starting with kde). One should be able to do that without accumulating garbage (packages that are no longer used, config files, etc), but so far only NixOS passes it (and I didn’t try but assume Guix).
Re:NixOS 22.11 “Raccoon” Released by Ixiaus on Thursday December 01, 2022 @10:20AM (#33817382)
Nix the language enables you to write explicit build recipes that can be reproducibly built with good integrity guarantees and granular and distinct knowledge of the build-time dependencies and the run-time dependencies (so you only ever transmit closures that have what they need to execute).

Nix the set of tools gives you convenient command line tools that can: evaluate Nix language expressions, build recipes, analyze build-time or run-time dependency graphs of a recipe, give you ephemeral shells with the packages you want in scope but not installed "globally", package management tools to install packages globally, and recipe diffing tools so you can see how recipes changed.

Nix the package manager is a convenient, gigantic, community effort to explicitly describe how to (reproducibly) build almost all of the OSS software that users need and it comes with a substitution cache so that most recipe build products are easily substituted when installing, so you don't have to build. Even if you don't use Nix, nixpkgs is still impressive because you have the most explicit documentation for how to build a piece of software from source and all of its dependencies than anywhere else on the internet, it usually rivals project author's in its specificity, explicitness, and clarity.

NixOS the Linux distribution combines all of this together with a convenient configuration module system and generally good defaults to give you an operating system that is declaratively specified from your etc hosts file all the way down to the recipe for building the kernel, a rich and granular dependency graph, reproducible OS configuration builds, and diffs between closures.

My biggest gripe with Nix is the lack of static types. This was the originator's biggest mistake that Nix will be living with for a very long time to come. Static types would have helped bring the learning curve down IMHO and made it easier to document and less frustrating to debug.

That being said, the overall properties of Nix, nixpkgs, and NixOS far outweigh the pain points in my six years of production experience with it and for what we care about: auditability, reproducibility, explicitness, efficiency, and integrity.

Re:NixOS 22.11 “Raccoon” Released by pmarreck on Thursday December 01, 2022 @11:13AM (#33818266)
"Derivation": A per-package lockfile (that is, a merkle tree of dependencies with the hash of their binaries plus the hashes of any deeper dependencies... think git with its commit hashes) that is computed at runtime when that particular binary is installed or updated. This ensures that it will always run with the exact versions of the things it depends on, and upgrades to sub-dependencies (like glibc, or openssl, etc. etc.) won't suddenly break things, because multiple versions of those can now exist in parallel, since its "name" (with regards to the nix store) is not just the canonical name but the canonical name concatenated with its "commit hash" (as it were, using git language)

so basically, when you install something with nix, it's specified all the way down to the bare metal (except for perhaps the kernel)

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @11:27AM (#33818487)
This is mean, but it's not so blatantly false that it's worthy of downvoting.

Nix and Nixpkgs are messy, evolved things with a lot of history and quirks. They're also very powerful tools that can change the way you even approach computers. If you stick with them long enough, they may inspire you to extend and leverage them in creative ways... continuing the process of messy evolution. :)

Re:NixOS 22.11 “Raccoon” Released by troad on Thursday December 01, 2022 @08:18AM (#33815825)
I would expect something like Steam gaming on my dual-GPU laptop might be one deep mineshaft of "nope" on NixOS.
Re:NixOS 22.11 “Raccoon” Released by pongo1231 on Thursday December 01, 2022 @08:29AM (#33815952)
If it's an Intel iGPU + an Nvidia dGPU setup beware there's a bug with the implementation of the Nvidia driver currently which breaks connecting external displays on X11 depending on your hardware. See https://github.com/NixOS/nixpkgs/issues/199024 and the comments of https://github.com/NixOS/nixpkgs/pull/165188.

Also setting Coolbits doesn't seem to work either on my end, which means no overclocking support for the Nvidia GPU (if that's something you care about).

Re:NixOS 22.11 “Raccoon” Released by Filligree on Thursday December 01, 2022 @08:19AM (#33815838)
No, that works fine. As well as it ever does.
Re:NixOS 22.11 “Raccoon” Released by troad on Thursday December 01, 2022 @08:21AM (#33815849)
Really? I'm curious to read more.

It works very well for me under Ubuntu these days, but if I can get it working equivalently well on NixOS I may legitimately consider switching.

Re:NixOS 22.11 “Raccoon” Released by Jhsto on Thursday December 01, 2022 @09:21AM (#33816539)
Plugging my own thing here, but I have been experimenting with a Nix configuration for gaming only. My configuration is here (for Nvidia, which does not work without tinkering as AMD does) : https://github.com/jhvst/nix-config/blob/main/nvidia.nix

First, this is a whole system specification. This means that executing this on Nix will build you a whole OS image. You can build the image if you have Nix by running the first line on file. You can also use Docker with the instruction on my README: https://github.com/jhvst/nix-config (however, kexec will not likely work, read more how to run it later)

Back to elaborating on the Nix file from the gaming perspective. First, we have the overlays. These are like patches to the packages, and really useful for gaming because it allows building important packages like mesa from the source tip. This is particularly useful when new games or GPUs are released. Same thing for wayland: Nvidia and its proprietary drivers need some patching, but it's possible to get wayland (and sway) to work this way.

Then, I have taken the reproducibility of Nix to a next step in my opinion, and made the system stateless. This means that it runs from the RAM. It is easy to create installation media like kernel, initrd, and rootfs because you have all the steps to create the distribution. This means that here, Nix works as a meta-distro like Gentoo, on top of which you develop your own. Running from the RAM means that theoretically, if you have a working config, and two people with different hardware runs it, then they should have the same experience. If you look at ProtonDB, you often find that some people claim that game X works on their machine with drivers and mesa of Y and Z, but there is no way to copy their configurations because it's certain that the user has made some stateful changes which they have forgotten hence left undocumented, which is the reason it works for them. If everyone would be using Nix, you could reproduce their system and possibly fix your own, but this is not tractable with most OSs.

If you like to test my changes, you can read more about my approach here: https://github.com/NixOS/nixpkgs/pull/203750

For testing I distribute Nvidia as documented here: https://github.com/jhvst/jhvst.github.io/blob/main/ramdisk.m...

However, I have developed it bit further: if you manage to get into an iPXE shell, you can write `boot -a http://boot.ponkila.com/menu.ipxe`, then select the second option which is Nvidia (proprietary drivers), and with some waiting you will get into a shell prompt to which you can write `sway --unsupported-gpu`, which will launch sway. Cmd+Enter opens a prompt to which you can write `steam`, which will open Steam. Then, you have to mount some drive on another shell with `mount`, and add this as a Steam library via Steam's UI. Then you can play games. I use this on AMD and I have been very happy.

To get iPXE, the easy option is to go along with https://netboot.xyz. You will find the `iPXE shell` option here to which to write the boot option from the previous paragraph.

Re:NixOS 22.11 “Raccoon” Released by tmnvdb on Thursday December 01, 2022 @10:21AM (#33817398)
I use steam on nix and it was a breeze.
Re:NixOS 22.11 “Raccoon” Released by thomastjeffery on Thursday December 01, 2022 @10:20AM (#33817377)
I can't speak to that specific use case, but in a more general sense...

NixOS, just like any other OS, can have you walking down the familiar caverns of, "getting the thing to work that this system isn't designed to accommodate well."

But this time is different: you can start over fresh at any time.

This is really the situation where NixOS shines the most. No more, "wondering what you installed where when you were trying to get that over program working the other day." No more, "did I just do the steps in the wrong order?"

It's unbreakable. Your OS is guaranteed to feel like a fresh install. Forever. Because it can't be anything else.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @12:42PM (#33819669)
NixOS actually handles NVIDIA hybrid graphics more easily than most distros. When I got a laptop with NVIDIA/Intel hybrid graphics a few years ago, it took less time to configure on NixOS than it had on openSUSE, which I was dual-booting at the time.

I don't have a laptop like that anymore, but check the NixOS manual and NixOS.wiki, and ask around if you get stuck!

(When I last used it, Bumblebee was the best option and worked well, but these days, native PRIME offloading should also work fine and it's what I would prefer.)

As for Steam, just add

  programs.steam.enable = true;
to your config. Works great!

(If you're accustomed to Flatpak Steam, you can alternatively enable Flatpak and just install Steam that way, like you would on your existing distro.)

Re:NixOS 22.11 “Raccoon” Released by justoreply on Thursday December 01, 2022 @08:04AM (#33815711)
you can't run binaries built for other distributions, without patching them
Re:NixOS 22.11 “Raccoon” Released by bfrog on Thursday December 01, 2022 @08:09AM (#33815757)
Sort of true, you can but it require a fhs environment setup
Re:NixOS 22.11 “Raccoon” Released by Filligree on Thursday December 01, 2022 @08:20AM (#33815841)
steam-run usually. That gives you a Ubuntu-like environment.
Re:NixOS 22.11 “Raccoon” Released by throwup on Thursday December 01, 2022 @08:52AM (#33816184)
I wonder why Nix doesn't give every package a FHS env by default. In 2022 chroot and overlayfs should be available everywhere. Wouldn't that solve a ton of problems?
Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:41AM (#33816800)
A FHS adds slight overhead to a package and to launch times. It also shadows part of the file system. For example /lib would probably be different for every other program which would be even more confusing.
Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @12:34PM (#33819553)
They're also not implemented on macOS, since they rely on Linux sandboxing features.
Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:46PM (#33820698)
Plus nix allows more than possible with FHS alone. What if your package has to use multiple versions of a single dependency? You are back to square one, for no good reason.
Re:NixOS 22.11 “Raccoon” Released by chriswarbo on Thursday December 01, 2022 @09:30AM (#33816661)
Nix has no concept of "package". Applications are defined as derivations, but so is everything else (I wouldn't want an entire FHS directory structure for, e.g., a single text file).

If you want an FHS, you can get one using a function like buildFHSUserEnv (that's defined in the Nixpkgs project; Nix itself doesn't know or case what FHS is)

Re:NixOS 22.11 “Raccoon” Released by rnhmjoj on Thursday December 01, 2022 @09:11AM (#33816410)
Not true: there are many tools that allows directly running any binary, like nix-autobahn [1].

[1]: https://github.com/Lassulus/nix-autobahn

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:38AM (#33816770)
or https://github.com/Mic92/nix-ld or a FHS. There are many projects to help with this.
Re:NixOS 22.11 “Raccoon” Released by 331c8c71 on Thursday December 01, 2022 @02:30PM (#33821433)
Haha, sometimes it goes the other way round.

The vpn client at work wasn't available for the latest ubuntu and the old version did not work due to changes in some libs. Wrapping it with nix providing the right libs was way easier and much more replicable than manually building the required stuff. Did in on my machine and than 3 mins to do the same for a colleague.

Re:NixOS 22.11 “Raccoon” Released by speed_spread on Thursday December 01, 2022 @09:17AM (#33816489)
If Nix is too much but you still want an immutable distro, look into Fedora Silverblue (or Kinoite). It offers some of the advantages of Nix in a more approachable fashion.
Re:NixOS 22.11 “Raccoon” Released by AnIdiotOnTheNet on Thursday December 01, 2022 @09:38AM (#33816765)
Seconding this. I ran Silverblue until recently due to some bugs in Kinoite but switched as soon as possible because GNOME sucks.

Its the first distro I've used in 20 years that doesn't feel like a stiff wind could cause the whole thing to collapse and catch fire in an unrecoverable way, while still allowing me to run any software I want instead of just what is in some limited curated repo. And unlike Nix, I didn't need to learn a new language to use it.

Re:NixOS 22.11 “Raccoon” Released by smoldesu on Thursday December 01, 2022 @09:40AM (#33816795)
Does Silverblue still support traditional package managers? An immutable OS seems nice and I like Bubblewrap's isolation, but I would never switch full-time to an all-Flatpak distro...
Re:NixOS 22.11 “Raccoon” Released by enticeing on Thursday December 01, 2022 @10:05AM (#33817131)
You can install all the usual software from the Fedora repos, but you need to do a reboot before you can use it. See the Package Layering section here: https://docs.fedoraproject.org/en-US/fedora-silverblue/getti...
Re:NixOS 22.11 “Raccoon” Released by speed_spread on Thursday December 01, 2022 @03:40PM (#33822404)
(for other readers) One only needs to reboot if modifying the base OS image ("layering" packages in ostree parlance). This is only required for packages that require low-level integration - services, virtualization, drivers. The big Silverblue idea is that you should make maximum use of flatpaks and "toolbox" containerized environments, all which "float" over the base OS. Once everything's been "layered" to your liking, you rarely touch the base OS anymore except for updates.
Re:NixOS 22.11 “Raccoon” Released by AnIdiotOnTheNet on Thursday December 01, 2022 @10:15AM (#33817286)
In addition to the sibling comment about layering, this is largely what toolbox is for. Essentially you create containerized environments with a lot of integration (you can run GUI apps from them) and install whatever you want in those.

  toolbox create new_dev_env_or_whatever
  toolbox enter new_dev_env_or_whatever
  dnf install all_the_things
And now you've got a container with whatever installed. To use it you do have to use `toolbox enter` or `toolbox run` though. Distrobox is basically the same thing for people who don't use Fedora.

I have my issues with both Flatpak and Toolbox as far as how they're put together and work, but overall I find it to be a vast improvement on the status-quo way of doing things. YMMV, of course.

Re:NixOS 22.11 “Raccoon” Released by smoldesu on Thursday December 01, 2022 @10:16AM (#33817312)
Interesting, that's much better than what I assumed. NixOS' composition tools are fairly similar, at least in scope.
Re:NixOS 22.11 “Raccoon” Released by speed_spread on Thursday December 01, 2022 @03:43PM (#33822448)
I found distrobox to be useful even on Fedora. For some reason running CLion under a plain toolbox resulted in very frequent system-wide pauses lasting several seconds.
Re:NixOS 22.11 “Raccoon” Released by AnIdiotOnTheNet on Thursday December 01, 2022 @06:08PM (#33824324)
I had the same issue on Kinoite 35 specifically, but only with GTK applications. That forced me to Silverblue at the time, but 37 seems to have ironed out whatever it was.
Re:NixOS 22.11 “Raccoon” Released by piaste on Thursday December 01, 2022 @10:24AM (#33817442)
Yes, you use 'rpm-ostree' to install and manage regular dnf packages, or local .RPM files.

The limitations are:

1) Each invocation of the package manager (install/upgrade/uninstall, the usual stuff) results in a new OS 'commit' and requires a reboot to switch to it.

This is the entire point of the distro (random .rpm broke your system? just rollback), and is why Silverblue users generally only use DNF packages for low-level tools and run regular applications as flatpaks, appimages, or podmans.

2) Occasionally you'll run into a package that wants to write to a folder that Silverblue made read-only and version-controlled, and breaks. In that case your only options are to run the package inside a toolbox (a special Podman container that comes with Silverblue for these scenarios), or patching the package.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @12:29PM (#33819469)
Never mind traditional package managers... you plug it in right, you can run Nix on Silverblue!

https://gitlab.com/ahayzen/silverblue-nix

NixOS people will prefer NixOS, but Silverblue seems like a nice complement to Nix if you need an FHS base system and want to retain some Nix-ish features like rollbacks and atomic upgrades.

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:26AM (#33816604)
NixOS has a steep learning curve but if you start to climb it, it is probably the strongest distro right now especially if you want to customize things and have it reproducible.
Re:NixOS 22.11 “Raccoon” Released by mamcx on Thursday December 01, 2022 @09:38AM (#33816757)
> What are its weaknesses?

I think is easier to see this with what is their main strength: A declarative/reproducible OS setup. Is AMAZING for server deployment (like what you put in a docker file but that not mutate after it).

But I don't think will be so nice for day to day use. That is where a mutation OS is easier.

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:40AM (#33816789)
As soon as you have multiple machines with shared configs it gets really attractive again.
Re:NixOS 22.11 “Raccoon” Released by funcDropShadow on Thursday December 01, 2022 @10:49AM (#33817840)
My desktop development workstation is running on NixOS. I am always updating it as soon as possible because I know I can revert everything. That is damn nice.
Re:NixOS 22.11 “Raccoon” Released by aidenn0 on Thursday December 01, 2022 @10:55AM (#33817948)
I don't agree. NixOS has many weaknesses, but a server/desktop divide is not one of them.

Fwiw the best summary of "should I use NixOS" is https://news.ycombinator.com/item?id=33679621

Re:NixOS 22.11 “Raccoon” Released by JamesSwift on Thursday December 01, 2022 @10:59AM (#33818017)
The biggest weakness is the built-in expectations it has on how packages install/operate. There are some patterns that will not fit into the box easily (e.g. native-compiled gems/node packages).

Also since things are declarative, that means things like e.g. updating bash aliases has additional friction vs the traditional way of editing the file directly.

Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:45PM (#33820666)
> updating bash aliases has additional friction vs the traditional way of editing the file directly

Additional friction (not much imo), but you will actually be able to move that bash plugin that does that thing you didn’t even realize were not available in a vanilla shell.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @12:31PM (#33819516)
I ran NixOS on my living room emulation/gaming computer for years, until I stopped having one. It wasn't particularly high friction or server-y.
Re:NixOS 22.11 “Raccoon” Released by staunch on Thursday December 01, 2022 @10:10AM (#33817206)
Nix feels to me like a cool but somewhat hacky v1 of a really great idea. I'm hoping someone creates a much more elegant successor.

If Nix is CVS or even Subversion, I'm hoping for Git.

Re:NixOS 22.11 “Raccoon” Released by thomastjeffery on Thursday December 01, 2022 @10:24AM (#33817445)
The neat thing about the functional design of Nix is that you don't have to reinvent the wheel: just make better steering.

Everything about Nix can be trivially refactored. Every part is neatly isolated from the rest.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @01:30PM (#33820442)
> Everything about Nix can be trivially refactored. Every part is neatly isolated from the rest.

Tweaking a few NixOS modules it replacing a package is easy, but neither the Nix codebase nor Nixpkgs is characterized by perfect modularity or uniform layering.

Re:NixOS 22.11 “Raccoon” Released by JamesSwift on Thursday December 01, 2022 @12:50PM (#33819793)
What? Have you used the old nix cli? It absolutely dominates Git in the frequency of "how do I do that again?" /s
Re:NixOS 22.11 “Raccoon” Released by chriswarbo on Thursday December 01, 2022 @01:30PM (#33820433)
Maybe take a look at Guix? (I don't use it, but it sounds like what you describe)
Re:NixOS 22.11 “Raccoon” Released by aidenn0 on Thursday December 01, 2022 @10:57AM (#33817982)
I'm just going to link to the best HN comment I've seen on this topic

https://news.ycombinator.com/item?id=33679621

Re:NixOS 22.11 “Raccoon” Released by mindslight on Thursday December 01, 2022 @11:24AM (#33818441)
No mention of the fucky /nix/store paths for everything? I haven't used a lot of other distros, especially recent ones (my list: Slackware, Redhat, Ubuntu, Debian), but Nix is a drastic departure from the standard FHS and Linux conventions.

Don't get me wrong - I love NixOS! I'm gradually switching my infrastructure to NixOS. There are very necessary reasons for Nix's departures. But it is jarring, and if we want converts we have to manage expectations properly!

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @12:24PM (#33819408)
That's true! Whenever I demo Nix for someone in person, the first trick I do is

> Look ma, no /usr/lib

and right after that it's a chat about the Nix store, and then a tour of what all those ugly hashes let you achieve.

I guess when I wrote that comment I was mostly thinking about what it's like to administer NixOS on a personal system over the moderate term, not the initial shock and wonder of hiking through the glorious Nix symlink forest under /nix/var/nix/profiles for the first time. :)

Re:NixOS 22.11 “Raccoon” Released by mindslight on Thursday December 01, 2022 @01:28PM (#33820387)
My personal administration involved a lot of digging through installed software's FHS to figure out how things worked. Especially coming up through Slackware. It's probably a learning style thing.

Mutable distros you directly edit stuff in /etc, then build your knowledge on top of that foundation. Whatever better practices you end up adopting, you're still ultimately modifying files in /etc (and probably elsewhere). A NixOS beginner shouldn't be touching config files, and can't even do things like replace a binary with a shell script wrapper to understand when and how a program is run by a different program.

So I see that departure as a pretty huge one, that will affect someone learning Linux on NixOS for many years, as they need to dig through NixOS specific docs to understand how they're supposed to configure something, rather than falling back to the regular packaging docs. Whereas with Debian you only need Debian documentation to know how to install a package, but after that the upstream package documentation tells you everything else.

As an aside, I feel like NixOS asks a fundamentally different question - "how can we mitigate Linux/Unix's complexity" rather than the traditional mutable distro question of "how can we best interact with Linux/Unix's complexity".

(Also, that sounds like a great approach to explaining NixOS!)

Re:NixOS 22.11 “Raccoon” Released by aidenn0 on Thursday December 01, 2022 @02:27PM (#33821394)
Another thing is that the nixos option searcher[1] links to the nix source code that implements the option, so you can go digging through how things work. It's definitely an extra layer of abstraction vs editing /etc/foorc but I have copied what those things do into my configuration.nix and made changes to poke at stuff.

1: https://search.nixos.org/options

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @03:05PM (#33821949)
A few times, I have privately used NixOS modules' source code to answer questions about how to configure software that I do not use, in response to questions posed by users of other distros. It's an awesome resource! :D
Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @02:55PM (#33821794)
> My personal administration [prior to NixOS] involved a lot of digging through installed software's FHS to figure out how things worked. [...] Mutable distros you directly edit stuff in /etc, then build your knowledge on top of that foundation.

That's true. Once you have found your footing with the Nix language and figured out some basics of how to navigate the NixOS modules in Nixpkgs, the latter becomes a rich source of examples on how to configure everything on a modern Unix-like system, from mounting a btrfs subvolume in your initrd via systemd/dracut integrations to setting up PipeWire to emulate PulseAudio. But while NixOS can still teach you a lot about how a working Unix-like system is put together and how its stack is configured, the most useful point of entry for such exploration is very different from what you might be used to on other distros.

You can also learn by exploring the Nix profiles and the Nix store of a working system, much like you would walk through the FHS on a ‘normal’ Linux system— after all, all of your system-wide config files can eventually be hunted down in the Nix store. If you run `ps` on a NixOS system, you'll see explicit references to RC files for lots of programs that are wrapped to point to specific config files, and for running persistent services. But it's probably not as useful as going directly to the Nixpkgs source, once you've learned to read a little Nix.

> A NixOS beginner shouldn't be touching config files, and can't even do things like replace a binary with a shell script wrapper to understand when and how a program is run by a different program.

That's an interesting thought. I didn't come to NixOS as a beginner in the Linux world; NixOS was not my first distro. (I think that's true for most of us in the community.) With NixOS, neither the paradigm nor the community really encourages the kind of monkey patching, that kind of learning by brute intervention on a running system. Even so, I think it would be possible (if perhaps a bit perverse) to write a textbook or a course like ‘Learning Unix with NixOS’. I think using a read-write store as a teaching tool before showing the reader how to use Nix itself to wrap programs that live in the Nix store would be fine.

> [NixOS users] need to dig through NixOS specific docs to understand how they're supposed to configure something, rather than falling back to the regular packaging docs.

Right, NixOS definitely changes the sort of ‘order of recourse’ users will want to make when configuring a piece of software. I'd say it looks something like this:

1. Is there an existing NixOS module for configuring the software I want to use? 2. If so, does the module have any high-level options that look so convenient that I should try them right away? 3. Is there any additional, special configuration that I need to do?

If the answer to (1) is no, or the answer to (3) is yes, then it's definitely necessary to consult the upstream documentation on the software you want to use. In the case that a module exists but you need special config, there will always be a way for you to pass configuration options defined upstream directly to the application through your NixOS configuration.

A NixOS fanatic might frame this

> Whereas with Debian you only need Debian documentation to know how to install a package, but after that the upstream package documentation tells you everything else.

in an alternative way:

> Whereas Debian only helps you to install the package, NixOS will also help you perform common configuration tasks. It's only when you need to perform peculiar configuration tasks for your specific needs that you really have to dive into the upstream documentation.

At the same time, knowledge of some upstream component (e.g., Xorg, connman, OpenSSH, etc.) always remains applicable with NixOS, if you want it to be. Everything that's configurable under /etc/something/or/other on Debian remains configurable on NixOS in a straightforward way, either by specifying key-value type config in the Nix language or (in the worst case) by embedding a config file snippet in your NixOS configuration.

> As an aside, I feel like NixOS asks a fundamentally different question - "how can we mitigate Linux/Unix's complexity" rather than the traditional mutable distro question of "how can we best interact with Linux/Unix's complexity".

I think this is well put, and it's what I was getting at above with the idea that thinking about the particular structure of some program's RC file is a last resort in NixOS. But it's not entirely one-sided! The NixOS module system serves not just to shield users from that complexity when they don't need to confront it, but also to teach them about it when they do. For me, that's one of the reasons that learning the Nix language and exploring the Nixpkgs codebase is so worth it.

Re:NixOS 22.11 “Raccoon” Released by aidenn0 on Thursday December 01, 2022 @01:05PM (#33820039)
I guess I kind of think of that as like "Lisp has a lot of brackets!" true, but something someone looking into potentially using it knows already.