Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Overview

othrys.nix is a public NixOS module library built with flake-parts. It exports reusable modules under the othrys.* namespace; host configurations live in a separate private fleet flake that consumes this one as an input (see Host Configuration).

Repository Structure

flake.nix                    # Flake entrypoint (no hosts, no secrets)
flake/                       # Flake-parts modules
  ├── modules.nix            # Exported nixosModules (incl. aggregates `default` and `full`)
  ├── templates.nix          # `nix flake init` starting points
  ├── packages.nix           # Packaged scripts and tools
  ├── dev-shells.nix         # Development environments
  ├── treefmt.nix            # Multi-language formatter (nix fmt)
  ├── docs-options.nix       # Generated othrys.* options reference
  └── checks/                # Flake checks, with each VM test and read-back in its own file
modules/                     # Reusable NixOS modules (othrys.* namespace)
  ├── system/                # System fundamentals
  │   ├── user.nix           # Primary user identity option
  │   ├── users.nix          # User options and the Home Manager registry
  │   ├── users.nixos.nix    # The account, shell and essential packages
  │   ├── home.nix           # Home Manager adapter, a separate export
  │   ├── locale.nix         # Locale, timezone, console
  │   ├── nix.nix            # Nix daemon, substituters, GC
  │   ├── kernel.nix         # Kernel selection
  │   ├── hardening.nix      # Opt-in kernel and sysctl hardening
  │   ├── networking.nix     # systemd-networkd interfaces, bridges, VLANs
  │   ├── auto-upgrade.nix   # Unattended upgrades with signature verification
  │   ├── bootloader.nix     # Bootloader + Secure Boot
  │   ├── disko.nix          # Disk layout, exported on its own
  │   ├── ephemeral-root.nix # Ephemeral root wipe
  │   ├── impermanence.nix   # Impermanence adapter, a separate export
  │   ├── persistence.nix    # Persistence registry, also declared on darwin
  │   ├── persistence.nixos.nix # The system-critical set
  │   ├── secrets.nix        # Secrets options and what both platforms write
  │   ├── secrets.nixos.nix  # sops-nix plumbing, exported on its own
  │   ├── secrets.darwin.nix # sops-nix plumbing for darwin
  │   ├── git.nix            # Git configuration
  │   └── shell/             # Shell (Zsh, Bash, Starship)
  ├── theme/                 # The theme every module reads
  │   ├── default.nix        # othrys.theme: palette, fonts, opacity, wallpaper
  │   ├── schemes/           # Colour schemes as Nix data
  │   ├── stylix.nix         # Stylix adapter options and shared writes
  │   ├── stylix.nixos.nix   # Stylix adapter, exported on its own
  │   └── stylix.darwin.nix  # Stylix adapter for darwin
  ├── desktop/               # Desktop environment
  │   ├── compositors/       # Hyprland, Niri
  │   ├── ashell/            # Status bar
  │   ├── login.nix          # greetd login manager
  │   ├── idle.nix           # Staged idle policy
  │   ├── keyring.nix        # Secret Service provider
  │   ├── night-light.nix    # Color temperature shifting
  │   ├── uwsm.nix           # Session management
  │   └── wallpaper.nix      # Wallpaper daemon
  ├── hardware/              # Hardware
  │   ├── audio.nix          # PipeWire audio
  │   ├── webcam.nix         # Webcam support
  │   ├── scanner.nix        # SANE scanning
  │   ├── smart.nix          # Disk health monitoring
  │   ├── ups.nix            # UPS monitoring (NUT)
  │   ├── usb.nix            # USB utilities
  │   ├── graphics/          # NVIDIA, PRIME offload, shader cache
  │   ├── laptop/            # Laptop features + specific models
  │   └── wireless/          # Bluetooth, WiFi
  ├── services/              # Services
  │   ├── security/          # Sudo, Polkit, YubiKey, fail2ban, CrowdSec
  │   ├── containerization/  # Podman, Docker, k3s
  │   ├── mounts/            # Disk and CIFS mounts
  │   └── *.nix              # SSH, Tailscale, router, Traefik, monitoring, etc.
  ├── apps/                  # Applications
  │   ├── cli/               # nixvim, ai (claude-code, ollama, mcp), gh, yazi, ...
  │   ├── gui/               # floorp, ghostty, gaming/, vscode, ...
  │   └── languages/         # Per-language toolchains shared by both editors
  └── lib/                   # Shared option types, address helpers, the systemd sandbox baseline, the sshd settings
templates/                   # The `nix flake init` templates, default and darwin
scripts/                     # Operational scripts
  └── yubikey-onboard.sh     # YubiKey provisioning (PGP, U2F, age)
docs/                        # This book

The consuming fleet flake holds everything machine- or person-specific: host configurations, shared profiles, fleet data (SSH host maps, cache keys, YubiKey identities), and the private secrets input.

Flake Inputs

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    # Flake framework for modular configuration
    flake-parts = {
      url = "github:hercules-ci/flake-parts";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # nix-darwin, the module system a macOS host is built with. The darwin
    # exports are written against it, and the darwin host checks evaluate
    # with its darwinSystem.
    nix-darwin = {
      url = "github:nix-darwin/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    hyprland = {
      # Deliberately does not follow nixpkgs, for cache hits rather than for
      # any build failure. Upstream builds against its own pin, so
      # hyprland.cachix.org serves the exact derivations this flake asks for.
      # Adding `follows` while still reading inputs.hyprland.packages changes
      # those hashes and puts every consumer on a source build, which is the
      # one combination to avoid.
      #
      # nixpkgs carries hyprland too, so defaulting to pkgs.hyprland with
      # mkDefault (what the niri module does) is viable and would drop the
      # second nixpkgs this input costs. Left alone because no check here can
      # prove a packaging swap leaves a live session behaving the same.
      url = "github:hyprwm/Hyprland";
      # Only upstream's own checks and dev shell read this, so following ours
      # leaves the package hashes alone and drops a second copy from the lock.
      inputs.pre-commit-hooks.follows = "git-hooks";
    };

    ashell = {
      url = "github:MalpenZibo/ashell";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Packages for AI agents and their desktop clients, the default of the
    # package options of the claude-code, codex, claude-desktop and orca
    # modules. Like hyprland it does not follow nixpkgs. Upstream builds and
    # tests against its own pin, and cache.numtide.com serves those exact
    # derivations, so following ours would put every consumer on a local
    # build of each package.
    llm-agents = {
      url = "github:numtide/llm-agents.nix";
      # Only upstream's own outputs and checks read these, so following ours
      # leaves the package hashes alone and drops a copy from the lock.
      inputs.flake-parts.follows = "flake-parts";
      inputs.treefmt-nix.follows = "treefmt-nix";
    };

    # The Paseo plugin that loads each agent's direnv environment, the
    # default of othrys.apps.ai.paseo.direnv.package. Its package is the
    # plugin's TypeScript source, which Paseo compiles when it loads it, so
    # following our nixpkgs costs no cache hit. Only a host with Paseo and
    # its direnv option on reads it, and no other host fetches it.
    paseo-direnv = {
      url = "github:MatthewDeSouza/paseo-direnv";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Niri compositor, packages plus the typed programs.niri.settings module
    # (build-time-validated KDL config). Self-contained, since the compositor
    # module imports its NixOS module directly, and its auto-cache is disabled in
    # favor of the curated substituter list in othrys.system.nix.
    niri = {
      url = "github:sodiboo/niri-flake";
      inputs.nixpkgs.follows = "nixpkgs";
      # niri-flake builds its own niri-stable package against nixpkgs-stable.
      # The compositor module takes niri from pkgs and never reads that
      # package, so the second nixpkgs follows ours and leaves the lock.
      inputs.nixpkgs-stable.follows = "nixpkgs";
    };

    # Declarative disk partitioning
    disko = {
      url = "github:nix-community/disko";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # NixOS-WSL, the module a host running as a WSL distro is built with,
    # written into by the optional nixosModules.wsl export. Its flake-compat
    # input is a plain source tree that no output reads.
    nixos-wsl = {
      url = "github:nix-community/NixOS-WSL";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Nix-index database, a prebuilt index for comma and nix-locate
    nix-index-database = {
      url = "github:nix-community/nix-index-database";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Impermanence, opt-in state persistence
    impermanence = {
      url = "github:nix-community/impermanence";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };

    # Nixvim - Neovim configuration with Nix modules
    nixvim = {
      url = "github:nix-community/nixvim";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-parts.follows = "flake-parts";
    };

    # Stylix - System-wide theming using base16
    stylix = {
      url = "github:nix-community/stylix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-parts.follows = "flake-parts";
    };

    # Git hooks for pre-commit validation
    git-hooks = {
      url = "github:cachix/git-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Multi-language formatting (drives `nix fmt` + the treefmt pre-commit hook)
    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Secrets management with age encryption
    sops-nix = {
      url = "github:Mic92/sops-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Lanzaboote, Secure Boot for systemd-boot. Pinned to a release tag, which
    # is what upstream asks consumers to track. No module imports it. It is
    # here so flake/checks can evaluate the systemd-boot Secure Boot path, and
    # a consumer who wants that path imports the module from their own input.
    lanzaboote = {
      url = "github:nix-community/lanzaboote/v1.1.0";
      inputs.nixpkgs.follows = "nixpkgs";
      # Upstream names this input after the repository's former name. It is
      # the project this flake carries as git-hooks.
      inputs.pre-commit.follows = "git-hooks";
      # crane and rust-overlay stay unfollowed. This flake declares neither,
      # and the copies ashell brings are pinned for ashell's toolchain rather
      # than for the lzbt build.
    };
  };

Flake Imports

      imports = [
        inputs.treefmt-nix.flakeModule
        # flake.modules.<class>.<name>, the output the darwin modules publish
        # under. flake-parts declares no darwinModules option.
        inputs.flake-parts.flakeModules.modules

        ./flake/modules.nix # Exported nixosModules
        ./flake/templates.nix # `nix flake init` starting points
        ./flake/packages.nix # Packaged scripts and tools
        ./flake/dev-shells.nix # Development environments
        ./flake/treefmt.nix # Multi-language formatter (nix fmt)
        ./flake/docs-options.nix # Generated othrys.* options reference
        ./flake/checks # CI/CD checks
      ];