diff options
| author | 2026-09-17 11:05:45 +0200 | |
|---|---|---|
| committer | 2026-09-17 11:05:45 +0200 | |
| commit | ae3fa667bda75f11881c9209dc67226f98bcfd95 (patch) | |
| tree | 1c2b16d8a97342fa608a15583ecc85ff0ec968eb /README.md | |
| download | desktop-flake-ae3fa667bda75f11881c9209dc67226f98bcfd95.tar.gz desktop-flake-ae3fa667bda75f11881c9209dc67226f98bcfd95.tar.bz2 desktop-flake-ae3fa667bda75f11881c9209dc67226f98bcfd95.zip | |
Add cross-platform Nix flake bootstrap
Adds a flake providing shared modules for NixOS and standalone
home-manager, a copyable NixOS host template, and the OpenSpec
tooling/change scaffolding used to plan this work.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 56 |
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 | |||
| 3 | A 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 | |||
| 16 | This flake does not partition disks for you — do that first, with the standard NixOS installer or manually. | ||
| 17 | |||
| 18 | 1. Partition and format disks; mount the target filesystems under `/mnt` (including `/mnt/boot` for the ESP if UEFI). | ||
| 19 | 2. Generate hardware config: `nixos-generate-config --root /mnt`. Keep the generated `hardware-configuration.nix`; discard its `configuration.nix`. | ||
| 20 | 3. 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). | ||
| 21 | 4. Copy the template into a real host: `cp -r ~/nix-config/hosts/template ~/nix-config/hosts/<real-hostname>`. | ||
| 22 | 5. Edit `hosts/<real-hostname>/configuration.nix`: set `networking.hostName`, pick the correct boot loader stanza, set `system.stateVersion` to the installer's NixOS release. | ||
| 23 | 6. Replace the stub hardware config: `cp /mnt/etc/nixos/hardware-configuration.nix ~/nix-config/hosts/<real-hostname>/hardware-configuration.nix`. | ||
| 24 | 7. 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 | ``` | ||
| 31 | 8. `cd ~/nix-config && git add -A` (flakes only see git-tracked files). | ||
| 32 | 9. If needed: `export NIX_CONFIG="experimental-features = nix-command flakes"`. | ||
| 33 | 10. `nixos-install --root /mnt --flake ~/nix-config#<real-hostname>`. | ||
| 34 | 11. Reboot and remove the install media. | ||
| 35 | 12. 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 | |||
| 39 | 1. 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. | ||
| 40 | 2. `git clone <your-remote-url> ~/nix-config`. | ||
| 41 | 3. 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 | |||
| 43 | This 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. | ||
