- Nix 97.5%
- Shell 2.5%
| .github/workflows | ||
| .secrets | ||
| .tack | ||
| aspects | ||
| .gitignore | ||
| .sops.yaml | ||
| AGENTS.md | ||
| flake.nix | ||
| justfile | ||
| README.md | ||
My NixOS Config
This is my personal NixOS setup, and it's kind of grown into its own little flake
framework. Instead of pulling in flake-parts, flake-file, wrapper-modules, stylix, base16.nix,
and a pile of other helpers, it reimplements the pieces I actually use with lib and nixpkgs.
I did this to:
- Learn more about NixOS and the Nix expression language.
- Have exactly the features I desire and nothing more.
- Make each abstraction (hopefully) small enough to read in one sitting.
Design Philosophy
Self-reliance
The interesting machinery is built from lib and nixpkgs — no
flake-parts, no flake-utils, no stylix, no base16.nix. Fewer moving parts means fewer
inputs to pin, fewer upgrade cliffs, and fewer uncontrolled abstractions.
Every abstraction is small enough to audit
The perSystem layer is a couple hundred lines. mkScheme is ~100. The
package wrapper is one runCommand. Each one replaces a third-party tool with a
deliberately narrow reimplementation, so understanding the repo doesn't require
understanding a framework first.
Everything is a module
The flake top level, every perSystem fragment, every wrapped package,
and each host config are all evaluated as modules
with typed options. The schemas document themselves, and composition happens through
deferred modules instead of hand-rolled merging.
Pins are data, not flake inputs
Tack replaces inputs with a declarative, signed, patchable pins.toml.
tack.nix exposes that file as top-level nix options and generates it, ala flake-file.
Dependencies show up in a reviewable diff instead of hiding in a flake.lock.
Compose hosts from modules, not one giant config
A host declares its user, state version, colorscheme, hardware profile, and which
modules it wants. Modules organize themselves into core, host, hardware, or
a named module within modules, and configurations.nix assembles the final
nixosSystemMinimal.
Areas of interest
If you're here to get ideas, these are worth reading:
| # | Area | What it is |
|---|---|---|
| 1 | A hand-rolled perSystem |
flake-parts' per-system abstraction, rebuilt from scratch |
| 2 | Tack inputs, not flake inputs | a flake-file-style interface that generates pins.toml |
| 3 | The package wrapper | an option-driven wrapPackage on top of makeWrapper |
| 4 | Lib-only colorschemes | a base16/24 engine with zero nixpkgs imports |
| 5 | Composable host configurations | bucket-based module composition for hosts |
A hand-rolled perSystem
file:
flake.nix
This is the part that replaces flake-parts perSystem. It runs two evalModules passes: the first
evaluates the top-level ./aspects tree (flake-level options, tack pins, schemes), and
the second re-runs one perSystem module once per system with extra arguments.
The glue is a handful of small helpers:
systemInputnarrows a flake-shaped input to a single system, dropping the system layer soinputs'.foo.packages.barmeansinputs.foo.packages.${system}.bar.withSystembuilds the per-system argument bundle:pkgs,inputs',self',packages',meta,system,rootPath.packages'is a convenience layer that pickspackages.default, falls back to a package named after the input, then merges everything into one set.- output transposition flips
system -> category -> derivationinto thecategory -> system -> derivationshape flake outputs expect.
The result is a flake that still looks normal from the outside (packages.x86_64-linux.*,
nixosConfigurations.*) but gives every module the same ergonomic arguments
flake-parts users get, then extends those further.
Composable host configurations
Hosts are declared as submodules, so modules.configurations.ramiel only accepts the fields:
system, stateVersion, user, hardware, scheme, modules, and extraConfig.
From each entry, the module builds a nixosSystemMinimal with the right specialArgs
(scheme, pkgs, inputs', hostname, constants, ...). It starts with no NixOS
modules at all: the base modules we rely on are listed explicitly in
aspects/hosts/_base-modules.nix instead of importing nixpkgs' full module list.
The composition is the important part. We merge deferred modules into sets:
modules.core— common configuration modules provided to every hostmodules.hardware.<profile>— hardware-specific modulesmodules.host.<hostname>— per host modulesmodules.mods.<name>— opt-in feature sets likedesktop,gaming,comms
A host just lists the modules it wants, and the final module list is assembled from those sets. So enabling gaming on a second machine is one word, not a copy-paste of config.
{ config, ... }:
{
modules.configurations.ramiel = {
user = "wyspr";
stateVersion = "25.11";
scheme = "amber";
hardware = "desktop-pc";
modules = with config.modules.mods; [
printing
desktop
gaming
comms
];
};
}
This will receive the following modules:
modules.core
modules.hardware.desktop-pc
modules.host.ramiel
modules.mods.printing
modules.mods.desktop
modules.mods.gaming
modules.mods.comms
Tack flake inputs
file:
aspects/flake/tack.nix
Dependencies live in .tack/pins.toml and get imported into the flake, so
there's no flake.lock and no inputs block to edit. This module gives that file
a typed option schema (tack.inputs.*, tack.shorturls, tack.signers, all_follow,
patches, follows, and so on) and then writes it back out with write-tack.
write-tack is a flake app that:
- Turns the evaluated options into TOML using a custom generator
- Diffs them against the current file
- Only runs
tack updateortack patchfor inputs that have changed or updated It also rewrites the file so every input starts with itsurl, which makes the diffs much nicer to read. Its like flake-file, for tack.
Inputs can be declared as children of the top-level tack option.
{
tack.inputs.hjem = {
url = "gh:feel-co/hjem";
group = "nix";
};
...
}
Then:
nix run .#write-tack
Produces:
# .tack/pins.toml
[inputs.hjem]
url = "gh:feel-co/hjem"
group = "nix"
Package wrappers
wrapPackage is a module-based wrapper around makeWrapper
wrapPackage {
package = pkgs.kitty;
binName = "kitty";
env.KITTY_CONFIG_DIRECTORY = files.config.dir;
files.config = {
path = "config/kitty.conf";
file =
let
toKittyConfig = lib.concatMapAttrsStringSep "\n" (
name: value:
let
mkValue = v: v |> (if lib.isBool v then lib.boolToYesNo else toString);
in
if lib.isList value then
value |> lib.concatMapStringsSep "\n" (v: "${name} ${mkValue v}")
else
"${name} ${mkValue value}"
);
in
''
# Settings
${toKittyConfig cfg.settings}
# Keybindings
${toKittyConfig cfg.keybindings}
# Theme
${cfg.theme}
'';
runtimePackages = [ pkgs.ydotool ];
aliases = [ "term" ];
}
It supports env, args, runCommand, runtimePackages, linkedPackages, files,
and aliases. Files passed as strings go through passAsFile, store paths get
symlinked, and wlib gives you placeholder-aware helpers for generating JSON, TOML,
YAML, or INI inside the wrapper.
Colorschemes
file:
aspects/flake/16.nix
This is a stripped-down base16.nix with no dependency on pkgs. Give it a scheme and
mkScheme normalizes it to base24, adds mnemonic names (red, bright-blue, ..), and
exposes a few useful forms:
scheme.base0D— the raw hex valuescheme.noHashtag.base0D— hex without the#scheme.asRgb8.base0D—{ r, g, b; }in 0–255scheme.asRgb.base0D— the same, normalized to 0–1
The schemes themselves live in schemes.nix, and hosts
pick one by name. No external theming framework, just a bit of hex math in lib.
Repository layout
.
├── flake.nix # the perSystem / output machinery
├── aspects/
│ ├── flake/ # flake-level modules (tack, wrappers, 16, sops, ..)
│ ├── hosts/
│ │ ├── configurations.nix # host schema and system assembly
│ │ ├── nixosSystemMinimal.nix # evalModules wrapper without module-list
│ │ ├── _base-modules.nix # explicit list of NixOS modules we import
│ │ └── ramiel/ # one host: boot, hardware, packages
│ └── modules/
│ ├── core/ # base system modules
│ ├── extra/ # gaming, rice, xdg
│ ├── programs/ # gui and tui apps
│ └── services/ # audio, networking, disks, ..
├── .tack/ # pins.toml and patches
└── justfile
That's the tour. If you're building something similar, the five areas above are the ones I'd start with — they're the parts that made the rest of the config pleasant to live in.