News for hackers. Stuff that matters.
Re:My NixOS Desktop Flow by tinco on Sunday April 26, 2020 @03:58AM (#22985415)
So with NixOS your process would look like this. Open up your editor on one of your devices thats already running. Write up a nix config that sets up i3 and firefox, could be just a couple of lines. Save it on a usb drive along with nix itself. Boot your new pc off the USB drive and your set.

And thats just the first time you use nix. Next time you just reuse that thumbdrive, or redownload it, and get your config from a git repo you are tracking your config in.

I have a git repo that has configuration for three types of devices I run in my personal setup (desktop, nas, webserver). They all inherit from my base configuration which has stuff like the user configuration and maybe my vim how I like it. The server adds docker and runs the docker containers that it should. The nas mounts the raid array etc.

If I want to know how I configured my nas three years ago, all I have to do is read the nix file I checked onto github. Thats powerful.

Re:My NixOS Desktop Flow by rustybolt on Sunday April 26, 2020 @05:08AM (#22985720)
> Write up a nix config that sets up i3 and firefox, could be just a couple of lines

You forget the step "find out what to write in the nix config file". Might take anywhere from less than a minute to forever, depending on experience, google-fu, and documentation.

Re:My NixOS Desktop Flow by tinco on Sunday April 26, 2020 @08:44AM (#22986741)
Well obviously, I'm just pointing out why you would want to spend some time figuring it out. NixOS isn't just another linux distro, it's the next generation of operating systems.
Re:My NixOS Desktop Flow by abrouwers on Monday April 27, 2020 @09:35AM (#22995661)
I don't know, the "benefits" have been well preached for years, and I don't see NixOS gaining popularity (though, I tend to focus on the linux community news, so might be missing the visibility). To me, NixOS is a cool concept, but I think it solves a problem that not a lot of people have. I mean, how often are people "redoing their systems from scratch," deploying to new machines, etc? That's like a once-every-four-year thing for me, and it's way easier to just dump a list of packages.
Re:My NixOS Desktop Flow by tinco on Monday April 27, 2020 @10:09AM (#22995955)
People mostly don't have the problem because Ansible et al solve it for them. It's the classic situation of a good-enough solution existing, making the superior solution irrelevant.
Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @12:55PM (#22997587)
Agree, what is going for Nix is that is a valuable tool and is very versatile. NixOS is just one application.

From OS point of view you no longer need:

- Kickstart

- Ansible, Saltstack et.al.

- Custom package repo for custom packages (if you need to customize something)

There are other areas too:

- create common developent environment, makes sure every developer has exactly the same tools installed with exactly same versions, so no more "it doesn't work on my machine"

- build system

- CI/CD

- packaging (as mentioned, you no longer need artifactory, instead you can have nix cache)

- there is also potential to use it for IaC, there's NixOps, but currently this is maybe the weakest part of Nix, it only covers deploying a box, but if you want to do something more complex, like autoscaled service it gets in the way. It is great for developing a new image though. There are terraform integrations, I didn't try them yet, might work better.

- you can configure local developer machine to use build system for local builds as well. If caching is configured, then once code is deployed it will already cache good build so it doesn't need to redo it

- for personal use with things like home-manager it can replace dot files as do more, you can have the same environment each time. Let say you change job and get a new laptop you can have it quickly set up the way you want it

Re:My NixOS Desktop Flow by majewsky on Sunday April 26, 2020 @09:56AM (#22987163)
https://nixos.org/nixos/options.html massively helps. Sure, some things you have to build for yourself and that may take some time, but a surprising amount of stuff has been done already and you just need to flip one of these options to activate it.
Re:My NixOS Desktop Flow by na85 on Sunday April 26, 2020 @01:39PM (#22988702)
What's the value proposition over something like Debian where it Just Works(tm)?

Maybe if I was a sysadmin managing a herd of boxen I would like this, but for a guy with only two Linux systems (plus my mac, plus my windows boxes, plus my openbsd pcengines etc.), it seems like a lot of fuckery with text files for little to no actual improvement in my UX.

Re:My NixOS Desktop Flow by tinco on Sunday April 26, 2020 @03:18PM (#22989408)
It's the same as with git. Some people don't use git when they're working on a project solo. I don't get that at all, NixOS is a fundamentally improved way of managing your operating system. The only real reason not to use it is because you're in a company and your business needs to avoid risks like sysadmins not getting your tech stack, or some component not working because there's a bug in a less battle-hardened setup.

When you're solo there's no such restrictions, you can just use the nicest tech that's out there. I've been amateur-adminning debian/arch/ubuntu machines for 15 years now, NixOS is such a relief to be rid of that mess.

Re:My NixOS Desktop Flow by na85 on Sunday April 26, 2020 @06:53PM (#22991029)
>I don't get that at all, NixOS is a fundamentally improved way of managing your operating system.

In what way? Why are functionally-declarative system configs good? What does the increased workload gain me over my usual list-of-packages-to-apt-get?

Re:My NixOS Desktop Flow by vertex-four on Monday April 27, 2020 @03:54AM (#22993824)
I can actually remember what's installed on my system and how it's configured in a centralised place, even when I don't touch the configuration for a few months. It's actually better for "boring" systems that I don't touch the config of much - "why is that set up like that" is a question I can easily answer. Additionally, when I do want to play with new stuff, the various tools I'm given usually let me do that and go back to a clean slate if I'm not interested, without having to deal with heavyweight containers/VMs/etc.
Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @10:35AM (#22996194)
Yep, switching between KDE and GNOME or xorg and Wayland is so much easier than on other distributions.
Re:My NixOS Desktop Flow by solarkraft on Monday April 27, 2020 @05:25AM (#22994272)
All your state is in one place - packages and configuration. On a typical system there is tons of hidden state - some little option you had to change but didn't document, some package you forgot you installed ... that's not that easy to reproduce or change-track without backing up the whole system. You could use Ansible to do it, but that's another can of overhead.

... at least that's my experience.

Re:My NixOS Desktop Flow by roguas on Tuesday April 28, 2020 @09:10AM (#23006581)
> The only real reason not to use it

I am sorry but that is fanfiction that nix people want to believe. There are numerous reasons not to use nix, a few: - Incredibly smaller community - Incredibly smaller support from community and enterprise - Yet another programming language - that is difficult to grok

Those alone can kill any technically sound project, but there are lots of others. Such as slow installs, storage requirements etc.

Re:My NixOS Desktop Flow by tinco on Tuesday April 28, 2020 @10:28AM (#23007298)
I agree with the programming language, it seems to be more difficult than necessary, I don't get why the syntax had to be so outlandish.
Re:My NixOS Desktop Flow by elbear on Sunday April 26, 2020 @03:09PM (#22989346)
The main value proposition is this: With a single file, you describe the desired state of your system. That file is configuration.nix.

You put in there what packages you want installed, what users, what SSH keys, what services systemd manages.

Then, you run `nixos-rebuild` and then you switch your system to that configuration. The old state of your system stays around until you run garbage collect. So you can rollback to it, if you want.

Re:My NixOS Desktop Flow by abrouwers on Monday April 27, 2020 @09:38AM (#22995680)
>Then, you run `nixos-rebuild` and then you switch your system to that configuration. The old state of your system stays around until you run garbage collect. So you can rollback to it, if you want.

How often are people doing this, though? I get a machine set up pretty quickly (install list of packages, systemctl enable <foo bar baz>, reboot), and I'm set for several years.

Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @10:41AM (#22996248)
It is as often as you change things. Also configuration.nix isn't just a list of packages to install and services to enable, it's also a configuration of various system components.

I'm quite new to NixOS and recently tried home manager, which basically manages your home, primarily all dot files, but goes as far as preinstalling favorite extensions on Firefox for example.

Re:My NixOS Desktop Flow by na85 on Sunday April 26, 2020 @06:55PM (#22991043)
>With a single file, you describe the desired state of your system.

I can already do that with Kickstart for rpm distros, though.

Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @10:49AM (#22996352)
Kickstart is just RedHat equivalent of unattended install. NixOS goes way beyond that it also takes over CMS (ansible, saltstack, etc). You can for example modify one of packages (use different configuration option, or maybe sorry patch) and if binary version is not available in the cache it will compile new one. With home manager, it can also take care of your home directory, all configurations so called dot files, down to what extensions you want to have installed on Firefox.
Re:My NixOS Desktop Flow by solarkraft on Monday April 27, 2020 @05:31AM (#22994305)
I didn't know about this, thanks. But can you use it to change an existing system?
Re:My NixOS Desktop Flow by strunz on Sunday April 26, 2020 @04:20PM (#22989880)
Honestly, I find it infinitely easier to just do everything in in docker containers. Then the OS doesn't matter except for installing docker, and running docker-compose up.
Re:My NixOS Desktop Flow by tinco on Sunday April 26, 2020 @06:33PM (#22990888)
Docker is for containing the environment of your apps. NixOS is for configuring your operating system. I use NixOS to define which Docker apps run on my machine, as well as monitoring and administration tools, firewall setup, that sort of thing.

If all you do is apt-get install docker, that doesn't feel like a very complete set up to me.

Re:My NixOS Desktop Flow by strunz on Sunday April 26, 2020 @11:18PM (#22992581)
I'm saying if you run all your apps in containers, there really isn't much left to configure on the OS. Using Ansible for those few things seems like an easier solution.
Re:My NixOS Desktop Flow by tinco on Monday April 27, 2020 @04:02AM (#22993876)
But Ansible is an incomplete and extra part of software just to make your operating system behave like you want it to. Why not just pick an operating system that behaves like you want it to from the ground up?
Re:My NixOS Desktop Flow by agumonkey on Sunday April 26, 2020 @05:25PM (#22990392)
docker is like nixos for 2yo
Re:My NixOS Desktop Flow by peanut_is_yum on Sunday April 26, 2020 @11:30PM (#22992631)
If that were all there were to it, I would certainly prefer docker over nixos
Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @11:16AM (#22996623)
Yeah, that argument is weird. If we are taking about state the difference between those two is that docker is just storing a snapshot of a state (BTW Dockerfile by itself is not reproducible and is comparable to a bash script) while Nix is storing information how to get to a given state. That makes it far more versatile. It is what Docker promised to be, but ended up being an overglorified zip file. Depending on your needs, that might be all you actually want. If you want to make small adjustments to existing state (let say applying a patch, in docker you pretty much have to rebuild from scratch and with non-deterministic Dockerfile you might change more than that), or maybe compose something new from existing components, Nix gives you far greater control to do that.
Re:My NixOS Desktop Flow by agumonkey on Monday April 27, 2020 @01:22PM (#22997832)
Honestly what I dislike about docker is the very effectful config file.
Re:My NixOS Desktop Flow by takeda on Tuesday April 28, 2020 @01:35AM (#23003756)
Yes, the Dockerfile has serious shortcomings and makes it totally miss the mark on what it was promising, but based on some comments about how nix is hard, it probably helped with adaptation.

Seems like it comes much easier to most people to issue series of (often nondeterministic) commands that mutate state rather than learning a new language that allows describing dependencies and have it figure out steps needed.

Re:My NixOS Desktop Flow by agumonkey on Tuesday April 28, 2020 @04:29AM (#23004911)
Yes obviously docker is primitive and people prefered that, just like they prefered php4/wordpress, it was the right match for a nascent space/market.

The issue to me is that it's mostly a regression and that when showed nix/guix people would squint saying it's horrible.. when in fact docker way is horrible, it's just nicer to them.

Alas, such is society.

Re:My NixOS Desktop Flow by TheYumasi on Sunday April 26, 2020 @10:20AM (#22987332)
It’s just a matter of doing a good old `man 5 configuration.nix`.
Re:My NixOS Desktop Flow by kylek on Sunday April 26, 2020 @05:30PM (#22990435)
>> If I want to know how I configured my nas three years ago, all I have to do is read the nix file I checked onto github. Thats powerful.

Have you had to deal with breaking changes in the config language? (Does this ever happen? Are there versions/specs of the language that can be pinned?)

Re:My NixOS Desktop Flow by tinco on Sunday April 26, 2020 @06:30PM (#22990859)
I don't remember any changes in the language, but I did encounter packages that had their configuration renamed or changed in a way that broke my config.

Basically you pin to a version of NixOS, and opting into the next version is fully optional. So if you change your NixOS version, and you run nixos-rebuild, and stuff doesn't work, then you can just undo your change. NixOS even keeps a backup of itself ready, so say for some reason you update but your new version doesn't boot, you can simply boot into your previous working version.

Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @02:44PM (#22998651)
So nix has ability to pin to specific version and you can get exact same system.

With an OS there is a problem, because most of the time you don't want to do that, you want to get security patches and erratas. For this purpose channels are used. They promise to not break anything within release channels. This is very similar to how other OSes, you need to trust them to not break thighs. There is also option to subscribe to a rolling release, so similarly to other OSes there are more opportunities for things to break (living on the edge and all), but the stuff below still applies.

On top of that there is also variable in your configuration.nix it is set to the version of NixOS that you first installed. That version is version of the configuration file and supposed to guarantee compatibility. The compatibility they mentions are things like for example default version of PostgreSQL that they use if you choose default one you don't want on system upgrade to automatically force you to upgrade your database. Another obvious change is change of defaults, perhaps they decided that service that was previously enabled by default should be now disabled etc.

You can bump the version in that file, but then you have to go through changelog and adapt your config to these changes.

I am relatively new NixOS user, but just did uphrade from 19.09 to 20.03 and it went smooth as if it was just update within the same release.

Re:My NixOS Desktop Flow by qqssccfftt on Sunday April 26, 2020 @09:32AM (#22987011)
Why would you want to know how you configured your NAS three years ago?
Re:My NixOS Desktop Flow by tinco on Sunday April 26, 2020 @03:07PM (#22989337)
Ran out of disk space, want to run another service, want to check if there's any software updates.. I don't know, in my case I had it in a moving box for 1.5 years and I was pleasantly surprised it even booted and immediately started serving up stuff to my TV.
Re:My NixOS Desktop Flow by eximius on Sunday April 26, 2020 @12:24PM (#22988212)
If you were happy with it and need to do it again? If there were small gotchas you aren't eager to rediscover?
Re:My NixOS Desktop Flow by m463 on Sunday April 26, 2020 @03:45PM (#22989621)
that actually sounds WONDERFUL.

I had a machine that I let run with an old (private) certificate for years because I didn't remember the how and the what of renewing that specific certificate.

I had another machine that had a hardware failure, and I spent an enormous amount of time recreating it.

Re:My NixOS Desktop Flow by takeda on Monday April 27, 2020 @02:45PM (#22998671)
I have been running a personal server (FreeBSD) for close to 20 years now, and upgrading in place since 4.6. And once some hardware components fails (especially disk) I spend extra time figuring once again how I did it then. Having everything described in a configuration would take less time to do such fixes.