50

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?

all 35 comments
sorted by: hot top controversial new old
[-] aleph@lemm.ee 19 points 6 months ago* (last edited 6 months ago)

I've only tinkered with Nix in a VM so I'm no expert, but I will say this: for every person that raves about it, it seems there's someone else who decided that the hassle of learning an entirely new way to do pretty much everything on a Linux system, often with sparse documentation, wasn't worth the time investment.

Your experience sounds pretty much par for the course, to me. People who think Arch is hard have obviously never tried Nix.

[-] Oinks 12 points 6 months ago* (last edited 6 months ago)

I'm not sure why nix-env is so slow exactly but it's the wrong tool to use anyways as it just throws away everything NixOS has going for itself in favour of pretending to be a normal package manager. You really just want to use the configuration file.

The "normal" way to install packages in NixOS would be using environment.systemPackages. The various programs.<name> options are intended for packages requiring additional setup, like shells or desktop environments (e.g. iirc for sway it creates a systemd target and adds the .desktop files for login managers to see it). Weston has a package but not an option, so you'd have to figure that additional stuff out yourself (but running Weston from a tty should just work).

There are additional ways to install packages for single users or using home-manager but you don't need those.

This does kinda demonstrate why (I personally think) NixOS is so hard to learn: There's a million different ways to do anything and each has it's own weird gotchas. And critically most of them, even when they are honestly just legacy cruft, are not actually deprecated and may even have users advocating their use, or even if they don't nobody bothered to remove that part from the wiki (if it was ever there to begin with).

You can also see this in the flake/channel split: One person in this very thread is telling you to use flakes, while another is telling you to stick with the default (channels).

And in some (fortunately relatively rare) cases even things that everyone agrees are bad ideas still get promoted in official documentation or other prominent places, like using nix-env -i under any circumstances, ever.

And it is definitely a learning problem you are having. You are facing the same problems as a new Linux user who just installed Manjaro with KDE 6 on Wayland and is wondering why apt-get and xrandr are not working even though those are accepted answers on Stackoverflow posts from 2012. Of course as experienced Linux users we know why, but a new one has to learn a lot of stuff before "getting it" and will probably stumble onto poor advice more than once in their journey. (And learning Nix is arguably worse than learning Linux for the first time, but that depends a bit on your exact experience and background.)

If you stick to learning NixOS there will be a point when these things seem trivial, but it will be a lot of effort to get there. Is that effort worth it? Well, if the term "declarative package management" doesn't mean anything to you, maybe not. You do sacrifice a lot of things "just" to declare your entire system state in one configuration file (or more likely, directory). But I do think the things Nix does are really cool, if you can get over the, uh, everything.

[-] Oinks 6 points 6 months ago

Also coming from Arch will induce a bit of a culture shock regarding documentation as the NixOS wiki is just... not very good. It's neither complete nor reliably accurate for the current release. And some wiki pages are actually just snippets with no explanation for either what they do or why they do it.

[-] Corbin@programming.dev 2 points 6 months ago

nix-env must evaluate all of nixpkgs and the reference implementation of Nix is not very fast. It's not a big mystery, although it appears that a rewrite of Nix will be required to improve it.

[-] thejevans@lemmy.ml 9 points 6 months ago

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

[-] gramgan@lemmy.ml 9 points 6 months ago* (last edited 6 months ago)

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!

https://nixos-and-flakes.thiscute.world/

https://mynixos.com/

[-] Oinks 6 points 6 months ago* (last edited 6 months ago)

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.

[-] gramgan@lemmy.ml 4 points 6 months ago

Yeah that’s a lot of what kept me out of most of home-manager’s functionality. I will say, though, there are occasionally programs that have a lot of home-manager options yet few (if any) NixOS options (gammastep comes to mind), so I use it for those.

Also, configuring browsers with home-manager is fantastic!

[-] srestegosaurio@lemmy.dbzer0.com 1 points 4 months ago

If you need ti h-m can be extremely powerful since let's you add logic to config files. But again, only if you need it.

[-] xylazineDream@lemmy.dbzer0.com 1 points 6 months ago

This is the one, make it work, then slowly make it fancy

Besides, the dynamic nature of how many NixOs configurations work, is our only defense against the coming ai menace lol

[-] tatterdemalion@programming.dev 9 points 6 months ago* (last edited 6 months ago)

I've been using NixOS for almost a year. The learning curve is aggressive and the learning resources are not exactly friendly to beginners. I'd even say the tooling is poorly designed or at least seemingly redundant at times. You sorta have to grind through it. It was painful for me too, but I feel like I mostly get what I'm doing now.

If you're interested in diving deep, I suggest trying to write a Nix derivation for some software you use that isn't already available on NixPkgs. That was a good learning experience for me.

+1 to the people saying to start off using flakes for everything.

[-] wewbull@feddit.uk 7 points 6 months ago

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 a configuration.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 read nixpkgs more than documentation.

[-] kyleraykbs@lemmy.ml 7 points 6 months ago

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,

  1. Use flakes, nix channel is legacy and is imperative meaning nix channel changes won't be copied per system
  2. 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.
  3. 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
  4. 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.
  5. 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.
  6. 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.

[-] wewbull@feddit.uk 9 points 6 months ago

I appreciate by the tone of your post that you're trying to be helpful, but:

  1. 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?

  1. 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.

  1. 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.

  1. 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.

[-] Oinks 4 points 6 months ago

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.

[-] wewbull@feddit.uk 4 points 6 months ago

I appreciate the response. You seems to understand why this is frustrating at least.

Since writing my question about flakes I've seen a few pointers from people and read a little more. It seems like flakes solve the "problem" of the channel not being pinned to a specific version in the configuration.nix.

Honestly that doesn't seem to be a problem worth worrying about whilst I'm learning, especially if it makes the documentation obsolete.

I don't understand why people are so sold on it for beginners (yourself excluded).

[-] kyleraykbs@lemmy.ml 3 points 6 months ago

I wish there were more resources I'm just tryina point you in a general right direction. I should a included more stuff though.

  1. Use Flakes You can think of flakes as declarative channels, with the added ability of using multiple channels at once and importing other flakes. I use both stable and unstable on my system and my flake has both. They also allow you to import other projects that use flakes a great example of this is base16.nix and my neovim config, try running nix run github:kyleraykbs/neovim and add the expirimental features flag it will complain at you about if you dont have flakes enabled.

  2. To clarify, I ment declaratively, cause 'the nix way' isnt pure if you use channels and such, I could a been more clear about that sorry.

  3. This is a complicated one.. You aren't reverse engineering it, its open source and in my opinion NixLang actually documents itself quite well, I haven't had a problem with the readability of nixpkgs and there's even a link to the source on search.nixos.org for any given option or package. On top of that NixOS is a rabbit hole of abstractions and at least personally I find it harder to build stuff for if I dont understand the layers of complexity that I'm standing on, reading the source is the only real way to do it as of current. But it is understandable that it might be hard to understand as a new user, and unfortunately my only suggestion is to read other peoples configs, that gave me a good idea of what to do and how to do it, still a pain of course but nix will hurt you a lot before it starts to get nice to use. Also once again vimjoyer is a wonderful resource for all of this.

  4. It makes it so all config is done in NixLang and therefore can take full advantage of nix, it also allows you to drop your home configs or parts of it on on any machine with just the config. Its just nixos but for your home, and as I said in my last comment the more nix tracks on your system the easier your life is.

The learning curve just will be steep and as someone who got though its worth it.

[-] lord_admiral@lemmy.world 1 points 6 months ago

My qualifications allow me to write flake on my own, and I have even tried doing it. But after a bit of figuring it out, I set the recommended ISO, connected an unstable channel (I used 24.05 back when it wasn't mainstream), configured the whole system according to the NixOS Wiki and...used the system daily, delighted with its amazing flexibility and stability. I've described everything I don't like about the "experimental features" here

I remember Dolstra writing on his blog that flakes' are needed to "ensure the best tolerance". Haha, I ensure portability of my system with a single yusb flash drive. I think Dolstra got tired of messing around with NixOS and wanted to reduce development costs by annoyingly suggesting a switch to flakes`.

[-] nickwitha_k@lemmy.sdf.org 3 points 6 months ago
  1. 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

This is what caused my bad initial experience and has left a bad taste in my mouth for the whole thing. I'm not a fan of the syntax and DSL but, could get over that with good docs. I DO find the concept interesting but until the docs are useful, it's a non-starter for me.

[-] lord_admiral@lemmy.world 1 points 6 months ago

I have a few questions. If your opinion is correct and nix-channels are rotten outdated crap, why aren't they removed from use? Why hasn't any of the nix developers decided to make flakes an integral part of the system yet? I can answer these questions. Any operating system is a complete piece of software only when it follows the developers' backbone logic. At the moment when NixOS becomes a collection of flakes of varying degrees of stupidity, NixOS will cease to exist. Everyone knows and keeps silent that Dolstra started all this nonsense with flakes and home manager only to attract more defectors from other systems. There is no other reason. When a person has worked 30 years in production, he will hardly want to retrain for a new architecture and learn a rather stupid language. The home manager is a crutch written by a third-party developer and its only task is to make the /home folder look familiar to the Arch Linux user. There are no other functions. In the end, all flakes end up in configuration.nix overcomplicating and confusing the configuration. So it's much better to stop chasing other people's hyprland configs and install the recommended ISO, switch to an unstable branch and...read the Wiki.

[-] kyleraykbs@lemmy.ml 1 points 6 months ago

Dude what are you on about? Channels are just imperative and that kinda goes against the purpose of nix same deal with why I recommend home manager, if you're gonna do NixOS imo you should do it pure and it sounds like op wants that. The rest of your rant is absolutely unhinged.

[-] lord_admiral@lemmy.world 1 points 6 months ago

When dudes use flakes config, they usually disable channels by lock their setup to their/anyone's github. This is kind of how it works.

[-] kyleraykbs@lemmy.ml 1 points 6 months ago

I use flakes and I do disable channels yeah but that wasn't what the other 90% of your post was about

[-] lord_admiral@lemmy.world 1 points 6 months ago

Can you please tell me how you managed to measure the percentage of "about this" and "not about that" in my comment? In any NixOS community, there are always a bunch of people ready to cut the throat of anyone who says "flakes is dogshit". These are the same people who are always crying "I downloaded flake from some crappy github and now my beloved hyprland doesn't want to work". Is this a coincidence?

[-] kyleraykbs@lemmy.ml 1 points 6 months ago

Never seen anyone do that?? But dude if everyone is telling you that your doing it wrong, you might be doing it wrong.

[-] lord_admiral@lemmy.world 1 points 6 months ago

Your problem is that you are drawing the wrong logical conclusions. The crowd can be wrong.Especially if the crowd relies on collective intelligence.

[-] Unmapped@lemmy.ml 5 points 6 months ago* (last edited 6 months ago)

I switched from arch to nixos a few months ago. I would recommended going straight to using flakes and never touching channels. Channels really confused me when I started.

Also don't ever use env to install packages. Just add them to your configuration file and run rebuild.

This video help me a lot when starting. Its a bit old but I don't remember anything being wrong. He goes over how to use channels and how to setup to update using flakes. Also covers homemanager setup. Nixos setup guide

Also Vimjoyer has some great nixos videos.

[-] sloppy_diffuser@sh.itjust.works 5 points 6 months ago

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.

[-] rutrum@lm.paradisus.day 4 points 6 months ago

Sorry about your troubles. Keep at it, I promise its greener on the other side.

One tip: nix-env installs things ad hoc. Its against fhe whole philosphy of nix, where your system state is defined in files. So don't ever use that. If you need any generic package, you can add it to environment.systemPackages. If you accidentally installed something that way, its okay. Just know you might get an error if you try installing it both from nixos-rebuild and nix-env. If that happens, just uninstall from nix-env.

[-] uthredii@programming.dev 3 points 6 months ago* (last edited 6 months ago)

I have definitely found it challenging at times to do even simple things. I think it does get easier over time.

I really hope the new user experience will improve. Once the issues with flakes are fixed and they are no longer experimental I would expect flakes to replace the other ways of doing things. This will hopefully make the documentation more concise/focused/better. It might also mean more people start using nix/flakes which will surface more of these problems to be fixed.

I think people need to decide if the benefits they are getting are worth the challenges. I personally really like the reproducibility and the massive amount of packages available from one place. On other distros I have used things have ended up breaking eventually and I have had to re-install things and search for fixes. But on NixOs things keep working.

[-] Corbin@programming.dev 3 points 6 months ago

You're doing fine. Slow down. Forget "installation"; it's not a concept Nix uses. If jumping directly to NixOS is overwhelming, it might be easier to go back to Arch, Ubuntu, or something else you know and are comfortable with, and use Nix from a familiar distro; build up idioms for working with your preferred tools, development environments, and configuration. When you're ready, you can try NixOS again, and hopefully it will make more sense.

[-] Ephera@lemmy.ml 1 points 6 months ago* (last edited 6 months ago)

I have no knowledge of NixOS, but:

missing pkg-config file for openssl

That's relatively common error with Rust dev, unfortunately. You need the pkg-config library installed on your system. On most distros, you install the pkg-config package via the OS package manager and then it works.

Also unrelated but am I correct in assuming that I cannot install KDE without also installing the X server?

Doesn't work on openSUSE either. I believe, SDDM (the login manager) still makes use of X11.

this post was submitted on 01 Jun 2024
50 points (100.0% liked)

Nix / NixOS

1831 readers
1 users here now

Main links

Videos

founded 2 years ago
MODERATORS