Unstructured tech for the curious

NixOS for the confused – Part 0.5

Click here for Part 0.

Okay, what are we even trying to do here? Well, reader, we are trying to go from zero to non-zero proficiency. There’s a whole lot of clever peeps out there who can literally perform arcane incantations with NixOS and summon ancient spirits to do their profane bidding. I’m not one of those. The point here is to get to a point where we have a functional environment to work with, without having to risk invoking the wrong otherworldly entity. We’ll be wrangling Flakes to get there. What are Flakes, you ask? Who gives a shit. Act like a true pro and just copy and paste stuff from the internet.

We’ll write our flake.nix , write some modules for our stuff, dump all that to a git repo over at Codeberg because, honestly, fuck GitHub. You can GitHub, though. Lots of things we’ll be doing are coming directly from there. I won’t be mad. Any git thingy will do (Coming soon! Hosting your own git thingy with Gitea!)

Where were we? Oh, yeah. So, a good place to start flakin’ and Nixin’ is to steal someone else’s work. I stumbled upon this repo that just happens to be maintained by a fellow compatriot. Go take a gander, read the README.md. Hopefully you won’t understand fuck all: that’s what we want.

Right! Here’s what we need to do:

  1. Create a git repo somewhere.

  2. In your NixOS, mkdir flakies(or whatever the hell you want to call the directory holding your flakes)

  3. Make that repo the remote (for example, git remote add origin https://codeberg.org/yourname/flakies.git)

  4. Wait for the next part!

Listen, you ain’t gotta use git for this. You can very well write your flake.nix directly on your machine. You’ll get shit done, but it won’t be as awesome. At the end of the day, all we need is a directory with a flake.nix file in it.

Don’t have git installed on your brand new NixOS? Jesus Christ.

You can get it system-wide by adding something like this to your /etc/nixos/configuration.nix:

environment.systemPackages = with pkgs; [
        gitMinimal  ];

Or, you can be smart, nix-shell git, and let the flakes take care of it:

$ nix-shell -p gitMinimal

Oops! Forgot your text editor? Me, too! Again, two options:

environment.systemPackages = with pkgs; [
        neovim  ];

Or... nix-shell -p neovim

Obviously, if you forgot both:

environment.systemPackages = with pkgs; [
        gitMinimal
        neovim
        ];

Or... nix-shell -p gitMinimal neovim

If you don't like vi/vim/Neovim, I can't help you there bud. Ok, ok. Just replace neovim with whatever editor you fancy.

As long as you have a way to write your flake.nix or pull it from a git repo, you're good.

Changed the /etc/nixos/configuration.nix? Don't forget to rebuild your system with sudo nixos-rebuild switch

Stick around for part 0.7, Cola Gang! With any luck, we'll get from ugly terminal to this: