Skip to content

About

I use nix btw

Resources

Stars

22 stars

Watchers

0 watching

Forks

Latest commit

 

History

525 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nix-config

A cross-machine, cross-OS Nix flake configuration for NixOS and macOS (nix-darwin), managing packages, dotfiles and system settings for a single user across multiple hosts.

Built around the Dendritic Pattern.


The Dendritic Pattern

This repository follows the Dendritic Pattern: configuration files (except the entry points flake.nix and host default.nix files) are flake-parts modules. Modules are organised by feature and hardware, not by host or configuration class, while reusable package and overlay helpers live under modules/software/. A single feature or hardware file can cover NixOS system config, nix-darwin system config and Home Manager config all in one place.

New files directly under modules/features/ are reserved for broad, cohesive capability categories, not individual apps or tools. Add app/tool configuration to an existing category first (such as communication, coding, gaming, or music), use modules/hardware/ for device-specific configuration, and use modules/software/ for package/overlay helpers. Create a feature file only when no existing category fits and it forms a genuinely distinct, reusable capability category. This convention applies to new work; existing legacy files do not all need to be reorganized.

# modules/features/terminal.nix — one file owns everything "terminal" touches
{
  flake.modules.nixos.terminal     = { ... };   # system-level (NixOS)
  flake.modules.darwin.terminal    = { ... };   # system-level (macOS)
  flake.modules.homeManager.terminal = { ... }; # user-level (both platforms)
}

import-tree auto-imports module .nix files under modules/, so dropping a new module in is enough — no manual registration in flake.nix needed. Raw package and overlay helpers imported by other files begin with _ so they are not auto-imported.

Why this pattern?

  • Locality - all config for a feature lives in one file.
  • No specialArgs pass-thru - values are shared through the top-level config attrset instead of being threaded through specialArgs/extraSpecialArgs.
  • Free file paths - files can be renamed, moved, or split without breaking anything. The path is just a name.
  • Automatic importing - any module file added under modules/ is picked up immediately; underscore-prefixed raw helpers are imported explicitly.

Sources & further reading


Folder Architecture

NixConfig/
├── flake.nix                        # Entry point — delegates to flake-parts via import-tree
├── flake.lock                       # Pinned input revisions
│
├── modules/                         # All Nix configuration logic (auto-imported by import-tree)
│   ├── flake-modules.nix            # Registers flake-parts + home-manager flake modules
│   ├── helpers.nix                  # Global options: username, supported systems, path helpers
│   ├── features/                    # Feature modules — one file per capability
│   ├── hardware/                    # Hardware-specific modules (graphics, RODECaster)
│   ├── software/                    # Reusable package/overlay helpers; raw files start with _
│   ├── hosts/
│   │   ├── nixstation/              # Primary Linux host (fully configured)
│   │   │   ├── default.nix          # Assembles nixosConfiguration from feature modules
│   │   │   ├── configuration.nix    # Boot, networking, display manager, users, locale
│   │   │   └── hardware-configuration.nix  # Filesystems, Bluetooth, AMD CPU
│   │   ├── macbook/
│   │   │   ├── default.nix          # Personal macOS host (nix-darwin + Homebrew)
│   │   │   └── configuration.nix    # macOS system settings, apps, Homebrew config
│   │   ├── macbook-cookunity/
│   │   │   ├── default.nix          # Work macOS host (nix-darwin + Homebrew)
│   │   │   └── configuration.nix    # macOS system settings, apps, Homebrew config
│   │   └── studio/
│   │       ├── default.nix          # Studio macOS host (nix-darwin)
│   │       └── configuration.nix    # macOS system settings
│   └── users/
│       └── christopher.nix          # Minimal Home Manager base: username + stateVersion
└── assets/                          # Static files symlinked into $HOME at activation time

Key design decisions

Decision Rationale
config.flake.username Username is declared once in helpers.nix, never hardcoded elsewhere
helpers.mkAssetsPath Returns a Nix store path to assets/<path> — used at eval time
helpers.mkAssetsStringPath Returns a string ~/nix-config/assets/<path> — used for live symlinks that must not enter the store
helpers.mkConfigPath / mkHomePath All ~/.config/ and ~/ paths go through helpers; no raw string paths scattered around
helpers.mkHybrid Wraps a Home Manager module to conditionally apply config per platform (Linux vs. macOS)
mkOutOfStoreSymlink for assets/nvim/ Neovim config edits take effect immediately without a rebuild
Proton Pass secret pipeline env.template + secure-env-refresh.sh + systemd service — secrets never touch the Nix store

Hosts

Host Platform Status Description
nixstation x86_64-linux Active Main Linux desktop — AMD, Niri, DankMaterialShell
macbook aarch64-darwin Active Personal MacBook — nix-darwin + Homebrew
macbook-cookunity aarch64-darwin Active Work MacBook — nix-darwin + Homebrew
studio aarch64-darwin Active Studio Mac — nix-darwin

Getting Started

Validate (no build)

nix flake check

Build without applying

nix build .#nixosConfigurations.nixstation.config.system.build.toplevel

Dry-run (build without activating)

sudo nixos-rebuild dry-activate --flake .#nixstation

Apply — Linux

sudo nixos-rebuild switch --flake .#nixstation

One-time setup — make switch work without --flake

nixos-rebuild only auto-detects this flake if /etc/nixos/flake.nix exists. Create it as a symlink to the repo (this is why the switch alias is just sudo nixos-rebuild switch):

sudo ln -sfn /home/christopher/nix-config/flake.nix /etc/nixos/flake.nix

With that in place, nixos-rebuild resolves the symlink, uses its parent directory as the flake path, and picks nixosConfigurations.nixstation from the hostname. Without it, plain switch fails with file 'nixos-config' was not found in the Nix search path. The symlink lives in /etc/nixos, a mutable directory NixOS leaves alone, so it survives every rebuild.

Apply — macOS

darwin-rebuild switch --flake .#macbook
# or using the shell alias:
switch

Update all inputs

nix flake update

Update a single input

nix flake update nixpkgs

Format all Nix files

nixfmt **/*.nix

Tools configuration

Howdy

For adding a face for howdy, run:

sudo howdy add

Ankama Launcher

The launcher (pkgs.ankama-launcher) is pinned in nixpkgs to a Wayback Machine snapshot of the official AppImage. The overlay in modules/software/_ankama-launcher-overlay.nix additionally disables its built-in auto-updater (it crashes on NixOS — it only works when running as a real AppImage), so launcher updates always come from the package, never from the app itself.

To update to a newer launcher version:

  1. Check the latest upstream version:
    curl -s https://launcher.cdn.ankama.com/installers/production/latest-linux.yml | head -1
  2. Update the nixpkgs pin — the package is usually bumped within days of a release:
    nix flake update nixpkgs
  3. If nixpkgs hasn't caught up yet, bump it manually in modules/software/_ankama-launcher-overlay.nix:
    • Create a snapshot of https://launcher.cdn.ankama.com/installers/production/Ankama%20Launcher-Setup-x86_64.AppImage on web.archive.org — don't use the CDN URL directly, it is not versioned and breaks on every upstream release.
    • In the overlay, replace inherit (prev.ankama-launcher) pname version src; with an explicit pname, version and src = fetchurl { url = "<snapshot-url>"; hash = "<hash>"; };
    • Get the hash with:
      nix store prefetch-file --hash-type sha256 "<snapshot-url>"
  4. Apply the update:
    sudo nixos-rebuild switch --flake .#nixstation

Note: if Ankama ever changes the auto-updater config key, the build fails loudly with updater feed URL not found in app.asar — adjust the postExtract patch in modules/software/_ankama-launcher-overlay.nix accordingly (the replacement string must stay the exact same byte length).

About

I use nix btw

Resources

Stars

22 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages