12 ms·
NixOS is not for the impatient. Maintaining your system configuration is an exercise in software development like any other - if you lack rigor or discipline, y
by turboponyy 3y ago
NixOS is not for the impatient. Maintaining your system configuration is an exercise in software development like any other - if you lack rigor or discipline, your codebase will become painful to work with. Nothing is ever one shell incantation away - it has to be carefully architected into the existing system.
That being said, once you get the hang of things, you reap amazing benefits:
- You can clone your system to any machine, and immediately have an identical environment
- You can share system configurations as code (declare the means for hosting a website in its repository, for example)
- You can use a fully-fledged programming language to configure any part of your system
- You can make use of an extensive ecosystem of easily composable, prebuilt NixOS modules
- You can seamlessly integrate with Nix, allowing for ephemeral development environments and shells with packages, eliminating much of the need for imperative package management
- Everything in a Nix-based system must be derived strictly from (lockfiled) inputs, making the reproducibility guarantees incredibly strong (barring any network errors or resources being taken down)
- The declarative nature of anything Nix-based means that every change is documented - your system never shifts from the source of truth, compared to other distros where discipline is required to maintain reproducibility
- Nix is so robust that you could even nuke your filesystems on every log out, if you'd like
- smoldesu 3y ago> You can clone your system to any machine, and immediately have an identical environment It's arguably the killer feature of NixOS, if stability and purity means nothing to you. A few weeks ago I bought a little SBC (Quartz64) for my homemade NAS project. Since I'm already a NixOS user, the bootstrap process was easy: - Build ARM image for NixOS and boot off the device - Clone my dotfiles and symlink my config folder into /etc/nixos - Rebuild my system And boom. Everything is there, my shell and coreutils and things I've come to expect all get rolled into the system. Updating it just means git pull and a system rebuild. As you say - it's not for the impatient. You have to maintain your config pretty regularly, and covering multiple devices across multiple architectures requires some deliberate config organization. I'm not sure where I fall on the patience spectrum, but NixOS worked out pretty great for me. It's on my desktop, laptop and homeserver, and I haven't had a single bad update in my 8 months of daily driving it.
- skavi 3y agoHow do people deal with isolating system specific config in Nix? Like stuff for a particular graphics card?
- huijzer 3y agoI use symlinks from configuration.nix and hardware -configuration.nix and point to specific instances for specific systems.
- throwaway22032 3y agoI have "if hostname == xyz" in my config, or I use a little config file with flags like "is_laptop".
- smoldesu 3y agoThere are a few solutions to this, but I keep separate configs for each device and link them into the entrypoint (/etc/nixos/configuration.nix) as-needed when I set things up. Then I have other "module" files for my terminal environment and my desktop environment, as well as an extra file that enables Wine/gaming packages.
- JamesLeonis 3y agoIn addition to the other suggestions, you can create different files for (e.g) each machine and use common includes for your apps and settings.
- evil-olive 3y agopersonally, the way I do it is: /etc/nixos/roles/foo/default.nix has config for the 'foo' role (eg, I have a desktop role that enables all my GUI options) configuration.nix and hardware-configuration.nix in /etc/nixos/ are symlinked to the actual files in /etc/nixos/hosts/<hostname>/ in the imports section of each machine's configuration.nix, I import /etc/nixos/roles/foo for each role the machine should use. for your graphics card example, I have 'nvidia' and 'nvidia470' roles that pull in their respective nvidia driver (due to an old gaming laptop that requires the legacy driver version) I have a 'core' role that all machines import, with the global config I want on every host this allows me to version-control my entire /etc/nixos directory (managed as a private git repo, replicated using syncthing rather than pushed to Github/Gitlab/etc). the symlinks in /etc/nixos are in .gitignore because they're machine-specific, and the actual per-host config files are able to be tracked in their own directories.
- anotherhue 3y agoI mount '/' as a tmpfs so yes, I nuke my OS every reboot. It's reconstructed from the /nix/store and obviously my homedir is on a persistent volume.
- eikenberry 3y agoIf this setup could be combined with an easy way to customize things, like ublue (https://ublue.it/ https://ublue.it/) lets you customzie fedora silverblue using Dockerfile configs, I'd adopt it in a heartbeat.
- bfrog 3y agoI’d think configuration.nix would be enough?
- anotherhue 3y agoI have yet to find a non customisable nixos component. It'd a source system that's excellent at building from source so there's always a way.
- eikenberry 3y agoSorry, I was unclear, by easy I meant simple. Dockerfiles are simple. I've yet to find an equivalently simple way with Nix.
- anotherhue 3y agoI haven't tried it but I would suggest looking here for some inspiration https://nixos.wiki/wiki/NixOS_Containers https://nixos.wiki/wiki/NixOS_Containers
- peoplearepeople 3y agoWhat does the config for doing that look like?
- 3y ago
- thomastjeffery 3y agoPatience isn't necessarily for time: it's for wasted time. That's not to say NixOS won't waste your time: it will just waste it in a different way.
- zetalyrae 3y agoI thought "too complex, too much of a timesink" and that kept me from trying it for a long time. My experience is different. If you are at all idiosyncratic about your setup, using Nix is better than whatever pile of bootstrapping bash scripts you've kludged together over the years.
- n8henrie 3y agoAbsolutely. I'm about a year deep on nix / NixOS and still spend way too much time refactoring things to be more DRY or what I think might be more idiomatic or maintainable going forward (as opposed to a more obvious but uglier approach). Definitely makes it easy to waste time prematurely optimizing, if you're prone to that sort of thing.
- soraminazuki 3y agoThe difference is that with Nix, you'd always have a working configuration. With traditional deploy tools, scripts stop working at the most inconvenient timing because they're not reproducible.
- cosmojg 3y agoI can do (almost) all of these things with a traditional Linux distribution, git, and a few scripts written in my language of choice, and I can do it faster. Nix seems more competitive with something like Conda or Spack than a traditional package manager like Apt or Pacman. Similarly, NixOS seems more suitable for deployment in containerized environments built on woefully outdated deps than personal dev setups with generally higher security requirements. I've experimented with both Nix and NixOS, and while I adore both the beautifully functional language and the endlessly helpful community, I haven't been able to justify the overhead of maintaining a nix.conf, flakes or no flakes, on top of everything else I need to do on my machines. I kept running into issues where some program I needed wasn't already integrated with the Nix way of doing things or something that worked on my Linux setup failed to work on my macOS setup despite multiplatform guarantees. Nevertheless, I wait with baited breath for the day that Nix replaces Conda among a critical mass of practitioners in my field. I've tried getting a few of my teams to switch (with help from Devbox and Devenv), but it's a struggle to get people to learn new things when their (often worse) way of doing things works well enough most of the time. Heck, I count myself lucky for getting some people to switch from the atrociously slow Conda to the significantly faster Mamba as even that was inordinately difficult despite for latter being a drop-in replacement for the former.
- zetalyrae 3y ago>I can do (almost) all of these things with a traditional Linux distribution, git, and a few scripts written in my language of choice, and I can do it faster. As someone who moved from a directory of numbered bash scripts and GNU Stow to Nix, I can't disagree more. The fundamental difference is one is imperative and the other is declarative (and reproducible), and that makes all the difference.
- indemnity 3y agoExactly. I have used Linux since 1994, from Slackware to RedHat to Debian to Gentoo to Ubuntu to Arch. NixOS and nix-darwin both using nixpkgs is the first time I have the exact same shell and programming/CLI environment on all five of my personal and work machines which run Linux and macOS. I upgraded them all to the 23.05 versions from 22.05 by updating my flake.lock and doing a rebuild switch on all machines. No regressions. Some cobbled together shell scripts and a Git home dir management system (yadm) is what I had before and it doesn’t come close. I also dreaded upgrades with the previous approach. And didn’t have nearly the same control pristine replicated environment across machines. It’s even flexible enough that on Linux desktop machines I have X11 and bspwm DE environment, on servers no X11, and on macOS it configures my system preferences, Dock icons and installed App Store apps.
- slabity 3y ago> Everything in a Nix-based system must be derived strictly from (lockfiled) inputs, making the reproducibility guarantees incredibly strong (barring any network errors or resources being taken down) Or multithreaded compilation :P
- jalino23 3y agoalright time to learn nix
- herewulf 3y agoAnd if you don't like it, you might try Guix which is a Guile Scheme based implementation of basically all the same concepts and features.
- UniqueUsername0 3y agoWrong. Guix's ecosystem is very much behind Nix's.
- npub1zenn0 3y agoThis is keeping me from immediately jumping on Nix. I'd rather use guix and scheme, but it's behind. If I learn nix, and then guix some day catches up, I'll already know nix and won't want to make the change anymore. Can't say I like the outlook for guix.
- herewulf 3y agoInteresting. I've been writing Bash scripts for over 20 years and despite my comfort with it, I'm always exploring avenues of replacing it. Despite the time investment already spent, I know there are far better tools out there to do the same jobs.
- herewulf 3y agoPerhaps you could expound upon that?
- xorcist 3y agoSo just like Puppet/Ansible/Salt then? > Nix is so robust that you could even nuke your filesystems on every log out Comments like these makes it hard to understand what is really going on. Persistent storage is kind of the point of using a computer instead of an abacus.
- colordrops 3y agoThere's been plenty of comments describing the difference between those tools and Nix, and various descriptions and docs are a single search away, so the snide comment comes off as ignorant. Most of us who use Nix came from one of those tools. I personally went from bash scripts --> Ansible --> Nix. Nix is lightyears ahead of Ansible. Since I'm familiar with these two, I'll tell you what's wrong with them: * They are imperative instead of declarative, so you have a ton of extra cognitive load figuring out the order of actions. I have thousands of lines of Nix config, change one file and it's not gonna break because something in another file was installed in the wrong order. * They are not suited for managing the entire OS, but rather a layer on top of an existing OS. NixOS manages everything from the bottom up, so there are no loose ends to break you. * They are not truly idempotent. You have to be very disciplined to keep them that way, including Ansible, despite their claims. My ansible deployments broke constantly * They don't have rollback capability. If you mess up on nix, a single command or keystroke on boot will bring you back to the last working deployment. * Their DSLs are not powerful enough of an abstraction. Nix is a fully fleshed out language so you don't have to write a bunch of boilerplate like Bash or need some special module like Ansible to make something happen. * Git support is first class. You can compose your installation from several git repos, so say you want the cutting edge version of a package, you can install the one directly from the maintainer's repo instead of the one in the nixpkgs repo * Speaking of which, Nix has more packages than any other distro. Key word here, DISTRO. Bash and Ansible aren't distros, and there is no central repo where anything you'd ever want to deploy is available and standardized and denormalized. And a Nix deployment has persistent and writable storage, not sure where you get the idea that it doesn't.
- xorcist 3y agoIgnorant, yes, but in no way snide. Each and every point listed here could have be taken verbatim from a ten year old blog post why Puppet, or later Ansible, is the new great thing. Being declarative and idempotent is the basic design idea of these tools. Managing every layer of infrastructure and the entire OS stack is also exactly what they aim for, and ironically also what many people regularly quote as why they haven't taken off more. Git support, and module versioning, is also completely on point. What is it that Nix does differently, and why? Is it a fundamentally different type of tool, such as Puppet is from plain Ruby scripts, or is it a better screwdriver? That Nix is a distribution in itself is an important difference. But how does that affect the use case? I realize the question have been asked before, but that's because not many attempts are ever made to explain where it sits in the problem space. It is not written for anyone who has experience with configuration management and infrastructure as code tooling, but instead for passive observers with the intention of bootstrapping the next hype cycle?