diff --git a/README.md b/README.md index b85fb0a..5c76f76 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,153 @@ -# nixos +# NixOS -## Playground +## Playground (QEMU) +```bash sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager -Video QXL -configuration.nix services.spice-vdagentd.enable = true; +``` -Falls zu klein HDD erweitern mit `qemu-img resize nixos.qcow2 +20G` +- Video: QXL +- In `configuration.nix`: `services.spice-vdagentd.enable = true;` +- Falls die HDD zu klein ist: `qemu-img resize nixos.qcow2 +20G` -## Install inside nixos +## Manuelle Installation (UEFI) +### 1. Root-Shell starten + +```bash sudo -i +# Use german keyboard layout +loadkeys de + +# List block devices +lsbkl +``` + +### 2. Partitionierung + +Das folgende Schema erstellt fuenf Partitionen auf `/dev/sda`: + +| Partition | Typ | Groesse | Mountpoint | +|-------------|----------------|-------------------|------------| +| `/dev/sda1` | FAT32 (EFI) | 512 MB | `/boot` | +| `/dev/sda2` | linux-swap | 8 GB | — | +| `/dev/sda3` | ext4 (Root) | Rest minus Home | `/` | +| `/dev/sda4` | ext4 (Home) | 50% des Rests | `/home` | + +**Hinweis:** Die Groessen muessen an die eigene Festplatte angepasst werden. Im Beispiel wird eine 100 GB Festplatte verwendet. + +```bash +# GPT-Partitionstabelle erstellen parted /dev/sda -- mklabel gpt -parted /dev/sda -- mkpart root ext4 512MB -8GB -parted /dev/sda -- mkpart swap linux-swap -8GB 100% -parted /dev/sda -- mkpart ESP fat32 1MB 512MB -parted --list -parted /dev/sda -- set 3 esp on -mkfs.ext4 -L nixos /dev/sda1 +# EFI-Partition (512 MB) +parted /dev/sda -- mkpart esp fat32 1MB 512MB +parted /dev/sda -- set 1 esp on + +# Swap-Partition (8 GB) +parted /dev/sda -- mkpart swap linux-swap 512MB 8626MB + +# Root-Partition (ca. 45 GB) +parted /dev/sda -- mkpart root ext4 8636MB 40000MB + +# Home-Partition (Rest) +parted /dev/sda -- mkpart home ext4 40000MB 100% + +# Ergebnis pruefen +parted /dev/sda -- print +``` + +### 3. Dateisysteme erstellen + +```bash +# EFI-Partition formatieren +mkfs.fat -F 32 -n boot /dev/sda1 + +# Swap-Partition formatieren mkswap -L swap /dev/sda2 -mkfs.fat -F 32 -n boot /dev/sda3 +# Root-Partition formatieren +mkfs.ext4 -L nixos /dev/sda3 + +# Home-Partition formatieren +mkfs.ext4 -L home /dev/sda4 +``` + +### 4. Partitionen einhängen + +Die Reihenfolge ist wichtig — zuerst Root, dann die Unterverzeichnisse: + +```bash +# Root mounten mount /dev/disk/by-label/nixos /mnt -mkdir -p /mnt/boot + +# Boot-Verzeichnis erstellen und mounten +mkdir /mnt/boot mount -o umask=077 /dev/disk/by-label/boot /mnt/boot -swapon /dev/sda2 +# Home-Verzeichnis erstellen und mounten +mkdir -p /mnt/home +mount /dev/disk/by-label/home /mnt/home +# Swap aktivieren +swapon /dev/disk/by-label/swap +``` +### 6. Konfiguration generieren + +```bash nixos-generate-config --root /mnt +``` -sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager -sudo nix-channel --update +Dies erzeugt zwei Dateien: +- `/mnt/etc/nixos/hardware-configuration.nix` — erkannte Hardware und Mountpoints +- `/mnt/etc/nixos/configuration.nix` — Grundkonfiguration -https://nixos.org/manual/nixos/stable/ +### 7. Bootloader konfigurieren -### install +In `/mnt/etc/nixos/configuration.nix` sicherstellen, dass der Bootloader korrekt eingerichtet ist: + +```nix +boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; +}; +``` + +### 8. Home Manager Channel hinzufuegen + +```bash +nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager +nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager +nix-channel --update +``` + +### 9. System installieren + +```bash +nixos-install +``` + +Nach der Installation wird ein Root-Passwort abgefragt. Danach: + +```bash +reboot +``` + +### 10. Nach dem ersten Start + +```bash +# Konfiguration anwenden sudo nixos-rebuild switch -sudo /etc/nixos/setup-smb-credentials.sh -### cleanup -sudo nix-collect-garbage -d -### optimize & cleanup +# SMB-Zugangsdaten einrichten (falls Netzlaufwerke genutzt werden) +sudo /etc/nixos/setup-smb-credentials.sh +``` + +## Wartung + +```bash +# Nix Store optimieren und alte Generationen entfernen sudo nix-store --optimise && sudo nix-collect-garbage -d +```