This repository contains the 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.
To use this repository as base configuration for your new machine running:
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: #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: #35 where I had to configure networking manually)
- Clone this repo anywhere
- Rename
./configurations/nixos/??.nixto match your current system hostname - Edit
config.nixto set your primary user information - Run
nix run. That's it. Re-open your terminal.
- Install Nix
- Clone this repo anywhere
- Rename
./configurations/darwin/??.nixto match your current system hostname - Edit
config.nixto set your primary user information - Run
nix run.1 That's it. Re-open your terminal.
Start from flake.nix (see Flakes). flake-parts is used as the module system.
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) |
- 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.
If you wish to discuss this config, join the NixOS Asia community.
Footnotes
-
You might have to
rm -rf /etc/nix/nix.conf, so our flake.nix can do its thing. ↩