From 48130f416658a3d8285d41aee5bf63b70999bc80 Mon Sep 17 00:00:00 2001 From: Kris Date: Sat, 28 Mar 2026 00:23:39 +0200 Subject: [PATCH] DISKO --- README.md | 340 ++++++++++++++++++++++++-------- flake.lock | 123 +++++++----- flake.nix | 3 + hosts/default/configuration.nix | 6 - hosts/default/disko.nix | 57 ++++++ 5 files changed, 395 insertions(+), 134 deletions(-) create mode 100644 hosts/default/disko.nix diff --git a/README.md b/README.md index ec4ac7f..2b9f7c3 100644 --- a/README.md +++ b/README.md @@ -1,121 +1,293 @@ -![](etc/rice_new.png) -![](etc/rice_gentoo.png) +# Kris's Nix -# Keybind reference +You should end up with: -| Keybind | What it does | -| --------- | -------------------- | -| `SUPER+Q` | Terminal | -| `SUPER+C` | Close current window | -| `SUPER+E` | File Manager | -| `SUPER+V` | Toggle Floating | -| `SUPER+Q` | Terminal | -| `SUPER+T` | App Launcher | -| `SUPER+P` | Psuedo | -| `SUPER+J` | Toggle Split | -| `SUPER+F` | Fullscreen | +- NixOS using this repo from `/etc/nixos` +- the automatically-created user `kris` +- the default desktop config from this flake -| Keybind | What it does | -| ------------------ | ------------------ | -| `SUPER+RightArrow` | Move Focus (right) | -| `SUPER+LeftArrow` | Move Focus (left) | -| `SUPER+DownArrow` | Move Focus (down) | -| `SUPER+UpArrow` | Move Focus (up) | +## What This Repo Does -| Keybind | What it does | -| ------------------------ | ------------------ | -| `SUPER+SHIFT+RightArrow` | Window width +100 | -| `SUPER+SHIFT+LeftArrow` | Window width -100 | -| `SUPER+SHIFT+DownArrow` | Window height +100 | -| `SUPER+SHIFT+UpArrow` | Window height -100 | +This repo configures: -| Keybind | What it does | -| ----------------------- | ----------------------- | -| `SUPER+CTRL+RightArrow` | Swap window pos (right) | -| `SUPER+CTRL+LeftArrow` | Swap window pos (left) | -| `SUPER+CTRL+UpArrow` | Swap window pos (down) | -| `SUPER+CTRL+DownArrow` | Swap window pos (up) | +- the default desktop machine +- a separate server host -| Mouse Keybind | What it does | -| ------------------ | -------------- | -| `SUPER+MouseLeft` | Move window | -| `SUPER+MouseRight` | Resize window | -| `SUPER+ScrollUp` | Next workspace | -| `SUPER+ScrollDown` | Prev workspace | +DO NOT use `#server`, this build the server! -| Keybind | What it does | -| ------------------- | ---------------------------------------- | -| `SUPER+[0-9]` | Switch to workspace X | -| `SUPER+SHIFT+[0-9]` | Move active window to workspace X | -| `SUPER+Z` | Special workspace | -| `SUPER+SHIFT+Z` | Move current window to special Workspace | +## Before You Start -| Keybind | What it does | -| --------------- | ---------------- | -| `SUPER+SHIFT+B` | Reload Waybar | -| `CTRL+ALT+DEL` | WLogout | -| `FN+F5` | Prev music track | -| `FN+F6` | Next music track | -| `FN+F7` | Play/Pause music | +You need: -| Keybind | What it does | -| ------------------- | ---------------------------------------------------------------------------------------------------------------- | -| `SUPER+SHIFT+ENTER` | Change wallpaper | -| `SUPER+F1` | Hide waybar | -| `SUPER+F2` | [Roblox](https://roblox.com) [Roblox](https://sober.vinegarhq.org) | -| `SUPER+Space` | Switch Keyboard Layout (English, Latvian) | +- a NixOS installer +- internet access +- your disks partitioned and mounted +- this repo _(`git@tangled.sh:kris.darkworld.download/nix`)_ -## How to install NixOS +## Disk Layout -1. Install base NixOS from the commandline +This repo now uses `disko` for the default desktop host. -- Without UI -- Use this disk configuration +The current declarative layout is: -``` -/dev/sda1 - 1G fat32 fmask=0022 dmask=0022 vfat - mounts to /boot - -# add compress=zstd - -/dev/sdb2 - 100% btrfs, with these subvolumes: - root -> / - [noatime] nix -> /nix - home -> /home - root -> /root +```text +disk = /dev/nvme0n1 +ESP = 2G FAT32 mounted at /boot +root disk = remaining space as btrfs +subvols = /, /home, /nix ``` -2. Create user named `kris` +Mount options are declared in the disko config: -3. Run this in order: +- `/` 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 -cd ~ nix-shell -p git +rm -rf /etc/nixos +git clone git@tangled.sh:kris.darkworld.download/nix /etc/nixos ``` -4. Run this inside the `nix-shell` +### 3. Let disko partition and mount the target disk + +Run: ```bash -git clone git@tangled.sh:kris.darkworld.download/nix /tmp/nix-config -sudo rm -rf /etc/nixos -sudo mv /tmp/nix-config /etc/nixos -cd /etc/nixos -sudo nixos-rebuild switch --flake /etc/nixos#default --cores 20 +nix --extra-experimental-features 'nix-command flakes' run github:nix-community/disko -- --mode destroy,format,mount /etc/nixos#default ``` -1. Reboot, run this in your terminal: +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 ``` -6. Add this to `/etc/resolv.conf` as root +### 11. Restore Quickshell project +This config expects the Deltarune Quickshell project here: + +```text +/home/kris/Projects/DeltaruneQuickshell ``` -nameserver 1.1.1.1 + +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 diff --git a/flake.lock b/flake.lock index e9344e0..7bd2a95 100644 --- a/flake.lock +++ b/flake.lock @@ -123,6 +123,24 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1773889306, + "narHash": "sha256-PAqwnsBSI9SVC2QugvQ3xeYCB0otOwCacB1ueQj2tgw=", + "owner": "nix-community", + "repo": "disko", + "rev": "5ad85c82cc52264f4beddc934ba57f3789f28347", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "fenix": { "inputs": { "nixpkgs": [ @@ -318,7 +336,7 @@ "inputs": { "flake-compat": "flake-compat", "home-manager": "home-manager_2", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "systems": "systems", "zig": "zig", "zon2nix": "zon2nix" @@ -425,7 +443,7 @@ }, "home-manager_3": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1774647770, @@ -819,7 +837,7 @@ "hyprlang": "hyprlang_2", "hyprutils": "hyprutils_2", "hyprwayland-scanner": "hyprwayland-scanner_2", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_6", "systems": "systems_3" }, "locked": { @@ -845,7 +863,7 @@ "hyprutils": "hyprutils_3", "hyprwayland-scanner": "hyprwayland-scanner_3", "hyprwire": "hyprwire_2", - "nixpkgs": "nixpkgs_6", + "nixpkgs": "nixpkgs_7", "systems": "systems_4" }, "locked": { @@ -1334,7 +1352,7 @@ }, "nix-steipete-tools": { "inputs": { - "nixpkgs": "nixpkgs_9" + "nixpkgs": "nixpkgs_10" }, "locked": { "lastModified": 1773561580, @@ -1383,6 +1401,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1767364772, + "narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1767767207, "narHash": "sha256-Mj3d3PfwltLmukFal5i3fFt27L6NiKXdBezC1EBuZs4=", @@ -1398,7 +1432,7 @@ "type": "github" } }, - "nixpkgs_11": { + "nixpkgs_12": { "locked": { "lastModified": 1771848320, "narHash": "sha256-0MAd+0mun3K/Ns8JATeHT1sX28faLII5hVLq0L3BdZU=", @@ -1414,7 +1448,7 @@ "type": "github" } }, - "nixpkgs_12": { + "nixpkgs_13": { "locked": { "lastModified": 1682134069, "narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=", @@ -1428,7 +1462,7 @@ "type": "indirect" } }, - "nixpkgs_13": { + "nixpkgs_14": { "locked": { "lastModified": 1771419570, "narHash": "sha256-bxAlQgre3pcQcaRUm/8A0v/X8d2nhfraWSFqVmMcBcU=", @@ -1444,7 +1478,7 @@ "type": "github" } }, - "nixpkgs_14": { + "nixpkgs_15": { "locked": { "lastModified": 1773389992, "narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=", @@ -1477,6 +1511,22 @@ } }, "nixpkgs_3": { + "locked": { + "lastModified": 1773628058, + "narHash": "sha256-hpXH0z3K9xv0fHaje136KY872VT2T5uwxtezlAskQgY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f8573b9c935cfaa162dd62cc9e75ae2db86f85df", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1770537093, "narHash": "sha256-XV30uo8tXuxdzuV8l3sojmlPRLd/8tpMsOp4lNzLGUo=", @@ -1489,7 +1539,7 @@ "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1774106199, "narHash": "sha256-US5Tda2sKmjrg2lNHQL3jRQ6p96cgfWh3J1QBliQ8Ws=", @@ -1505,22 +1555,6 @@ "type": "github" } }, - "nixpkgs_5": { - "locked": { - "lastModified": 1772433332, - "narHash": "sha256-izhTDFKsg6KeVBxJS9EblGeQ8y+O8eCa6RcW874vxEc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "cf59864ef8aa2e178cccedbe2c178185b0365705", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_6": { "locked": { "lastModified": 1772433332, @@ -1539,15 +1573,15 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1774386573, - "narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=", - "owner": "nixos", + "lastModified": 1772433332, + "narHash": "sha256-izhTDFKsg6KeVBxJS9EblGeQ8y+O8eCa6RcW874vxEc=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9", + "rev": "cf59864ef8aa2e178cccedbe2c178185b0365705", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" @@ -1571,16 +1605,16 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1767364772, - "narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=", - "owner": "NixOS", + "lastModified": 1774386573, + "narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa", + "rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", + "owner": "nixos", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } @@ -1591,7 +1625,7 @@ "flake-parts": "flake-parts", "mnw": "mnw", "ndg": "ndg", - "nixpkgs": "nixpkgs_8", + "nixpkgs": "nixpkgs_9", "systems": "systems_5" }, "locked": { @@ -1613,7 +1647,7 @@ "flake-utils": "flake-utils", "home-manager": "home-manager_4", "nix-steipete-tools": "nix-steipete-tools", - "nixpkgs": "nixpkgs_10" + "nixpkgs": "nixpkgs_11" }, "locked": { "lastModified": 1773851886, @@ -1681,6 +1715,7 @@ "inputs": { "catppuccin": "catppuccin", "chaotic": "chaotic", + "disko": "disko", "ghostty": "ghostty", "home-manager": "home-manager_3", "hyprland": "hyprland", @@ -1688,7 +1723,7 @@ "hyprsysteminfo": "hyprsysteminfo", "nix-flatpak": "nix-flatpak", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_7", + "nixpkgs": "nixpkgs_8", "nvf": "nvf", "openclaw": "openclaw", "spacebar": "spacebar", @@ -1920,7 +1955,7 @@ "inter-fonts-src": "inter-fonts-src", "lucide-src": "lucide-src", "mermaid-src": "mermaid-src", - "nixpkgs": "nixpkgs_11", + "nixpkgs": "nixpkgs_12", "sqlite-lib-src": "sqlite-lib-src" }, "locked": { @@ -1940,7 +1975,7 @@ "vscode-server": { "inputs": { "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_12" + "nixpkgs": "nixpkgs_13" }, "locked": { "lastModified": 1770124655, @@ -1958,7 +1993,7 @@ }, "wafrn": { "inputs": { - "nixpkgs": "nixpkgs_13", + "nixpkgs": "nixpkgs_14", "wafrn-src": "wafrn-src" }, "locked": { @@ -2036,7 +2071,7 @@ "zen-browser": { "inputs": { "home-manager": "home-manager_5", - "nixpkgs": "nixpkgs_14" + "nixpkgs": "nixpkgs_15" }, "locked": { "lastModified": 1774605342, diff --git a/flake.nix b/flake.nix index c64d52f..bacd54b 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,7 @@ zen-browser.url = "github:0xc000022070/zen-browser-flake"; # Package tooling + disko.url = "github:nix-community/disko"; chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.4.1"; nvf.url = "github:notashelf/nvf"; @@ -43,11 +44,13 @@ }; modules = [ inputs.home-manager.nixosModules.default + inputs.disko.nixosModules.disko inputs.catppuccin.nixosModules.catppuccin inputs.nix-flatpak.nixosModules.nix-flatpak inputs.chaotic.nixosModules.nyx-cache inputs.chaotic.nixosModules.nyx-overlay inputs.chaotic.nixosModules.nyx-registry + ./hosts/default/disko.nix "/etc/nixos/hardware-configuration.nix" ./hosts/default/configuration.nix ]; diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix index f761a59..045a357 100644 --- a/hosts/default/configuration.nix +++ b/hosts/default/configuration.nix @@ -151,12 +151,6 @@ in { environment.variables.GTK_USE_PORTAL = "1"; environment.sessionVariables.GTK_USE_PORTAL = 1; - fileSystems = { - "/".options = [ "compress=zstd" ]; - "/home".options = [ "compress=zstd" ]; - "/nix".options = [ "compress=zstd" "noatime" ]; - }; - services.btrfs.autoScrub = { enable = true; interval = "monthly"; diff --git a/hosts/default/disko.nix b/hosts/default/disko.nix new file mode 100644 index 0000000..91d3582 --- /dev/null +++ b/hosts/default/disko.nix @@ -0,0 +1,57 @@ +{ lib, ... }: + +{ + disko.devices = { + disk.main = { + type = "disk"; + device = lib.mkDefault "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "fmask=0022" + "dmask=0022" + ]; + }; + }; + + nixos = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ + "-f" + "-L" + "NixOS" + ]; + subvolumes = { + "@root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" ]; + }; + "@home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" ]; + }; + "@nix" = { + mountpoint = "/nix"; + mountOptions = [ + "compress=zstd" + "noatime" + ]; + }; + }; + }; + }; + }; + }; + }; + }; +}