mirror of
https://github.com/srid/nixos-config.git
synced 2026-07-16 22:01:33 +08:00
KISS NixOS configuration based on Flakes & flake-parts (supports macOS too)
* ralph(eval): baseline + benchmark harness pureintent cpuTime 23.17s, zest cpuTime 14.93s (median of 5). Methodology: NIX_SHOW_STATS cpuTime, eval-cache off, warm fetcher cache. * ralph(eval) cycle 1: disable NixOS options manual on pureintent documentation.nixos.enable = false. Generating the NixOS manual evaluates every option's doc string. nrThunks 20,400,114 -> 19,201,996 (-5.9%), nrFunctionCalls -6.2%, nrPrimOpCalls -7.5%. Package man pages unaffected. Metric pivoted to deterministic NIX_SHOW_STATS counters: cpuTime is unusable on this thermally-throttling machine (same eval = 11s..21s). * ralph(eval): switch home target zest -> sincereintent (per request) sincereintent home config baseline: nrThunks 5,323,428 / calls 3,227,404 / primops 1,565,120 (deterministic). * ralph(eval) cycle 2: disable home-manager options manpage manual.manpages.enable = false in shared modules/home/default.nix. HM builds home-configuration.nix(5) by default, evaluating every HM option's doc string. sincereintent nrThunks 5,323,428 -> 3,551,679 (-33.3%), calls -35%, primops -39%. * ralph(eval): record cycle-2 pureintent gain (shared HM module) pureintent nrThunks 19,201,996 -> 17,431,437 (-9.2%); cycle-2's manual.manpages.enable=false also feeds pureintent's embedded home-manager via modules/nixos/default.nix. Total pureintent -14.6% from baseline. * ralph(eval) cycle 3: profiling + dead-ends (no behaviour-preserving win) Confirmed: nixpkgs single-instantiation (no 2x trap), unused inputs are lazy (no counter impact), escapeShellArg hotspot is HM file-linking + /etc (not patchable here). Remaining eval cost is feature-bound (embedded HM, vira/kolu, google-cloud-sdk/pandoc/omnix). * ralph(eval) cycle 4: drop heavy home.packages (yt-dlp/lima/omnix/pandoc/gcloud) User-approved behaviour change. Removed from shared modules/home/cli/terminal.nix (kept hledger). pureintent nrThunks 17,431,437 -> 16,989,720 (-2.5%), sincereintent 3,551,679 -> 2,757,201 (-22.4%). Totals from baseline: pureintent -16.7%, sincereintent -48.2%. * ralph(eval): finalize report (final measurement, key findings, cost breakdown) |
||
|---|---|---|
| .vscode | ||
| AI | ||
| configurations | ||
| docs | ||
| doom.d | ||
| modules | ||
| overlays | ||
| packages | ||
| secrets | ||
| .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. ↩︎