|
| 1 | +<div align="center"> |
| 2 | + <h1>my NixOS configurations.</h1> |
| 3 | + <p>This repo stores all my nix configurations. It is modular in terms of host machines, modules and users. The main branch should be regarded as a rolling release.</p> |
| 4 | +</div> |
| 5 | + |
| 6 | +> [!NOTE] |
| 7 | +> Disk partitioning still needs to be done manually for each machine. I did not yet have the nerve to make this declarative. |
| 8 | +
|
| 9 | +# Setting up a new host |
| 10 | +To bootstrap a new machine with the configuration from withing the installer, follow the [official installation guide](https://nixos.wiki/wiki/NixOS_Installation_Guide) up to the *Create NixOS Config* section, or just: |
| 11 | +- make sure networking is working: |
| 12 | +```sh |
| 13 | +ping -c 2 papertoilet.com |
| 14 | +``` |
| 15 | +- make sure all disks are correctly formatted and mounted: |
| 16 | +```sh |
| 17 | +lsblk -f |
| 18 | +``` |
| 19 | + |
| 20 | +Then, after nix flakes are enabled: |
| 21 | +```sh |
| 22 | +export NIX_CONFIG="experimental-features = nix-command flakes" |
| 23 | +``` |
| 24 | + |
| 25 | +clone this repo: |
| 26 | +```sh |
| 27 | +nix-shell -p git vim |
| 28 | +git clone https://github.com/inverted-tree/nixos-config.git /mnt/etc/nixos |
| 29 | +``` |
| 30 | + |
| 31 | +and generate the `hardware-configuration.nix`: |
| 32 | +```sh |
| 33 | +nixos-generate-config --root /mnt |
| 34 | +mkdir -p /mnt/etc/nixos/hosts/<newhostname> |
| 35 | +mv /mnt/etc/nixos/configuration.nix /mnt/etc/nixos/hardware-configuration.nix /mnt/etc/nixos/hosts/<newhostname> |
| 36 | +``` |
| 37 | + |
| 38 | +Adapt the generated config: |
| 39 | +```sh |
| 40 | +vim /mnt/etc/nixos/hosts/<newhostname>/configuration.nix |
| 41 | +``` |
| 42 | + |
| 43 | +it should look something like [the default template](./hosts/templates/default-configuration.nix): |
| 44 | +```nix |
| 45 | +{ |
| 46 | + imports = [ |
| 47 | + # The hardware-dependent options |
| 48 | + ./hardware-configuration.nix |
| 49 | + # All (shared/non-specific) users |
| 50 | + ../../users/iamgroot.nix |
| 51 | + # All custom modules |
| 52 | + ../../modules/somemodule.nix |
| 53 | + ]; |
| 54 | +
|
| 55 | + nix.settings.experimental-features = [ |
| 56 | + "nix-command" |
| 57 | + "flakes" |
| 58 | + ]; |
| 59 | +
|
| 60 | + ... |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +and then install the OS wiht the flake: |
| 65 | +```sh |
| 66 | +nixos-install --flake /mnt/etc/nixos#<newhostname> |
| 67 | +``` |
| 68 | + |
| 69 | +Finally, set a root password and reboot. |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +> [!WARNING] |
| 74 | +> This repo mainly acts as a way to sync my configurations across host machines and make it easy to set up a new machine with minimal effort. Feel free to use my code and break your system. |
0 commit comments