Stream: nix

Topic: Dynamic NixOS configuration, using flakes


view this post on Zulip Pratham Patel (Apr 28 2024 at 17:19):

Hello everyone, for a long time, I had been deploying NixOS and devshells using the traditional, non-flake approach. As I had some time a few months ago, I tried flakes and understood why they're so useful.

I had written an "installer script" in Bash that would, depending on hardware detected, add lines to a host-specific-configuration.nix file which, as it's name suggested, was host-specific and not included in the git tree. This always rubbed me the wrong way as it it was a very hacky solution and also something that couldn't be in the git tree. After getting familiar with Nix, I could easily get rid of this monster from the installer script, leaving it only essential duties like partitioning, formatting, mounting and calling nixos-install. Everything else was moved from Bash statements to Nix expressions.

Though I haven't yet written a blog about this, you can checkout my configuration repository. It includes the following outputs:

This post was made mostly to help anyone else who stumbles on the same problems I did and hopefully not waste a lot of time because of the widely known documentation issue.

https://github.com/thefossguy/prathams-nixos
https://gitlab.com/thefossguy/prathams-nixos (same thing, mirrored on GitLab)

view this post on Zulip Pratham Patel (Apr 28 2024 at 17:23):

The obvious next step is to use disko but I need some more experimentation with it in a feature branch before mass deployment.

view this post on Zulip Srid (Apr 29 2024 at 00:27):

Pratham Patel said:

The obvious next step is to use disko but I need some more experimentation with it in a feature branch before mass deployment.

Have you looked into disko-install?

cf. https://nixos.asia/en/nixos-install-oneclick

view this post on Zulip Pratham Patel (Apr 29 2024 at 02:37):

I do intend to, just need some more time to tinker with. Probably this weekend :)

view this post on Zulip Pratham Patel (Apr 29 2024 at 11:17):

Update: Added a GitHub workflow to build x86 and arm64 build nightly. workflow file
The only thing that I haven't gotten around (other than the RISC-V issue for my SBCs) is targeting x86 and arm64 Darwin. At the moment, my company laptop is an Intel MBP and will tend to arm64 once I own one. :)

view this post on Zulip Pratham Patel (May 01 2024 at 18:15):

Another update: Added a justfile to so that I don't need to remember long invocations like nixosConfigurations.bla.bla.bla :D

view this post on Zulip Pratham Patel (May 01 2024 at 18:16):

Hmm, maybe I should write a blog about this, it was quite an adventure lol

view this post on Zulip Srid (May 01 2024 at 23:39):

Pratham Patel said:

Hmm, maybe I should write a blog about this, it was quite an adventure lol

Yes.

(Also link back to this zulip topic as reference :-) )

view this post on Zulip Pratham Patel (May 02 2024 at 03:26):

Absolutely!

view this post on Zulip Pratham Patel (May 02 2024 at 15:54):

Part 1 (rationale behind it) is live!
https://blog.thefossguy.com/posts/nixos-migration-with-flakes-01.md

view this post on Zulip Pratham Patel (May 02 2024 at 16:05):

I plan to add some follow-ups for

view this post on Zulip Shivaraj B H (May 02 2024 at 18:00):

That doesn’t mean that you cannot lean from it. ;)

A typo?

view this post on Zulip Pratham Patel (May 03 2024 at 02:32):

Shivaraj B H said:

That doesn’t mean that you cannot lean from it. ;)

A typo?

hah yeah, fixed it just now; thanks for pointing it out!


Last updated: Nov 15 2024 at 12:33 UTC