KISS NixOS configuration based on Flakes & flake-parts (supports macOS too)
Find a file
Sridhar Ratnakumar 293e53071c incus-pet: hello-web example flake — minimal contract demonstration
Self-contained reference under
modules/nixos/linux/incus/incus-pet/example/hello-web/ that satisfies
the incus-pet contract in the smallest possible form:

  - packages.<sys>.default    a darkhttpd wrapper that serves a
                              one-page index.html, reading HOST/PORT
                              from the environment
  - nixosModules.default      services.hello-web.{enable, package,
                              host, port} + a DynamicUser=true systemd
                              unit
  - nixosModules.incus        the deploy contract: services.hello-web
                              bound to 8080, hostname "hello-web"

Useful as a copy-paste template for new apps. Less moving parts than
the anywhen reference (no bun, no SQLite, no state dir, no e2e tests
to keep green) — just three flake outputs and a static HTML response.

Live-deployed end-to-end on pureintent during this PR's bring-up:

  $ incus-pet deploy path:./.../example/hello-web hello-web \
      --port 8081 --listen 100.122.32.106
  $ curl http://100.122.32.106:8081/
  <!doctype html>
  <h1>Hello from incus-pet</h1>

Idempotent re-deploy verified (no flags needed — host-port + listen
read back from container metadata; container name auto-detected from
incus.container.hostname).
2026-05-23 14:47:54 -04:00
.vscode vscode: nushell 2025-07-22 10:27:01 -04:00
AI Upstreamed 2026-04-09 17:49:46 -04:00
configurations incus-pet: per-app incus container CLI ("pet PaaS"); drop webapps/ 2026-05-23 13:53:55 -04:00
docs i 2026-05-23 10:27:31 -04:00
doom.d doom: disable 2024-11-18 12:04:59 -05:00
modules incus-pet: hello-web example flake — minimal contract demonstration 2026-05-23 14:47:54 -04:00
overlays opencode: use upstream juspay/oc home module (#105) 2026-03-12 18:18:51 -04:00
packages twitter-convert, restore minimally 2026-05-20 08:06:44 -04:00
secrets Update juspay llm key 2026-03-02 10:26:58 -05:00
.envrc envrc: Fix devshell path 2025-06-25 18:06:30 +10:00
.gitattributes chore: Redundant entry 2024-06-21 19:46:58 -04:00
.gitignore Ignore .codex 2026-04-23 12:32:31 -04:00
.gitmodules Remove submodules entirely 2026-03-14 09:22:23 -04:00
CLAUDE.md Add hackage-publish.nix, to be tested 2025-08-28 05:31:50 +05:30
config.nix Remove unused 2024-09-28 22:51:12 -04:00
flake.lock incus-pet: per-app incus container CLI ("pet PaaS"); drop webapps/ 2026-05-23 13:53:55 -04:00
flake.nix incus-pet: per-app incus container CLI ("pet PaaS"); drop webapps/ 2026-05-23 13:53:55 -04:00
justfile fuck pc for now 2026-03-14 09:16:34 -04:00
README.md Remove submodules entirely 2026-03-14 09:22:23 -04:00
vira.hs ci: Add vira 2025-10-21 08:31:21 -04:00

AGPL

This is my Nix / NixOS configuration for all of my systems. See nixos-unified—specifically nixos-unified-template—if you wish to create your own configuration from scratch.

Setup

If you are using this repository as a starting template for your own configuration, perform these initial steps:

  1. Edit config.nix in the repository root to set your primary user information (username, fullname, email, sshKey).
  2. Replace the SSH keys in secrets/secrets.nix with your own, or delete the file if you do not use agenix.
  3. Delete any files in configurations/ that you do not need, and create/rename files to match your hostnames.

After preparing your template, to install on a new machine running:

NixOS Linux

Tip

For a general tutorial, see https://nixos.asia/en/nixos-install-flake

macOS

  • Install Nix
  • Clone this repo anywhere
  • Run nix run.1 That's it. Re-open your terminal.

Architecture

Start from flake.nix (see Flakes). flake-parts is used as the module system.

Directory layout

Tip

See flake-module.nix for autowiring of flake outputs based on this directory structure.

Path Corresponding flake output
./configurations/{nixos,darwin,home}/foo.nix {nixos,darwin,home}Configurations.foo
./mdules/{nixos,darwin,home,flake-parts}/foo.nix {nixos,darwin,home,flake}Modules.foo
./overlays/foo.nix overlays.foo
./packages N/A (Nix packages)
./secrets N/A (agenix data)

Tips

  • To update NixOS (and other inputs) run nix flake update
    • You may also update only primary inputs:
      # nix run .#update
      
  • To free up disk space,
    sudo nix-env -p /nix/var/nix/profiles/system --delete-generations +2
    sudo nixos-rebuild boot
    
  • To autoformat the project tree using nixpkgs-fmt, run just lint in Nix devShell.
  • To build all flake outputs (locally or in CI), run nix run nixpkgs#omnix ci
  • For secrets management, I use agenix, because it works with SSH keys, and functions well on macOS and NixOS.

Discussion

https://github.com/srid/nixos-config/discussions


  1. You might have to rm -rf /etc/nix/nix.conf, so our flake.nix can do its thing. ↩︎