Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 2.78 KB

README.md

File metadata and controls

83 lines (60 loc) · 2.78 KB

Nix configuration

This repo contains the Nix configuration for the various machines I use. I'm new to Nix/NixOS and its ecosystem so a lot of the code you'll see here might not be its best.

Flakes

When I first started using NixOS I used the standard configuration at /etc/nixos/configuration.nix. This worked well for me while I was managing only one machine. As I installed Nix on more and more machines I wanted a more elegant way to manage shared configuration. So I arrived at Flakes.

This repo is a mix of Flakes and non-Flakes configuration, but most of the hosts I use daily have been converted to Flakes.

For an intro to flakes I recommend the original Tweag Flakes intro on using Nix Flakes to manage a NixOS system.

For other example configs on Github, have a look at this list I made nix-configs.

Btrfs & backups

In before people get triggered, I use Btrfs on all of my machines (including a raspi's SDCard). It's great 👌

To prevent sadness in case something goes wrong in the future I back up daily to Backblaze. See my custom restic module for that

Hosts

The ./hosts directory contains the configuration files for my machines.

  • 🖥️ vader - Main NixOS install
  • 💻 mackey - A macbook running [nix-darwin] & home-manager
  • raspi hk47 - A Raspberry Pi 4B in my closet. Mainly runs the Unifi controller
  • 🖥️ nix-1 - A Hetzner VPS. Runs k3s

System management

Most of the time it boils down to this:

  • make a change in this repo (e.g. add a new package, add a new env var)

  • execute

    $ sudo nixos-rebuild switch --flake /path/to/git/repo

    alternatively, you can push the change to Github and run

    $ sudo nixos-rebuild switch --flake github:alexghr/nix

nixos-rebuild will default to apply the nixosConfiguration named after the current system's hostname, so the above command is equivalent to

$ sudo nixos-rebuild switch --flake github:alexghr/nix#$(hostname)

Todo

  • remove stale hosts
  • migrate other machines to Flakes
  • setup CI (update flakes, push derivations to cachix, etc)