NixOS configuration for Hakula's machines (flake-based).
| Host | System | Type |
|---|---|---|
us-1 |
x86_64-linux | NixOS server |
us-2 |
x86_64-linux | NixOS server |
us-3 |
x86_64-linux | NixOS server |
us-4 |
x86_64-linux | NixOS server |
sg-1 |
x86_64-linux | NixOS server |
hakula-macbook |
aarch64-darwin | macOS (nix-darwin) |
hakula-linux |
x86_64-linux | Generic Linux (Home Manager) |
hakula-devvm |
x86_64-linux | Docker Image (NixOS) |
Install NixOS with nixos-anywhere:
nix run github:nix-community/nixos-anywhere -- --flake '.#us-1' root@<host>On a single server (run on the server itself):
nh os switch .After setting up the alias:
nixswDeploy to all servers in parallel from the workstation using Colmena:
colmena applyDeploy to a single server:
colmena apply --on us-4Deploy by provider tag:
colmena apply --on @cloudconeBuild without activating:
colmena buildEach server builds its own configuration locally (buildOnTarget = true), so no cross-compilation is needed. Server inventory is defined in lib/servers.nix.
Install Nix with Determinate Nix Installer:
curl -fsSL https://install.determinate.systems/nix | sh -s -- installBootstrap with nix-darwin (first switch):
sudo nix run nix-darwin/nix-darwin-25.11#darwin-rebuild -- switch --flake '.#hakula-macbook'nh darwin switch .After setting up the alias:
nixswInstall Nix with Determinate Nix Installer:
curl -fsSL https://install.determinate.systems/nix | sh -s -- installFirst-time apply (before nh is available):
nix run home-manager -- switch --flake '.#hakula-linux'After the first apply:
nh home switch . -c hakula-linuxOr with the alias:
nixswFor environments where Nix cannot be installed natively, NixOS Docker images can be built using dockerTools.buildLayeredImageWithNixDb. This creates multi-layer images (up to 100 layers) for efficient incremental updates via layer caching, and includes the Nix database for Home Manager activation.
nix build '.#packages.x86_64-linux.hakula-devvm-docker'# Load the layered image into Docker
docker load < result
# Start the container
docker compose -f hosts/hakula-devvm/docker-compose.yml up -dConnect via VS Code / Cursor using the Dev Containers: Attach to Running Container command.
nix flake updateThis repository uses nixfmt-rfc-style. Format all Nix files with:
git ls-files '*.nix' -z | xargs -0 nix fmtThis repository uses a Nix-native pre-commit setup (via git-hooks.nix).
Enable hooks locally (installs into .git/hooks):
nix develop -c zshCI-style check (does not modify your working tree; fails if formatting would change files):
nix flake checkGitHub Actions automatically validates the configuration on every push and pull request:
- Flake Check: Validates flake structure using
nix flake check --all-systems - Build NixOS: Tests building all 5 server configurations (
us-1,us-2,us-3,us-4,sg-1) on x86_64-linux - Build macOS: Tests building the
hakula-macbookconfiguration on aarch64-darwin - Build Generic Linux: Tests building the
hakula-linuxHome Manager configuration on x86_64-linux - Build Docker: Tests building the
hakula-devvm-dockerDocker image on x86_64-linux
Secrets are managed with agenix. Edit secrets with:
cd secrets
agenix -e <secret-name>.age -i ~/.ssh/<private-key>