mirror of
https://github.com/srid/nixos-config.git
synced 2026-05-05 05:16:50 +08:00
KISS NixOS configuration based on Flakes & flake-parts (supports macOS too)
* Enable incus on pureintent, rename lxd.nix, drop unused flake-parts - Add incus module import to pureintent and bind the UI to its Tailscale IP (no firewall change needed since tailscale0 is trusted). - Rename modules/nixos/linux/lxd.nix -> incus.nix since the module configures virtualisation.incus, and enable the bundled web UI. - Drop the unused modules/flake-parts/incus-image helper; the `images:nixos/*` community images cover container/VM launches. * Move incus module into a directory with a README The troubleshooting notes used to live as comments in the module; they belong in docs alongside a quick-start on launching containers/VMs and configuring the UI listener. * Expand incus README with VM gotchas Document the sharp edges hit while bringing up a NixOS VM for the first time: secureboot, memory/cpu/disk limits (with the error signatures that point at each), configuring the guest (flakes, firewall), and a three-step guide to exposing a service from inside. |
||
|---|---|---|
| .vscode | ||
| AI | ||
| configurations | ||
| docs | ||
| doom.d | ||
| modules | ||
| overlays | ||
| packages | ||
| secrets | ||
| webapps | ||
| .envrc | ||
| .gitattributes | ||
| .gitignore | ||
| .gitmodules | ||
| CLAUDE.md | ||
| config.nix | ||
| flake.lock | ||
| flake.nix | ||
| justfile | ||
| README.md | ||
| vira.hs | ||
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:
- Edit
config.nixin the repository root to set your primary user information (username,fullname,email,sshKey). - Replace the SSH keys in
secrets/secrets.nixwith your own, or delete the file if you do not useagenix. - 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
- Install NixOS
- Hetzner dedicated from Linux Rescue system: https://github.com/numtide/nixos-anywhere (see blog post; example PR: https://github.com/srid/nixos-config/pull/35 where I had to configure networking manually)
- Copy from existing configuration (eg: ax41.nix)
- Make networking configuration changes.
- Run nixos-anywhere from a Linux system, targetting
root@<ip> - Wait for reboot;
ssh srid@<ip>; profit!
- Digital Ocean
- Legacy/manual approach: nixos-infect
- Modern/automate approach: Custom image + colerama; cf. Zulip and example
- X1 Carbon: https://srid.ca/x1c7-install
- Windows (via WSL): https://github.com/nix-community/NixOS-WSL
- Hetzner dedicated from Linux Rescue system: https://github.com/numtide/nixos-anywhere (see blog post; example PR: https://github.com/srid/nixos-config/pull/35 where I had to configure networking manually)
- Clone this repo anywhere
- Run
nix run. That's it. Re-open your terminal.
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.nixfor 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
- You may also update only primary inputs:
- 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 lintin 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
-
You might have to
rm -rf /etc/nix/nix.conf, so our flake.nix can do its thing. ↩︎