Skip to content

hakula139/nixos-config

Repository files navigation

NixOS Configuration

CI Ask DeepWiki

NixOS configuration for Hakula's machines (flake-based).

Hosts

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)

NixOS

Prerequisites (NixOS)

Install NixOS with nixos-anywhere:

nix run github:nix-community/nixos-anywhere -- --flake '.#us-1' root@<host>

Apply NixOS Configuration

On a single server (run on the server itself):

nh os switch .

After setting up the alias:

nixsw

Multi-Server Deployment

Deploy to all servers in parallel from the workstation using Colmena:

colmena apply

Deploy to a single server:

colmena apply --on us-4

Deploy by provider tag:

colmena apply --on @cloudcone

Build without activating:

colmena build

Each server builds its own configuration locally (buildOnTarget = true), so no cross-compilation is needed. Server inventory is defined in lib/servers.nix.

macOS

Prerequisites (macOS)

Install Nix with Determinate Nix Installer:

curl -fsSL https://install.determinate.systems/nix | sh -s -- install

Bootstrap with nix-darwin (first switch):

sudo nix run nix-darwin/nix-darwin-25.11#darwin-rebuild -- switch --flake '.#hakula-macbook'

Apply Darwin Configuration

nh darwin switch .

After setting up the alias:

nixsw

Home Manager (standalone, for non-NixOS Linux)

Prerequisites (Nix)

Install Nix with Determinate Nix Installer:

curl -fsSL https://install.determinate.systems/nix | sh -s -- install

Apply Home Manager Configuration

First-time apply (before nh is available):

nix run home-manager -- switch --flake '.#hakula-linux'

After the first apply:

nh home switch . -c hakula-linux

Or with the alias:

nixsw

Docker Images (for air-gapped deployment)

For 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.

Build Docker Image

nix build '.#packages.x86_64-linux.hakula-devvm-docker'

Deploy Docker Image

# Load the layered image into Docker
docker load < result

# Start the container
docker compose -f hosts/hakula-devvm/docker-compose.yml up -d

Connect via VS Code / Cursor using the Dev Containers: Attach to Running Container command.

Update

nix flake update

Formatting

This repository uses nixfmt-rfc-style. Format all Nix files with:

git ls-files '*.nix' -z | xargs -0 nix fmt

Pre-commit

This repository uses a Nix-native pre-commit setup (via git-hooks.nix).

Enable hooks locally (installs into .git/hooks):

nix develop -c zsh

CI-style check (does not modify your working tree; fails if formatting would change files):

nix flake check

Continuous Integration

GitHub 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-macbook configuration on aarch64-darwin
  • Build Generic Linux: Tests building the hakula-linux Home Manager configuration on x86_64-linux
  • Build Docker: Tests building the hakula-devvm-docker Docker image on x86_64-linux

Secrets

Secrets are managed with agenix. Edit secrets with:

cd secrets
agenix -e <secret-name>.age -i ~/.ssh/<private-key>

About

My NixOS configuration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors