-
Notifications
You must be signed in to change notification settings - Fork 0
NullOS Architecture
This document provides a technical deep dive into how NullOS is structured behind the scenes, specifically covering the configuration pipeline, custom derivations, and injected shell scripts.
NullOS heavily relies on a 3-stage feature flag pipeline evaluated in flake.nix (lines 58-100). This replaces the traditional monolithic variables.nix and provides a highly modular and reusable way to define machines.
-
Base Defaults (
machines/profiles/base.nix): Defines over 70 baseline variables and feature flags (e.g.,enableSteam,enableDocker,desktopEnvironment). To keep the system minimal, almost all non-essential features are set tofalseby default. -
Profile Overrides (
machines/profiles/<profile>.nix): When defining a machine inflake.nix, a profile (likepcorserver) is passed. This applies a set of overrides suitable for that class of machine. For example,pc.nixwill typically enableenableSteam,enableLutris, and setdesktopEnvironment = "hyprland", whileserver.nixkeeps the GUI disabled. -
Machine Overrides (
machines/<hostname>/default.nix): This file provides the final layer of configuration. Variables defined here take highest precedence (e.g., setting thehostname,username, and specificuseNvidiaPrimetoggles).
The Quirky Magic of extraNixosConfig:
When the machine's default.nix is evaluated, any key that isn't explicitly reserved as a feature flag in the base definitions is automatically bundled into a property called extraNixosConfig. This enables you to write raw, arbitrary NixOS configuration directly inside the machine's variables file without creating a new module for one-off tweaks.
NullOS handles custom packages directly within the flake.nix overlay rather than utilizing standalone derivations inside the packages/ directory.
Several flake inputs are directly exposed to the system pkgs via the final: prev: overlay pattern:
-
stable: Exposes thenixpkgs-stablebranch (pkgs.stable), allowing stable applications to be pulled into an otherwise unstable environment. -
fusion360: Exposes thefusion360derivation from a custom GitHub flake. -
hyprland&xdg-desktop-portal-hyprland: Completely replaces the default nixpkgs Hyprland builds with the bleeding-edge flake input versions. -
dolphin-overlay: Applies custom patches to the Dolphin file manager.
The overlay modifies several existing packages:
-
ananicy-rules-cachyos: Bumped to version1.1.38directly from GitHub source. -
picosvg(Python): Overridden to disable tests during the build (doCheck = false). -
openldap: Overridden to skip tests during the build phase (doCheck = false).
NullOS injects several custom shell scripts as packages via pkgs.writeShellScriptBin. These are managed by Home Manager and are crucial for the desktop experience:
| Script Name | Purpose |
|---|---|
wallsetter |
A daemon that cycles desktop wallpapers every 12 minutes. Uses awww for transitions. Ensures no duplicate consecutive wallpapers are selected. |
list-keybinds |
Parses hyprland.conf, replaces raw modifier names with SUPER, and displays all available keybindings via a searchable rofi menu. |
rofi-launcher |
A smart toggle script for the app launcher. Checks if rofi is running; if it is, it kills it. Otherwise, it launches rofi -show drun. |
screenshotin |
Interactive screenshot utility. Utilizes slurp for region selection, grim to capture the region, and immediately pipes to swappy for annotation. |
screenshot-ocr |
OCR utility for screenshots. Uses grim/slurp, passes the image to tesseract for text extraction, and pipes the result to wl-copy (clipboard). |