- Nix 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| hosts | ||
| modules | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
vega nix config
vega is α Lyrae — the proper name of the brightest star in Lyra, a small northern constellation.
for now, my laptop nix config. one repo, one flake, one config per machine.
each target (vm, laptop) gets its own ssh deploy key, with write access: it pushes its own hardware config once, then only ever pulls. config is otherwise written and committed elsewhere, then pulled in.
layout
flake.nix one attribute per machine, one iso per machine, the home-manager input
flake.lock the exact nixpkgs/home-manager commits — this is the reproducibility
modules/ shared, identical for every machine
├── base.nix imports everything below + git, flakes, timezone, locale
├── users/users.nix the account
├── boot/systemd-boot.nix uefi only — systemd-boot cannot install on bios
├── console/keyboard.nix de layout, console and x11/wayland
├── desktop/gnome.nix gnome + gdm
├── home/ everything user-scoped lives here, not in the system modules
│ ├── base.nix home manager activation + frader's home identity
│ ├── bash.nix aliases, completion, grep colour, the rebuild alias
│ ├── ssh.nix ~/.ssh/config: which identity for which git host
│ ├── git.nix git identity, ssh commit signing
│ ├── packages.nix the handful of packages every machine gets (per-user)
│ ├── claude.nix claude code + its keyring-backed token
│ └── vscodium.nix editor + the nix toolchain it drives
├── installer/iso.nix what the *-iso attributes bake into the installer image
├── audio/pipewire.nix
├── memory/swap.nix zram — ram, not a partition, so shared by every host
├── ssh/openssh.nix ssh client + daemon, gnome-keyring as the ssh agent
└── hardware/
├── base.nix firmware + updates, graphics, bluetooth — safe on any machine
├── intel.nix the va-api driver, which no default turns on
├── nvidia.nix written, not yet imported
├── usbmuxd.nix iphone over usb
├── placeholder.nix fake root fs, stands in until a host has a real one
└── vm-guest-agent.nix spice + qemu guest agents — imported by vms only
hosts/<name>/
├── configuration.nix manifest: imports + hostname + stateVersion
└── hardware-configuration.nix generated on the machine, never hand-edited. imported by
flake.nix, not by configuration.nix — it may not exist yet
modules/ never changes for a new machine: a new machine is a new host dir plus one
attribute in flake.nix. it changes once per new kind of hardware — hardware/nvidia.nix
gets written for the first nvidia machine and every later one just imports it.
machine-specific stuff (uuids, filesystems, hostname, stateVersion) stays in hosts/<name>/,
and since nixos-generate-config marks its own file "do not modify", nothing hand-written
ever goes into hardware-configuration.nix.
daily loop
git pull
sudo nixos-rebuild switch --flake /etc/nixos#nixos-testvm
both at once as rebuild, a bash alias from modules/home/bash.nix.
before pushing: nix flake check. it only evaluates the hosts — nothing gets built,
installed or activated;
every host evaluates, whether or not its hardware-configuration.nix exists yet — a host
without one prints a warning about the placeholder root fs.
note: flakes only see files git has seen. new file → git add it first. staged is enough —
flakes build the working tree, uncommitted changes included.
upgrades are deliberate: nix flake update moves flake.lock to a new nixpkgs commit.
until then nothing moves on its own. that is within a release — crossing one is below.
updating a nixos release
nix flake update moves within a release, never across one: it resolves the refs already in
flake.nix. crossing a release means editing them first — both together, they are a pair.
# 1. both refs in flake.nix:
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.11";
# home-manager.url = "github:nix-community/home-manager/release-26.11";
nix flake update # 2. re-resolve against the new refs; rewrites flake.lock
nix flake check # 3. evaluate every host, build nothing
sudo nixos-rebuild switch --flake /etc/nixos#$HOSTNAME
before that, read Backward Incompatibilities in the release notes — grep it for options this repo sets, most of it is services you do not run. one release per hop.
note: home-manager cuts release-XX.XX after nixpkgs cuts nixos-XX.XX. no branch yet means
the pair is not ready: git ls-remote --heads https://github.com/nix-community/home-manager.
note: system.stateVersion and home.stateVersion stay at the release the machine was
installed on.
wifi
nmtui — connect to wireless lan -> ssid -> passphrase. no config needed.
gnome boxes test vm
hosts/nixos-testvm is designed to be a gnome boxes
test vm. make sure you enable uefi mode
note issue #5
installation
NOTE: before installing make sure you add hosts/<new_machine> or be familiar with one host you will use to install.
hosts/<name> exists because hardware differs — filesystems and uuids always, a gpu driver
only for nvidia. amd needs no config beyond what modules/hardware/base.nix already sets, so
it gets no host-side import; intel needs hardware/intel.nix, because mesa ships its own
va-api driver but nixpkgs ships no intel one by default.
Each host requires a configuration.nix file (which should be created manually beforehand), see hosts/template.
If you re-install on a machine, you can temporarily rm hardware-configuration.nix and commit the generated one (see below).
the provided installer isos have git and networking, so we clone the repo on the iso and install the system fully from the flake. (packages should live on the system)
info on how to get the iso below
getting hardware to a state to install the flake
initial boot
use the custom iso (also possible with stock minimal iso, just needs to download for a while) and get to partitioning. check the firmware first — note that systemd-boot cannot install on bios.
tip: on the custom iso the console is already de; on a stock iso use loadkeys de-latin1 =)
tip: the custom iso carries this readme md README.md reads it there.
partitioning
we want 1 fat32 esp for the boot partition and one ext4 partition for the system. i selected ext4 since the btrfs gains are minimal on a nix system (see below).
note: replace vda with whatever storage device is used, like nvme0n1. check with
lsblk -f before touching anything.
# create boot partition - only necessary if you dont already have one
# mklabel rewrites the partition table: THIS WILL DELETE ALL DATA!
parted /dev/vda -- mklabel gpt
# create esp partiton as fat32
parted /dev/vda -- mkpart ESP fat32 1MiB 1024MiB
parted /dev/vda -- set 1 esp on
# format fat32
mkfs.vfat -F32 /dev/vda1
# create primary partition
parted /dev/vda -- mkpart primary 1024MiB 100%
# encrypt
cryptsetup luksFormat /dev/vda2
# open at mount point /dev/mapper/cryptroot
cryptsetup open /dev/vda2 cryptroot
# format to ext4
mkfs.ext4 -L vega /dev/mapper/cryptroot
just be careful when partitioning =)
cloning the repo
mount the partitions
mount /dev/mapper/cryptroot /mnt
mkdir -p /mnt/boot && mount /dev/vda1 /mnt/boot
the new system now sits at /mnt
clone the repo now — the repo is public, so an https clone needs no key. the target path is
the whole point: /mnt/etc/nixos becomes /etc/nixos on the installed system, which is
what the install command and the daily loop both read.
git clone https://forgejo.vibe.ac/frader/vega.git /mnt/etc/nixos
getting the hardware config
for a machine not yet in the repo: create hosts/<name>/configuration.nix and add one
nixosConfigurations.<name> attribute to flake.nix — the repo's only flake.
generate the config
nixos-generate-config --root /mnt --dir /mnt/etc/nixos/hosts/<name>
note: this never clobbers your hand-written config — configuration.nix is only created if
none exists. hardware-configuration.nix is rewritten on every run.
tell git about the file — nix only builds files git tracks, and git add is enough:
git -C /mnt/etc/nixos add hosts/<name>/hardware-configuration.nix
no commit and no git identity on the iso: flakes build from the working tree, so a staged file is visible to the install. the commit happens after first boot, as your real account, and gets pushed with the machine's deploy key.
you need to add the file to git.
Otherwise the temporary "fake fs" will get used as information and (in the best case) nothing will happen
installing
nixos-install --flake /mnt/etc/nixos#<name> --no-channel-copy --no-root-passwd
disclaimer: keep --no-root-passwd. it skips the root password prompt, and since no root
password is ever set (modules/users/users.nix configures no root account) root cannot be
logged into at all — only frader, then sudo.
do not reboot yet, read below
first login: change the password before logging in
initialPassword is "changeme" (modules/users/users.nix), we should change it before logging in with gdm otherwise the keyring will not unlock easily.
nixos-enter --root /mnt
passwd frader
exit
already too late? set the real password, then re-key the keyring to match — seahorse
(Passwords and Keys) -> login -> Change Password, with changeme as the old one. or delete
~/.local/share/keyrings/login.keyring and log in again for a fresh one; what was stored in it is lost, which on a new machine is nothing. either way the ssh key passphrases get asked
for once more afterwards, that is the re-key working, not a failure.
after first boot, hand the repo to your user — it is cloned as root, and git needs to be able to write to it without sudo:
sudo chown -R frader:users /etc/nixos
building an iso
nix build .#nixosConfigurations.<name>-iso.config.system.build.isoImage
tip: building the iso (mostly creating the squashfs filesystem) can take quite some time. relax.
a machine that has never been installed can have an iso: hosts/<name>/configuration.nix and its
flake attribute are needed, its hardware-configuration.nix is not — the flake falls back to
modules/hardware/placeholder.nix. for a machine with no host dir at all,
build template-iso;
what comes out is nixpkgs' minimal installer plus two things in its store — the host's system
closure, and the nixpkgs/home-manager sources flake.lock points at.
installing using the iso
dd if=result/iso/*.iso of=/dev/sdX bs=16M status=progress conv=fsync
boot it and install as above: clone, generate the hardware config, nixos-install. the only
difference is that nothing downloads — the packages are already on the stick and get copied over,
and only the few derivations that depend on this machine's uuids are rebuilt.
the store on the stick is as of the build: rebuild the iso when the config changes, or the install fetches the difference.
ssh identities
three keys, one per purpose, all flat in ~/.ssh — the agent only scans the top level,
so a key in a subdirectory is never unlocked automatically:
~/.ssh/id_ed25519_github github.com
~/.ssh/id_ed25519_forgejo forgejo.vibe.ac — the deploy key
~/.ssh/id_ed25519_git signs commits, see git below
make new key:
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519_github -C "frader@$(hostname)"
take a somewhat strong password - you will have to enter it from time to time.
change it later: ssh-keygen -p -f <keyfile>.
register the .pub: key to get it to work
copy an identity to a machine that does not have it yet
mkdir -p -m 700 ~/.ssh
scp -p 'oldmachine:.ssh/id_ed25519_github*' ~/.ssh/ # needs openssh
chmod 600 ~/.ssh/id_ed25519_github
chmod 644 ~/.ssh/id_ed25519_github.pub
permissions are not cosmetic, ssh refuses a private key readable by group or world:
700 directory, 600 private, 644 public.
nothing to register with gnome-keyring: GDM opens the login keyring with your login password at the greeter, and the first ssh use asks for the key passphrase once — the agent then keeps the unlocked key in that keyring, everything after is silent.
all of that assumes the two passwords agree, which is only true if the keyring was created with the password you now have — see first login above.
check: ssh -T git@github.com, ssh -T git@forgejo.vibe.ac.
git
identity and commit signing come from modules/home/git.nix. commits and tags are signed
by default, over ssh — no gpg. signing uses a key of its own, ~/.ssh/id_ed25519_git
(generated as above, -C "fritz@vibe.ac"); register its .pub as a signing key on
github and forgejo. ~/.ssh/allowed_signers holds the same key for local
git verify-commit.
claude
claude needs minimal setup, namely setting the auth key for the vibe endpoint.
run
secret-tool store --label='claude code' service claude-code
to store the api key.
editor
vscodium, per-user, from modules/home/vscodium.nix, with jnoortheen.nix-ide and the
binaries it drives: nixd, nixfmt, deadnix, statix.
These are installed system wide, other development stuff should be installed
using devShells or another isolation mechanism.