Simon Bruder
c9d66b545c
Flake lock file updates: • Updated input 'flake-utils': 'github:numtide/flake-utils/1ef2e671c3b0c19053962c07dbda38332dcebf26' (2024-01-15) → 'github:numtide/flake-utils/d465f4819400de7c8d874d50b982301f28a84605' (2024-02-28) • Updated input 'home-manager-unstable': 'github:nix-community/home-manager/043ba285c6dc20f36441d48525402bcb9743c498' (2024-02-14) → 'github:nix-community/home-manager/cf111d1a849ddfc38e9155be029519b0e2329615' (2024-03-06) • Updated input 'nix-pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/0db2e67ee49910adfa13010e7f012149660af7f0' (2024-02-07) → 'github:cachix/pre-commit-hooks.nix/5df5a70ad7575f6601d91f0efec95dd9bc619431' (2024-02-15) • Updated input 'nixos-hardware': 'github:nixos/nixos-hardware/f1b2f71c86a5b1941d20608db0b1e88a07d31303' (2024-02-13) → 'github:nixos/nixos-hardware/59e37017b9ed31dee303dbbd4531c594df95cfbc' (2024-03-02) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/01885a071465e223f8f68971f864b15829988504' (2024-02-13) → 'github:nixos/nixpkgs/880992dcc006a5e00dd0591446fdf723e6a51a64' (2024-03-05) • Updated input 'nixpkgs-unstable': 'github:nixos/nixpkgs/35ff7e87ee05199a8003f438ec11a174bcbd98ea' (2024-02-13) → 'github:nixos/nixpkgs/9df3e30ce24fd28c7b3e2de0d986769db5d6225d' (2024-03-06) • Updated input 'sops-nix': 'github:Mic92/sops-nix/48afd3264ec52bee85231a7122612e2c5202fa74' (2024-02-13) → 'github:Mic92/sops-nix/25dd60fdd08fcacee2567a26ba6b91fe098941dc' (2024-03-06) • Updated input 'sops-nix/nixpkgs-stable': 'github:NixOS/nixpkgs/d8cd80616c8800feec0cab64331d7c3d5a1a6d98' (2024-02-10) → 'github:NixOS/nixpkgs/66d65cb00b82ffa04ee03347595aa20e41fe3555' (2024-03-03) |
||
---|---|---|
.git-crypt | ||
.reuse | ||
keys | ||
LICENSES | ||
machines | ||
modules | ||
pkgs | ||
users/simon | ||
.envrc | ||
.gitattributes | ||
.gitignore | ||
.sops.yaml | ||
flake.lock | ||
flake.lock.license | ||
flake.nix | ||
README.md | ||
secrets.yaml |
NixOS configuration
Structure
machines
: Machine-specific configurationREADME.md
: Short overview of the hardware and usage of the machineconfiguration.nix
: Main configurationhardware-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 don’t 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 overlayusers/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:
systemctl start wpa_supplicant
wpa-cli
add_network
set_network 0 ssid "SSID"
set_network 0 psk "PSK"
set_network 0 key_mgmt WPA-PSK
enable_network 0
Create the partition table (enter the indented lines in the repl):
parted /dev/nvmeXnY
mktable GPT
mkpart ESP 1MiB 512MiB
mkpart root 512MiB 100%
set 1 esp on
quit
On MBR:
parted /dev/sdX
mktable GPT
mkpart primary 1MiB 2MiB
mkpart primary 2MiB 512MiB
mkpart primary 512MiB 100%
set 1 bios_grub on
disk_toggle pmbr_boot
quit
Format encrypted partition and open it:
cryptsetup luksFormat --type luks2 /dev/nvmeXnYp2
cryptsetup open /dev/nvmeXnYp2 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 don’t know LVM), do
the following after opening the luks partition: vgchange -ay
.
Create filesystems:
mkfs.fat -F 32 -n boot /dev/nvmeXnYpZ
mkfs.btrfs -L root /dev/HOSTNAME-vg/root
mkswap -L swap /dev/HOSTNAME-vg/swap
On MBR:
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 -o compress=zstd /dev/HOSTNAME-vg/root /mnt
mkdir /mnt/boot
mount /dev/nvmeXnYp1 /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 --no-channel-copy --impure --flake /path/to/repository#hostname
Add the krops sentinel file:
mkdir -p /mnt/var/src
touch /mnt/var/src/.populate
Reboot.
License
This repository is REUSE compliant. To get the most correct licensing information, please consult the REUSE specification or use a tool that parses it.
As a rule of thumb,
most code files are released under the AGPL-3.0-or-later
,
most generated files are specified as CC0-1.0
(as they are not copyrightable)
and small independent scripts are licensed under Apache-2.0
.
However, there are deviations from this,
so always consult the file header and other resources as specified in the REUSE specification.
Please note that those licensing terms only apply to the source files in this repository, not any build outputs, like system or package closures. They might be licensed differently, depending on their source.
If you think you have a compelling reason why you should be able to use part of this repository under a more permissive license, please contact me, so we can figure something out. Please note, that I can only offer this for files that are solely authored by me, as I do not own the rights to other people’s code.