My NixOS configuration and other infrastructure related things
Find a file
Simon Bruder 02f2138294
flake.lock: Update
Flake input changes:

* Updated 'home-manager': 'github:nix-community/home-manager/148d85ee8303444fb0116943787aa0b1b25f94df' -> 'github:nix-community/home-manager/35a24648d155843a4d162de98c17b1afd5db51e4'
* Updated 'nix-pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/0398f0649e0a741660ac5e8216760bae5cc78579' -> 'github:cachix/pre-commit-hooks.nix/628a319e1ee0f9e01d63a3dbe6c1681a177bc5f9'
* Updated 'nixpkgs': 'github:nixos/nixpkgs/bad3ccd099ebe9a8aa017bda8500ab02787d90aa' -> 'github:nixos/nixpkgs/0ccd0d91361dc42dd32ffcfafed1a4fc23d1c8b4'
* Updated 'nixpkgs-unstable': 'github:nixos/nixpkgs/fa0326ce5233f7d592271df52c9d0812bec47b84' -> 'github:nixos/nixpkgs/7e567a3d092b7de69cdf5deaeb8d9526de230916'
2021-06-23 17:21:57 +02:00
.git-crypt Add 1 git-crypt collaborator 2021-02-05 18:01:49 +01:00
keys sayuri: Migrate to sops 2021-04-10 11:58:50 +02:00
machines sayuri: Drop amdvlk in favour of radv 2021-06-20 11:22:34 +02:00
modules mulvad: Do not unlock pass when disabling tunnel 2021-06-01 11:37:59 +02:00
pkgs nix-direnv: Enable flake support 2021-06-11 16:04:55 +02:00
users/simon programs: Add snownews 2021-06-06 00:12:55 +02:00
.envrc direnv: Use nix-direnv’s use_flake 2021-05-09 12:34:48 +02:00
.gitattributes Use sops for secrets 2021-04-06 14:05:48 +02:00
.gitignore Ignore all results 2020-12-17 09:50:25 +01:00
.sops.yaml sayuri: Migrate to sops 2021-04-10 11:58:50 +02:00
flake.lock flake.lock: Update 2021-06-23 17:21:57 +02:00
flake.nix Use nixos-21.05 branch 2021-06-01 09:14:59 +02:00
LICENSE Initial commit 2020-08-22 17:44:39 +02:00
README.md Adapt documentation to current configuration 2021-05-04 21:45:05 +02:00
secrets.yaml sayuri: Migrate to sops 2021-04-10 11:58:50 +02:00

NixOS configuration

Structure

  • machines: Machine-specific configuration
    • README.md: Short overview of the hardware and usage of the machine
    • configuration.nix: Main configuration
    • hardware-configuration.nix: Hardware-specific configuration. It should not depend on any modules or files from this repository, since it is used for initial setup.
    • services: Non-trivial machine-specific configuration related to a specific service the machine provides.
    • secrets: Nix expressions that include information that is not meant to be visible to everyone (e.g. accounts, password hashes, private information etc.) or secrets for services that dont provide any other (easy) way of specifying them and whose secrets leaking does not pose a huge threat
  • modules: Custom modules. Many are activated by default, since I want them on all systems.
  • pkgs: My nixpkgs overlay
  • users/simon: home-manager configuration

Secrets are managed with sops-nix.

Machines can be deployed with nix run .#deploy/hostname, LUKS encrypted systems can be unlocked over network with nix run .#unlock/hostname.

How to install

This guide describes how to install this configuration with GPT and BIOS boot. It is not a one-fits-all guide, but the base for what I use for interactive systems. Servers and specialised systems may need a different setup (e.g. swap with random luks passphrase and no LVM).

Set up wifi if no wired connection is available:

wpa_passphrase "SSID" "PSK" | wpa_supplicant -B -i wlp4s0 -c/dev/stdin

Create the partition table (enter the indented lines in the repl):

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:

cryptsetup luksFormat --type luks2 /dev/sdX3
cryptsetup open --type luks2 /dev/sdX3 HOSTNAME-pv

Create LVM (replace 8G with desired swap size):

pvcreate /dev/mapper/HOSTNAME-pv
vgcreate HOSTNAME-vg /dev/mapper/HOSTNAME-pv
lvcreate -L 8G -n swap HOSTNAME-vg
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 dont know LVM), do the following after opening the luks partition: vgchange -ay.

Create filesystems:

mkfs.ext2 /dev/sdX2
mkfs.btrfs -L root /dev/HOSTNAME-vg/root
mkswap -L swap /dev/HOSTNAME-vg/swap

Mount the file systems and activate swap:

mount /dev/HOSTNAME-vg/root /mnt
mkdir /mnt/boot
mount /dev/sdX2 /mnt/boot
swapon /dev/HOSTNAME-vg/swap

Generate hardware configuration and copy hardware configuration to machine configuration (skip this step if you already have a hardware-configuration for this machine):

nixos-generate-config --root /mnt/

Modify the hardware configuration as needed and add it to the machine configuration in this repository. If necessary, create the machine configuration first by basing it on an already existing configuration and adding an entry to machines/default.nix. Then copy this repository to the target machine and run (--impure is needed since /mnt/nix/store is not in /nix/store):

nixos-install --impure --flake /path/to/repository#hostname

Add the krops sentinel file:

mkdir -p /mnt/var/src
touch /mnt/var/src/.populate

Reboot.

License

As nixpkgs, this repository is licensed under the MIT License. This only applies to the nix expressions, not the built system or package closure. Patches may also be licensed differently, since they may be derivative works of the packages to which they apply.