* refactor(kubevirt): drop the static 1G hugetlb pool, use THP on demand The hosts pre-reserved 48/48/15 GiB of 1G hugepages, but the VMs only used 32/16/11 GiB, so ~52 GiB was stranded (hugetlb is exclusive and cannot be overcommitted or shared with the host / non-hugepage VMs). It also blocked scheduling (a 16 GiB hugepage VM cannot fit on a host with fewer free pages, e.g. youko with 15/24 GiB) and made the full intended VM set (idols 3x8G + k3s-test 3x16G + k3s-prod 3x4G + 3x16G = 132 GiB vs 146 GiB physical) impossible to fit. Use transparent huge pages on demand (madvise) instead, and let the VMs use ordinary memory (instancetypes updated in k8s-gitops). This frees the stranded memory, removes the scheduling rigidity, and makes overcommit/swap usable again. * feat(kubevirt): add earlyoom; stop overriding swappiness (zram already enabled) zram is already provided by modules/nixos/base/zram.nix (enabled by default: 50% RAM, zstd, prio 100 + swappiness/watermark tunings). But genKubeVirtHostModule hard-coded vm.swappiness = 0, which overrode the modules mkDefault 180 and disabled swapping entirely - so the zram device was never used (Swap used: 0B). - Remove the hard-coded vm.swappiness (let the zram modules tuning apply); the disk swapfile from disko stays as the last resort. - Add services.earlyoom to kill the greediest process before the host thrashes / OOMs.
❄️ Ryan4Yin's Nix Config ❄️
My configuration is becoming more and more complex, and it will be difficult for beginners to read. If you are new to NixOS and want to know how I use NixOS, I would recommend you to take a look at the ryan4yin/nix-config/releases first, check out to some simpler older versions, such as i3-kickstarter, which will be much easier to understand.
This repository is home to the Nix code that builds all of my systems:
- NixOS desktops — Home Manager, Niri (Wayland), the Noctalia shell, agenix.
- macOS desktops — nix-darwin + Home Manager, sharing the same
home/configuration with the NixOS desktops. - NixOS servers — KubeVirt VMs running on three physical mini PCs, hosting K3s clusters, monitoring, and other self-hosted services.
See ./hosts for the host inventory, ./outputs for how the flake outputs are composed, ./Virtual-Machine.md for creating & managing KubeVirt VMs, and ./AGENTS.md for the repository conventions.
Why NixOS & Flakes?
Nix allows for easy-to-manage, collaborative, reproducible deployments. This means that once something is setup and configured once, it works (almost) forever. If someone else shares their configuration, anyone else can just use it (if you really understand what you're copying/referring now).
As for Flakes, refer to Introduction to Flakes - NixOS & Nix Flakes Book
Want to know NixOS & Flakes in detail? Looking for a beginner-friendly tutorial or best practices? You don't have to go through the pain I've experienced again! Check out my NixOS & Nix Flakes Book - 🛠️ ❤️ An unofficial & opinionated 📖 for beginners!
If you're using macOS, check out ryan4yin/nix-darwin-kickstarter for a quick start.
Components
| NixOS (Wayland) | |
|---|---|
| Display Manager | greetd + tuigreet |
| Window Manager | Niri |
| Desktop Shell | Noctalia — bar/notifications/launcher/lock screen/control center/power menu/screenshots, one native shell |
| Terminal Emulators | foot, Kitty, Alacritty, Ghostty |
| Terminal Multiplexer | Zellij |
| Shell | Nushell + Starship |
| Editors / IDE | Zed (GUI, primary), VS Code (GUI); Helix (TUI, primary), Neovim (TUI, backup) |
| Color Scheme | catppuccin-nix |
| Networking | systemd-networkd / NetworkManager |
| Input Method | Fcitx5 + rime + 小鹤音形 flypy |
| System Monitor | Btop (+ Noctalia's built-in sysmon widgets) |
| File Manager | Yazi (TUI) + thunar (GUI) |
| Media Player | mpv |
| Image Viewer | imv |
| Screenshots | Native Noctalia capture: region / fullscreen / display picker, with a built-in annotation editor |
| Screen Recording | OBS, gpu-screen-recorder, wf-recorder |
| Fonts | Nerd fonts |
| Filesystem & Encryption | tmpfs as /, Btrfs subvolumes on a LUKS encrypted partition for persistent data; unlock via passphrase |
| Secure Boot | lanzaboote |
Wallpapers: https://github.com/ryan4yin/wallpapers
Screenshots
Editors / IDE
- Terminal editors: ./home/base/core/editors/ — Helix / Neovim,
$EDITOR, docs. - GUI editors: Zed (primary) and VS Code.
- LLM coding agents: ./agents — rules, installers, CLI snippets; see ./agents/README.md.
Secrets Management
See ./secrets for details.
How to Deploy this Flake?
🔴 IMPORTANT: You should NOT deploy this flake directly on your machine ❗ It will not succeed. This flake contains my hardware configuration (such as hardware-configuration.nix, Nvidia support, etc.) which is not suitable for your hardware, and requires my private secrets repository ryan4yin/nix-secrets to deploy. You may use this repo as a reference to build your own configuration.
Run just --list to see every recipe.
For NixOS:
To deploy this flake from NixOS's official ISO image (purest installation method), please refer to ./nixos-installer/
# Desktops: deploy the <hostname>-niri nixosConfiguration (e.g. ai-niri, shoukei-niri)
just niri # equals `sudo nixos-rebuild switch --flake .#<hostname>-niri`
just niri boot # set as the next boot configuration without switching
just niri switch debug # detailed output
# Other hosts (servers, VMs): deploy the nixosConfiguration matching the bare hostname
just local
just local boot
just local switch debug
For macOS (nix-darwin):
# If you are deploying for the first time,
# 1. install nix & homebrew manually.
# 2. prepare the deployment environment with essential packages available
nix-shell -p just nushell
# 3. comment home-manager's code in lib/macosSystem.nix to speed up the first deployment.
# 4. comment out the proxy settings in scripts/darwin_set_proxy.py if the proxy is not ready yet.
# Deploy the darwinConfiguration by hostname match (fern, frieren)
just local
just local debug # detailed output (macOS has no switch/boot mode)
Remote / cluster hosts are deployed with Colmena on top of
the same flake, e.g. just col <tag>, just k3s-prod, just lab.
What y'all will need when Nix drives you to drink. (copy from hlissner's dotfiles, it really matches my feelings when I first started using NixOS...)
Validation & Development
nix develop provides the formatters and linters used by the repository. The most useful commands:
just test # eval tests across Linux & Darwin; the output must be `true`
just fmt # format all Nix files with nixfmt
just --list # all recipes
nix flake check # broader flake checks
For Nix changes, run just test and inspect just fmt's diff before committing. Non-Nix files are
formatted with prettier; spelling is checked with typos.
References
Other dotfiles that inspired me:
- Nix Flakes
- NixOS-CN/NixOS-CN-telegram
- notusknot/dotfiles-nix
- xddxdd/nixos-config
- bobbbay/dotfiles
- gytis-ivaskevicius/nixfiles
- davidtwco/veritas
- gvolpe/nix-config
- Ruixi-rebirth/flakes
- fufexan/dotfiles: gtk theme, xdg, git, media, etc.
- nix-community/srvos: a collection of opinionated and sharable NixOS configurations for servers
- Modularized NixOS Configuration
- Neovim / AstroNvim
- maxbrunet/dotfiles: astronvim with nix flakes.
- Misc



