Update NixOS installation

Tibo De Peuter 2023-10-18 21:32:17 +02:00
parent 00091d260b
commit bdfc0b188c
2 changed files with 67 additions and 58 deletions

@ -1,58 +0,0 @@
# Installing NixOS
I used [this guide](https://nixos.wiki/wiki/Wil_T_Nix_Guides) so it should be straightforward for you too.
```
< Connect to the Internet />
fdisk /dev/sdx
<.../>
mkfs.fat -F 32 -n NIXBOOT /dev/sdx1
mkswap -L SWAP /dev/sdx2
mkfs.ext4 -L NIXROOT /dev/sdx3
mount /dev/disk/by-label/NIXROOT /mnt
mkdir -p /mnt/boot/efi
mount /dev/disk/by-label/NIXBOOT /mnt/boot/efi
swapon /dev/disk/by-label/SWAP
```
<details>
<summary>If you do not have an existing configuration repository.</summary>
```
git init
git crypt init
git crypt add-gpg-user <email>
git crypt export-key <out-path>
```
Add a `.gitattributes` file containing
```
secrets/** filter=git-crypt diff=git-crypt
```
</details>
<details>
<summary>If you have a repository and you want to 'clone' an existing machine using flakes.</summary>
Clone your repository and go inside the folder containing the `flake.nix` file.
```
nixos-install --flake .#<hostname>
```
Alternatively, if you don't want to clone the repository first:
```
nixos-install --flake https://<url_to_your_repo>#<hostname>
```
</details>
# Installing packages
User packages still need to be installed. Run [this script](https://git.depeuter.dev/tdpeuter/sisyphus/src/commit/1105a772fdcc7b4d7cb5534f3befda6a31e1e28d/nixos/apply-users.sh) if you're using home manager.

67
NixOS.md Normal file

@ -0,0 +1,67 @@
# NixOS
## Installation
I used [this guide](https://nixos.wiki/wiki/Wil_T_Nix_Guides) so if you follow along there, it should be straightforward for you too.
Depending on how you're feeling today, you should prepare an installation medium with either the graphical or minimal installer.
```
fdisk -l
fdisk /dev/sdx
<.../>
mkfs.fat -F 32 -n NIX-BOOT /dev/sdx1
mkswap -L SWAP /dev/sdx2
mkfs.ext4 -L NIX-ROOT /dev/sdx3
mount /dev/disk/by-label/NIX-ROOT /mnt
mkdir -p /mnt/boot/efi
mount /dev/disk/by-label/NIX-BOOT /mnt/boot/efi
swapon /dev/disk/by-label/SWAP
```
<details>
<summary>If you do not have an existing configuration repository.</summary>
(Automatically) generate a basic config using:
```
nixos-generate-config --root /mnt
```
You probably want to tweak this configuration. Remember to:
- Point `boot.efiSysMountPoint` to `/boot/efi`.
- Enable networking.
- Add a user. I recommend to set a password using `initialPassword`.
- Install `git`.
- Map you disk configuration to the labels you just made. This is done in `/etc/nixos/hardware-configuration.nix`.
Then you can `cd /mnt` and `nixos-install`. When the installation is successful, reboot and remove the installation media.
Afterwards, you should change the password of your user. Then you can choose to build your configuration from here or integrate with an existing configuration.
</details>
<details>
<summary>If you have a repository and you want to 'clone' an existing machine using flakes.</summary>
Clone your repository and go inside the folder containing the `flake.nix` file.
```
nixos-install --flake .#<hostname>
```
Alternatively, if you don't want to clone the repository first:
```
nixos-install --flake https://<url_to_your_repo>#<hostname>
```
It is possible that you might have to append `--experimental-features nix-command --experimental-feautres flakes` if your system does not have those options enabled yet.
</details>
# Installing packages
User packages still need to be installed. Run [this script](https://git.depeuter.dev/tdpeuter/sisyphus/src/commit/1105a772fdcc7b4d7cb5534f3befda6a31e1e28d/nixos/apply-users.sh) if you're using home manager.