I recently tried switching from Arch to NixOS and the experience I had can best be described as apalling. I have not had a new user experience this bad since my first dip into Ubuntu dependency hell back in 2016. I’d like to preface this by saying I’ve been a Linux user in one form or another for almost half my life at this point, and in that time this may well be the most I’ve struggled to get things to work.
Apparently they have this thing called home-manager which looks pretty cool. I’d like to give that a shot. Apparently I have to enable a new Nix channel before I can install it. I’m guessing that’s the equivalent of a PPA? Well, alright. nix-channel --add ...
, nix-channel --update
(oh, so it waits until now to tell me I typo’d the URL. Alright), and now to run the installation command and… couldn’t find home-manager? Huh?? I just installed it. I google the error message and apparently you have to reboot after adding a new nix-channel and doing nix-channel --update
before it will actually take effect, and the home-manager guide didn’t tell me that. Ah well, at least it works now.
I didn’t want to wait for KDE and its 6 morbillion dependencies to download, so I opted for Weston. It wasn’t a thing in configuration.nix (programs.weston.enable=true;
threw an error and there was no page for it on the NixOS wiki), but it was available in nix-env (side note: why does nix-env -i
take upwards of 30 seconds just to locate a package?), so I installed it, tried to run it, and promptly got an inscrutable “Permission denied” error with one Google result that had gone unresolved. Oh well, that’s alright, I guess that’s not supported just yet – I’ll install Sway instead. Great, now I have a GUI and all I need is a browser. nix-env -i firefox
gave me the firefox-beta
binary which displayed the crash reporter before even opening a browser window. Okay, note to self: always use configuration.nix. One programs.firefox.enable=true;
and one nixos-rebuild switch
later, I’m off to the races. Browser is up and running. Success! Now I’d like to install a Rust development environment so I can get back to work. According to NixOS wiki, I can copy paste this incantation into a shell.nix file and have rustup in there. Cool. After resolving a few minor hangups regarding compiler version, manually telling rustc where the linker is, and telling nix-shell that I also need cmake (which was thankfully pretty easy), I’m met with a “missing pkg-config file for openssl” error that I have absolutely no idea how to begin to resolve.
I’m trying to stick with it, I really am – I love the idea that I can just copy my entire configuration to a brand new install by copying one file and the contents of my home directory and have it be effectively the same machine – but I’m really struggling here. Surely people wouldn’t rave about NixOS as much as they do if it was really this bad? What am I doing wrong?
Also unrelated but am I correct in assuming that I cannot install KDE without also installing the X server?
I love nix. I started on flakes and have no clue what configuration.nix, channels, or nix-env even are.
Its pretty much a toolchain to orchestrate a bunch of community bash scripts with some (optional) syntax sugar to do most things right in nix.
Scripts break. So did my own when I left the sandbox of any other distros curated version set. Now its version controlled and I can rollback.
Functional programming skills are helpful. The documentation is shit. Like really really bad. I had to go through a few lib/ src to figure out modules. It just wasn’t clicking until I did with the abstractions until I looked at the code.
I mostly search GitHub now a days for solutions with
lang:nix
and some tokens I know I’ll need and analyze what someone else did.I look at the source for package defs often.
The repl can be handy.
I basically went straight to using flakes when I switched from Arch to NixOS, so I can’t speak to channels.
I use home-manager as a NixOS module. It’s a bit clunky, but it works well.
I was told when I started to basically never use nix-env, so I don’t.
For development environments (I do both rust and python), I use https://github.com/the-nix-way/dev-templates
My config is here if you want something to work from https://github.com/thejevans/nix-config
Hello! Made a Lemmy account to comment on this, I’ve been a long time lurker. As someone who also went into Nix blind, its always gonna be a hard time a first, its a super different paradigm then anything else out there. Few recommendations,
- Use flakes, nix channel is legacy and is imperative meaning nix channel changes won’t be copied per system
- Try to purify everything, you may not succeed but if you try to nixify everything then you’ll get a much better understanding of the underlying systems of nix and of course your is.
- Fuck the wiki read the code and other peoples configs. The wiki and the docs have largely been misleading and the nixpkgs code is usually super easy to read, the source is also linked to on search.nixos.org
- Use home manager early. Working with NixOS gets better at a rate exponential to the amount NixOS has control over and your home environment is a huge part of that.
- Learn modules, all of nixpkgs is made of modules and your system should be as well, if you throw everything into one file you’ll have a really hard time generalizing later on, check out vimjoyers channel for this seriously he’s great.
- Understand that Nix, NixOS and NixLang all are huge upfront investments of time for a time save later on, its absolutely worth it in my opinion but you need to be aware its gonna be very difficult and you should focus on putting your energy towards the parts most important to you. If you have multiple systems you want nix to seamlessly deploy on focus on system relationships like roles, users, flake parts, etc.
And full disclosure once you get over the learning curve it gets easier to write and understand nix, but you realize you did everything poorly and you’ll restart.
I appreciate by the tone of your post that you’re trying to be helpful, but:
- Use flakes
Why? What are they? How would I find out about them?
All I’ve heard about flakes is that it’s an experimental feature that’s still evolving. Shouldn’t I learn the stable system first?
- Try to purify everything
That’s what I’m trying to do. Doing everything the “nix way” but that means none of my previous knowledge is useful. It’s a very steep learning curve.
- Fuck the wiki read the code and other peoples configs.
So you’re telling me I need to reverse engineer everything I want to do with no documentation. Great.
- Use home manager early
Why? What is it ? What problem does it solve?
check out vimjoyers channel for this seriously he’s great.
Ok, a tangible resource to go look at. Great, will do. Thanks for that, but most other things you wrote put me off more than help me.
Nix’s biggest issue is that it has a steep learning curve and throwing more things (flakes / home manager) into the mix just makes it feel more daunting. That’s especially true when you’re saying to ignore what small amount of documentation there is.
The matter of flakes is complicated. Yes they are experimental, but in reality most Nix users use them despite that. I’m a bit on the fence on whether you should start with flakes because they do add some complexity. You can copy paste a sample flake configuration from the Internet (there are many but they all do exactly the same things) and you’ll probably be fine but telling people to just copy paste code they don’t understand feels wrong as well.
Regarding documentation… I wouldn’t go as far as saying you should avoid it entirely but it is in a very unfortunate state with a lot of wiki pages being outdated or just containing snippets that do things in very weird ways, or are over engineered to the point of being incomprehensible.
And that’s if someone bothered to write up anything at all. It’s a bit sad but reading from the nixpkgs GitHub (or other people’s dotfiles) is sometimes the only way to get certain information, such as valid values for package overrides.
I’m struggling too. You allude to it, but I think my main problem is that often the only information you can find about configuring a particular package is a tangentially related discourse thread, or a tiny outdated paragraph on the wiki.
Applications are generally fine. You add them to the list of packages and then you start using them. The problem is services where there’s lots of unique configuration to be done, or programs that have a plug-in architecture. Take something like Home Assistant or Kodi and there’s quite complex nixpkgs code for them. However there’s no documentation the explain what the user is meant to do. Kodi, for example, has a set of
kodiPackages
plug-in packages. The wiki page gives two methods without information on why to choose one or the other, and just aconfiguration.nix
snippet for each. So far, I’ve managed to get the plug-in files on the disk, but not to get Kodi to use them. To get his far, I’ve needed to readnixpkgs
more than documentation.Hey friend,
My recommendation is to keep things dead simple as you start out—no fancy channels or flake inputs and such, at least not where not necessary. I’ve found a lot of success in going slow, and not feeling rushed to do everything the NixOS way at first (for example, I still manage my dotfiles with GNU
stow
instead of home-manager). I started off with a very simple flake and basically just using my configuration.nix to declare packages, gradually learning more from there. The Nix ecosystem is as extremely powerful as it is poorly documented—it unfortunately sometimes takes a while to (as you’ve noted) even just find information.I’ve linked below two sites I found unbelievably helpful in my journey—the first one helps you get up and running with a very simple flake (and, yes, you will want to use a flake, even if it isn’t obvious right now why), and the second one is a huge search engine of all NixOS options, the first place I check when I’m putting something new on my system.
Good luck!
As a Home-Manager user I would argue it’s not really worth it. It has it’s moments for some applications but most of the time it’s the same experience as editing the config files directly. Except instead of INI or TOML it’s stringly typed Nix attrsets and you need to rebuild the entire system instead of restarting the app. Not exactly a huge improvement.
And that’s when you’re lucky enough that what you’re configuring can be mapped to attrsets. Styling Waybar via Home-Manager means writing CSS but it’s a multi line string in Nix with no appropriate editor support whatsoever, and writing custom actions for Nixvim means writing Neovim-Lua but… that’s right, in a multi line string.
On a more positive note, I will second the recommendation for the NixOS & Flakes Book, I found it to be much more useful for getting my head around flakes (and Nix in general since I started using them fairly early on in my Nix journey) than e.g. Vimjoyer’s videos, which are good but their repositories were really really cryptic to me at the beginning.