13 ms·
I recently moved my laptop, desktop, and a few servers from Arch Linux to NixOS with flakes and home-manager. It is amazing! The complete configuration for all
by nitsky 5y ago
I recently moved my laptop, desktop, and a few servers from Arch Linux to NixOS with flakes and home-manager. It is amazing! The complete configuration for all machines is in a single git repository, I can share configuration between them, and a `flake.lock` file guarantees all machines are using the same version of everything. No more trying to remember what command I need to run to install and configure software and no more copying files from `/etc` between machines. Best of all, if I need to rebuild a computer from scratch or buy a new one, just running `nixos-install --flake myrepo#mymachine` configures everything so I can pick up right where I left off with an identical setup.
I also appreciate that a lot of frequently used configuration is easy to enable. For example, to install podman, the Arch wiki details a number of files in /etc you need to edit. On NixOS, just add `podman.enable = true;` to your configuration and you're done.
At this point, I think NixOS is hugely underrated and I strongly encourage anyone who is an advanced linux user to try it.
- CloselyChunky 5y agoCould you share a link to your repo? This setup sounds interesting. Currently I have two separate repos for NixOS and home-manager.
- nitsky 5y agohttps://github.com/nitsky/config https://github.com/nitsky/config
- res0nat0r 5y agoI use nixpkgs on my osx laptop for most everything over homebrew these days, I've upgraded nix to 2.4, but home-manager isn't compatible. Hopefully that will change soon.
- mekster 5y agoGood thing about nix package manager is that you can have same path using it on macOS and on Linux, so your shell config files are easier to maintain without if's. Linuxbrew installing at /home/linuxbrew/.linuxbrew/ is a bit of a joke too.
- nitsky 5y agoNix is a great replacement for homebrew, but the lack of native support for Apple Silicon at the moment is a blocker for me.
- Ericson2314 5y agohttps://github.com/NixOS/nixpkgs/pull/105026 https://github.com/NixOS/nixpkgs/pull/105026 this was recently merged so that should start rapidly improving.
- lloeki 5y agoThe show's happening here now: https://github.com/NixOS/nixpkgs/issues/95903 https://github.com/NixOS/nixpkgs/issues/95903 https://github.com/NixOS/nixpkgs/pull/125184 https://github.com/NixOS/nixpkgs/pull/125184 https://github.com/NixOS/nix/pull/4867 https://github.com/NixOS/nix/pull/4867 There's also not-directly-related cross-functional need here on the install process: https://github.com/NixOS/nix/pull/4289 https://github.com/NixOS/nix/pull/4289
- alias_neo 5y agoSo if I understand correctly, I could declaratively specify my workstation, say I want vim, podman, codium, kubectl, curl, tmux, firefox, zettlr. I could put this in a configuration and have my workstation anywhere I can grab that from? Is there some way I can boot-to-git-configuration? So I could do this in RAM on someone else's hardware, like a network boot?
- mason55 5y ago> So if I understand correctly, I could declaratively specify my workstation, say I want vim, podman, codium, kubectl, curl, tmux, firefox, zettlr. I could put this in a configuration and have my workstation anywhere I can grab that from? Yes, and you can specify your .vimrc, your vim plugins, the users you want setup, their SSH keys, your systemd config, etc. > Is there some way I can boot-to-git-configuration? Bootstrapping a system is the one place where you still need to do a bit of work, but it's not bad. I personally have a script in my Nix config repo which pulls my config down to disk, sets up symlinks, and then switches to the new config. From there everything then goes through standard Nix tooling.
- Filligree 5y agoWhat you can relatively easily do is extend the 'installer' config with whatever you want to add there, for instance applications and a desktop environment. It should be relatively straightforward to also mount /home from a separate USB stick partition, but I haven't tried.
- mason55 5y agoOh yeah, that's not a bad idea and definitely what I'd do if I was bootstrapping a bunch of hosts at once. As it is I set up maybe one new host a year, which means that it's at least as much work to rebuild an installer boot media + my config as it is to do a base install and then pipe a script through bash to finish setup.
- alias_neo 5y agoAmazing thanks. I'm going to start taking a look at getting a simple configuration started with my basic setup, keys, shell, tmux config etc.
- rkangel 5y agoHonestly - how painful was it to learn and get working? And what limitations/niggles are left when using as a workstation? I love the principles behind Nix, and I like to use it to provide development environments (through nix-shell locally and then using the same setup in CI). But some things can be moderately painful to get going.
- nvarsj 5y agoYou're looking at a solid 10-20 hours of hacking stuff together to get a decent working system, and you still won't understand a good 80% of what you copied from various repos. I've been using NixOS for a year now, and I have a definite love/hate relationship. Many times I miss the simplicity of Arch, where I understood _everything_ about my system and how it was configured. NixOS is like learning everything all over again, but in a weird, poorly documented language+standard lib that nothing else uses. I think when you are super comfortable with it, is when it becomes truly amazing. But that takes a lot of dedicated time and effort.
- OhSoHumble 5y agoThis is where I'm sitting right now. I'm trying out Void Linux on my laptop and it's just so simple. I love that I understand my system. I look at Nix as a language and I just have no idea what is going on. What I'd really like, as a learning resource, is a "Nix for apt/yum users" or a "Nix for Ansible" users guide. There is the cheat sheet (https://nixos.wiki/wiki/Cheatsheet https://nixos.wiki/wiki/Cheatsheet) but it's just not enough. For example, I wanted to just... create an arbitrary directory in my home directory (~/workspace). Does Home Manager do this? If so, how? Do I just have a shell script that is called within a package? That seems excessive. Is this not a use case for Nix? It looks like it can do arbitrary tasks across the system but the documentation is so bogged down with theory that it takes forever to find practical applications.
- m45t3r 5y ago> For example, I wanted to just... create an arbitrary directory in my home directory (~/workspace). Does Home Manager do this? If so, how? Do I just have a shell script that is called within a package? That seems excessive. Is this not a use case for Nix? It looks like it can do arbitrary tasks across the system but the documentation is so bogged down with theory that it takes forever to find practical applications. You are definitively trying to do too much at the same time. Before using Home-Manager (that is a community project, it is not endorsed by NixOS except by allowing to be hosted on the nix-community group on GitHub), I stayed at two years playing with only NixOS. It is only after I got comfortable with Nix and NixOS that I decided to migrate my configuration to Home-Manager. Not saying that you need that much time to use HM, just that HM assumes that you're know a reasonable good amount about Nix and NixOS. So I would say, start with less: try NixOS first, it is kinda easy to use compared to other "advanced" Linux distros like Arch and Void. The easy things are really easy, the hard things can be really hard at first but I don't think you need to know much about Nix to be proeficient on NixOS nowadays. Also yeah, you will need to search some things, but since the scope is reduced it is easier to find answers.
- Jiocus 5y agoLong time Arch user here but I'm growing more interested in NixOS by the day. I'm mainly “utilitarian” in my OS choice and other things being equal, Arch's AUR packages is what keeps me using it. How does the Nix ecosystem compare with AUR? Would you still recommend making the switch?
- nitsky 5y agoAlmost everything I used on Arch is available on NixOS. In fact, for a lot of software I was able to use a more advanced configuration because NixOS makes it easier than Arch to set up. I only ran into one hiccup: NixOS has an open pull request for supporting plymouth for silent boot with a LUKS encrypted drive. For now, I am stuck with an ugly password prompt when I turn my computer on.
- Jiocus 5y agoGreat. That won't be a problem, as I love ugly password prompts. Edit: Relocating /boot to a flash or SD-card is also a way to accomplish deniability of a cryptroot.
- curriculum 5y agoIt should be pointed out that you can install the nix package manager in Arch (or whatever other Linux, or macOS, etc.), so you can try out nix's declarative package management without actually switching to NixOS.
- Jiocus 5y agoDoh! You're right, I completely forgot that. Thanks for pointing it out.
- toastal 5y agoI tried this on my previous laptop and ran into a number of issues once I tried to install anything with a GUI. It's fine for shells and CLI tools though. I migrated some configs over to a Nix configs under Arch, and while it was a pain to initially set up NixOS (unfamilarity), it's a lot easier doing everything else now.
- sorbits 5y ago> and a few servers The problem I see with NixOS on a typical personal server is that you have to setup all these things using nix expressions, from which the actual configuration files are generated. That means if you e.g. want to install postfix, instead of learning about main.cf you have to learn the syntax of the nix configuration wrapper for postfix, and postfix having hundreds if not thousands of options, many referring to external files/databases, you have to hope that whoever did this configuration wrapper, supported all the features of postfix that you want to use. I am using nixpkgs on macOS, and I run a personal server with mail (for a bunch of people), web (for a bunch of sites), DNS (for a bunch of domains), etc. and while I would love to switch to declarative configuration, I fear I would run into shortcomings with the configuration wrappers for the various software packages I use. I am curious if anyone have experience to share?
- nitsky 5y agoNixOS makes it easy to emit raw configuration files if you want. I do this for software where I want more control than the Nix wrapper exposes.
- kaba0 5y agoYour best friend is https://search.nixos.org/options https://search.nixos.org/options From a quick search, it seems you can use `services.postfix.config` and pass key-value pairs as arbitrary options. Not familiar with this service, but usually if a given one has more complex syntax, there is a “pass-through” option that will simply append to the given config file whatever text you provide, as well as as the sister reply says you can create manually additional files.
- sorbits 5y agoThe thing with a lot of server software (like postfix) is that configuration is usually spread across many files. And then there is the re-use of things between services, for example DKIM’s generated public key should be made available as a TXT record by the DNS server, the SSL certificate kept up-to-date by the web server should be used by both the smtp and imap servers, though it may need to include the full chain, and services may need to be relaunched, if the certificate is updated, etc. I was hoping to hear from someone who had managed to get a “full” server running (with SMTP, IMAP, DKIM, DNS, DNSSec, HTTPS via ACME, etc.), because while I know that I can output raw configuration files, it seems like an extremely daunting task to weave all this together in something semantically meaningful. Right now I have /etc under git control and a Makefile that handles all dependencies between the various pieces (i.e. to ensure proper files are regenerated/indexed as needed, and services relaunched when dependencies are updated).