2020-08-22 17:44:39 +02:00
|
|
|
|
# NixOS configuration
|
|
|
|
|
|
|
|
|
|
## How to install
|
|
|
|
|
|
|
|
|
|
This guide describes how to install this configuration (or any NixOS
|
|
|
|
|
configuration) with GPT and legacy (BIOS) boot.
|
|
|
|
|
|
2020-08-24 11:11:23 +02:00
|
|
|
|
If you do not have a wired connection, first set up wifi
|
|
|
|
|
|
|
|
|
|
wpa_passphrase "SSID" "PSK" | sudo wpa_supplicant -B -i wlp4s0 -c/dev/stdin
|
|
|
|
|
|
2020-08-22 17:44:39 +02:00
|
|
|
|
Create the partition table (enter the indented lines in the repl).
|
|
|
|
|
|
|
|
|
|
sudo parted /dev/sdX
|
|
|
|
|
mktable GPT
|
|
|
|
|
mkpart primary 1MiB 2MiB
|
|
|
|
|
mkpart primary 2MiB 500MiB
|
|
|
|
|
mkpart primary 500MiB 100%
|
|
|
|
|
set 1 bios_grub on
|
|
|
|
|
disk_toggle pmbr_boot
|
|
|
|
|
quit
|
|
|
|
|
|
|
|
|
|
Format encrypted partition and open it
|
|
|
|
|
|
|
|
|
|
sudo cryptsetup luksFormat /dev/sdX3
|
|
|
|
|
sudo cryptsetup luksOpen /dev/sdX3 HOSTNAME-pv
|
|
|
|
|
|
|
|
|
|
Create LVM (replace `8G` with desired swap size)
|
|
|
|
|
|
|
|
|
|
sudo pvcreate /dev/mapper/HOSTNAME-pv
|
|
|
|
|
sudo vgcreate HOSTNAME-vg /dev/mapper/HOSTNAME-pv
|
|
|
|
|
sudo lvcreate -L 8G -n swap HOSTNAME-vg
|
|
|
|
|
sudo lvcreate -l '100%FREE' -n root HOSTNAME-vg
|
|
|
|
|
|
|
|
|
|
**Hint**: If you have to reboot to the installation system later because
|
|
|
|
|
something went wrong and you need access to the LVM (but don’t know LVM), do
|
|
|
|
|
the following after opening the luks partition: `sudo vgchange -ay`
|
|
|
|
|
|
|
|
|
|
Create filesystems
|
|
|
|
|
|
|
|
|
|
sudo mkfs.ext2 /dev/sdX2
|
|
|
|
|
sudo mkfs.ext4 -L root /dev/HOSTNAME-vg/root
|
|
|
|
|
sudo mkswap -L swap /dev/HOSTNAME-vg/swap
|
|
|
|
|
|
|
|
|
|
Mount the file systems and activate swap
|
|
|
|
|
|
|
|
|
|
sudo mount /dev/HOSTNAME-vg/root /mnt
|
|
|
|
|
sudo mkdir /mnt/boot
|
|
|
|
|
sudo mount /dev/sdX2 /mnt/boot
|
|
|
|
|
sudo swapon /dev/HOSTNAME-vg/swap
|
|
|
|
|
|
|
|
|
|
Create the configuration (see [below](#how-to-add-new-device)) and copy this
|
|
|
|
|
repository to your new home directory (e.g. `/mnt/home/simon/nixos`).
|
|
|
|
|
|
|
|
|
|
Add a symlink as the global configuration
|
|
|
|
|
|
|
|
|
|
sudo mkdir -p /mnt/etc/nixos/
|
|
|
|
|
sudo ln -s /mnt/home/simon/nixos/machines/nunotaba/configuration.nix /mnt/etc/nixos/configuration.nix
|
|
|
|
|
|
2020-08-30 10:03:48 +02:00
|
|
|
|
Generate hardware configuration and copy hardware configuration to machine
|
|
|
|
|
configuration
|
2020-08-22 17:44:39 +02:00
|
|
|
|
|
|
|
|
|
sudo nixos-generate-config --root /mnt/
|
2020-08-30 10:03:48 +02:00
|
|
|
|
sudo cp /mnt/etc/nixos/hardware-configuration.nix /mnt/home/simon/nixos/machines/nunotaba/hardware-configuration.nix
|
2020-08-22 17:44:39 +02:00
|
|
|
|
|
|
|
|
|
Install NixOS and reboot (if you do not have another machine, omit
|
|
|
|
|
`--no-root-passwd`)
|
|
|
|
|
|
|
|
|
|
sudo nixos-install --no-root-passwd
|
|
|
|
|
sudo reboot
|
|
|
|
|
|
|
|
|
|
**Hint**: If you need to reboot to the installation system because something
|
|
|
|
|
didn’t work, first open the luks partition like in the setup script, run `sudo
|
|
|
|
|
vgchange -ay` to scan for LVM VGs and then mount the other filesystems like in
|
|
|
|
|
the script.
|
|
|
|
|
|
2020-08-30 10:03:48 +02:00
|
|
|
|
SSH into the machine (or login locally if you set a root password), set a user
|
|
|
|
|
password and clone the dotfiles
|
2020-08-22 17:44:39 +02:00
|
|
|
|
|
|
|
|
|
ssh root@machine
|
|
|
|
|
rm /etc/nixos/configuration.nix
|
|
|
|
|
passwd simon
|
|
|
|
|
^D
|
|
|
|
|
ssh simon@machine
|
|
|
|
|
# press “q” to get rid of zsh-newuser-install
|
|
|
|
|
git clone https://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick
|
|
|
|
|
source $HOME/.homesick/repos/homeshick/homeshick.sh
|
|
|
|
|
homeshick clone https://git.sbruder.de/simon/dotfiles
|
|
|
|
|
|
|
|
|
|
## How to add new device
|
|
|
|
|
|
|
|
|
|
* Copy the config from the device that is similar to the new one
|
|
|
|
|
* Import profiles/modules you want
|
|
|
|
|
* Change settings in `configuration.nix`
|
|
|
|
|
* Change secrets
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
[MIT License](LICENSE)
|