aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md56
1 files changed, 56 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..881b2e9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,56 @@
1# nix-config
2
3A single Nix flake for provisioning both NixOS hosts and non-NixOS systems (any Linux now; macOS via nix-darwin later) from one shared set of modules.
4
5## Layout
6
7- `flake.nix` — inputs (`nixpkgs`, `home-manager`) and outputs (`nixosConfigurations`, `homeConfigurations`, `formatter`, `devShells`)
8- `lib/` — `mkNixos` and `mkHome` helper functions that build `nixosConfigurations` / `homeConfigurations` entries
9- `modules/nixos/common.nix` — shared NixOS-only system settings applied to every NixOS host
10- `modules/home/` — the shared, cross-platform home-manager profile (shell, git, editor, CLI tools). The same modules are consumed whether activated via a NixOS host's home-manager module or standalone `home-manager switch`
11- `users/tom.nix` — identity/profile file consumed by both `mkNixos` and `mkHome`
12- `hosts/template/` — a copy-source-only NixOS host skeleton; **never** wired into `flake.nix` outputs directly. Copy it to `hosts/<real-hostname>/` when provisioning a real machine
13
14## Installing NixOS on a new machine
15
16This flake does not partition disks for you — do that first, with the standard NixOS installer or manually.
17
181. Partition and format disks; mount the target filesystems under `/mnt` (including `/mnt/boot` for the ESP if UEFI).
192. Generate hardware config: `nixos-generate-config --root /mnt`. Keep the generated `hardware-configuration.nix`; discard its `configuration.nix`.
203. Get this repo onto the installer: `nix-shell -p git && git clone <your-remote-url> ~/nix-config` (requires the repo already pushed to a remote — see Follow-ups below).
214. Copy the template into a real host: `cp -r ~/nix-config/hosts/template ~/nix-config/hosts/<real-hostname>`.
225. Edit `hosts/<real-hostname>/configuration.nix`: set `networking.hostName`, pick the correct boot loader stanza, set `system.stateVersion` to the installer's NixOS release.
236. Replace the stub hardware config: `cp /mnt/etc/nixos/hardware-configuration.nix ~/nix-config/hosts/<real-hostname>/hardware-configuration.nix`.
247. Add the host to `flake.nix`:
25 ```nix
26 nixosConfigurations.<real-hostname> = lib.mkNixos {
27 hostname = "<real-hostname>";
28 system = "x86_64-linux";
29 };
30 ```
318. `cd ~/nix-config && git add -A` (flakes only see git-tracked files).
329. If needed: `export NIX_CONFIG="experimental-features = nix-command flakes"`.
3310. `nixos-install --root /mnt --flake ~/nix-config#<real-hostname>`.
3411. Reboot and remove the install media.
3512. Afterwards, clone the flake to a stable path (e.g. `/etc/nix-config`) so future updates are just `sudo nixos-rebuild switch --flake /etc/nix-config#<real-hostname>`.
36
37## Installing on a non-NixOS system (any Linux, or macOS once supported)
38
391. Install Nix. Recommended: the [Determinate Systems installer](https://github.com/DeterminateSystems/nix-installer) (flakes enabled by default). The official installer also works, but you'll need to add `experimental-features = nix-command flakes` to `nix.conf` yourself.
402. `git clone <your-remote-url> ~/nix-config`.
413. First run: `nix run home-manager/master -- switch --flake ~/nix-config#tom@linux`. After that, `home-manager switch --flake ~/nix-config#tom@linux` works directly.
42
43This only touches your home directory — no sudo required.
44
45## Development
46
47- `nix fmt` — format all `.nix` files with `nixfmt-rfc-style`.
48- `nix develop` — a shell with `statix` and `deadnix` for linting.
49- `nix flake check` — validates `homeConfigurations."tom@linux"` and the other outputs defined here (there are no `nixosConfigurations` yet — see Follow-ups).
50
51## Follow-ups (not covered by this change)
52
53- Push this repo to a remote — required before `nixos-install` can `git clone` it during a real install.
54- Add a real NixOS host once hardware has been partitioned (see workflow above).
55- Add nix-darwin once a real Mac host is being configured.
56- Add secrets management (e.g. sops-nix) — none is set up yet.