Files
nix/README.md
2026-03-28 11:45:28 +02:00

319 lines
6.1 KiB
Markdown

# Kris's Nix
You should end up with:
- NixOS using this repo from `/etc/nixos`
- the automatically-created user `kris`
- the default desktop config from this flake
## What This Repo Does
This repo configures:
- the default desktop machine
- a separate server host
DO NOT use `#server`, this build the server!
## Before You Start
You need:
- a NixOS installer
- internet access
- your disks partitioned and mounted
- this repo _(`git@tangled.sh:kris.darkworld.download/nix`)_
## Build a custom installer ISO
This flake now exposes an installer image with extra install tools preloaded
(`git`, `disko`, partitioning and filesystem tools).
Build it from this repo:
```bash
nix build .#installerIso
```
The ISO is created at:
```text
./result/iso/*.iso
```
Write it to a USB stick (replace `/dev/sdX`):
```bash
sudo dd if=./result/iso/*.iso of=/dev/sdX bs=4M status=progress oflag=sync
```
Then boot from that USB and follow the install steps below.
## Disk Layout
This repo now uses `disko` for the default desktop host.
The current declarative layout is:
```text
disk = /dev/nvme0n1
ESP = 2G FAT32 mounted at /boot
root disk = remaining space as btrfs
subvols = /, /home, /nix
```
Mount options are declared in the disko config:
- `/` with `compress=zstd`
- `/home` with `compress=zstd`
- `/nix` with `compress=zstd,noatime`
If `/dev/nvme0n1` is not the disk you want to wipe and install to, edit [`hosts/default/disko.nix`](/home/ralsei/config/hosts/default/disko.nix) before running the installer.
RAHHHHH IM NOT WRITING STUFF ANYMORE PLZ JUST TRY TO FIGURE OUT THE STEPS URSELF
THX
## Fresh Install
### 1. Boot the NixOS installer
Use the normal installer ISO.
### 2. Clone the repo in the installer
From the live installer:
```bash
nix-shell -p git
rm -rf /etc/nixos
git clone git@tangled.sh:kris.darkworld.download/nix /etc/nixos
```
### 3. Let disko partition and mount the target disk
Run:
```bash
nix --extra-experimental-features 'nix-command flakes' run github:nix-community/disko -- --mode destroy,format,mount /etc/nixos#default
```
This will:
- partition the disk
- format it
- create the btrfs subvolumes
- mount everything under `/mnt`
This is destructive.
### 4. Generate hardware config
Run:
```bash
nixos-generate-config --root /mnt
```
Then replace the generated target config with this repo while keeping the generated hardware file:
```bash
cp /mnt/etc/nixos/hardware-configuration.nix /tmp/hardware-configuration.nix
rm -rf /mnt/etc/nixos
git clone git@tangled.sh:kris.darkworld.download/nix /mnt/etc/nixos
cp /tmp/hardware-configuration.nix /mnt/etc/nixos/hardware-configuration.nix
```
## Install The System
### 5. Run the install
From the live environment:
```bash
nixos-install --flake /mnt/etc/nixos#default
```
If Nix complains about flakes:
```bash
nix --extra-experimental-features 'nix-command flakes' run nixpkgs#nixos-install -- --flake /mnt/etc/nixos#default
```
### 6. Reboot
After install finishes:
```bash
reboot
```
## First Boot
### 7. Log in as `kris`
The config creates the main user for you during install.
After boot, log into the installed system as:
```text
kris
```
### 8. Verify the repo location
Make sure the config is really here:
```bash
ls /etc/nixos
```
You should see:
- `flake.nix`
- `flake.lock`
- `hosts`
- `modules`
### 9. Rebuild once from the installed system
Run:
```bash
sudo nixos-rebuild switch --flake /etc/nixos#default
```
## Manual Restore After Install
Nix does not fully restore everything by itself. Some things still need to be
copied back manually.
### 10. Recreate normal user folders
Run:
```bash
mkdir -p /home/kris/Pictures
mkdir -p /home/kris/Pictures/Screenshots
mkdir -p /home/kris/Pictures/Wallpapers
mkdir -p /home/kris/Pictures/Deltarune
mkdir -p /home/kris/Downloads
mkdir -p /home/kris/Desktop
mkdir -p /home/kris/Documents
mkdir -p /home/kris/Projects
```
### 11. Restore Quickshell project
This config expects the Deltarune Quickshell project here:
```text
/home/kris/Projects/DeltaruneQuickshell
```
If it is missing, restore or clone it there.
### 12. Restore non-declarative assets
Copy back these if you want the setup to look correct:
- `~/Pictures/Wallpapers`
- `~/Pictures/Deltarune`
- `~/.local/share/fonts`
- `~/.local/share/icons`
- `~/.local/share/deltarunequickshell`
Important:
- screenshots are optional
- the desktop can boot without all of this, but it will not look right
### 13. Restore private assets and secrets
If you use them, restore things like:
- SSH keys
- Git auth
- cloudflare credentials
- Bitwarden/KeePass databases
- any private art or shell assets
## Useful Commands
Rebuild:
```bash
sudo nixos-rebuild switch --flake /etc/nixos#default
```
Update flake inputs:
```bash
cd /etc/nixos
nix flake update
```
Check current git state:
```bash
git -C /etc/nixos status
```
## If Something Is Broken
### Quickshell missing
Make sure:
- the package is installed by Nix
- `/home/kris/Projects/DeltaruneQuickshell` exists
### Rice looks wrong
You probably forgot to restore:
- fonts
- icons/cursors
- wallpapers
- Quickshell runtime state
### Build fails because of hardware config
Make sure this file exists:
```text
/etc/nixos/hardware-configuration.nix
```
### Git push fails
Your local SSH config may be cursed. If needed, bypass system SSH config:
```bash
git -c core.sshCommand='ssh -F /dev/null' push
```
## TL;DR
If you want the shortest version:
```bash
nix-shell -p git
rm -rf /etc/nixos
git clone git@tangled.sh:kris.darkworld.download/nix /etc/nixos
nix --extra-experimental-features 'nix-command flakes' run github:nix-community/disko -- --mode destroy,format,mount /etc/nixos#default
nixos-generate-config --root /mnt
cp /mnt/etc/nixos/hardware-configuration.nix /tmp/hardware-configuration.nix
rm -rf /mnt/etc/nixos
git clone git@tangled.sh:kris.darkworld.download/nix /mnt/etc/nixos
cp /tmp/hardware-configuration.nix /mnt/etc/nixos/hardware-configuration.nix
nixos-install --flake /mnt/etc/nixos#default
reboot
```
Then restore:
- `/home/kris/Projects/DeltaruneQuickshell`
- `~/.local/share/fonts`
- `~/.local/share/icons`
- your wallpapers and pictures