los provides Nix flake, modules, and library for NixOS systems.
The L in los was picked randomly, and could stand for last, light, or even loser.
Modules are organized under ./modules:
modules/system/— System-wide NixOS modulesmodules/home/— Per-user modules (withusername:closure)
There's only 1 rule for modules: a system module must never touch user modules.
We allow user modules to read or even set values of system modules, or even
nixosConfigurationsitself, if that's the natural way to implement the module.
-
System modules in
modules/system/The root of this module is the top-level
losThe modules here provide los system options like networking, mountpoints, users, and doas.
-
The modules here provide
los.homeuser options like program configurations, user-specific packages, etc.dm/— Display manager related configs (sway, pipewire, fonts)languages/— Programming language supportfirefox/— Firefox browser configurationgit/— Git version control configurationhelix/— Helix editor configurationlf/— lf file manager configurationvscodium/— VSCodium editor configuration
And it goes on.
Options under
los.homeare user-specific. The per-user configuration is implemented by simple, stupid functional module factories that takes in a username and returns a user-specific los modules underlos.home.${username}.The options
los.home.${username}will then be mapped tohome-manager.users.${username}.Note that
home-manager.sharedModulesis not used because some modules here might need to set system configurations too, usually low-level or security-related NixOS options.The
dm/module provides shared display manager settings:los.home.${username}.dm.pipewire.enable— Audio/screen sharing supportlos.home.${username}.dm.fonts— Font configurationlos.home.${username}.dm.sway— Sway window manager
Other modules (like Firefox) can reference
dm.pipewire.enableto determine whether to enable Pipewire support, avoiding configuration races. -
The
home/default.nixfile is the flake entry point for standalonehomeConfigurations, used for non-NixOS systems (e.g., macOS).
Per-host configurations should be consolidated into a single module
under ./hosts.
Preferrably, these hosts modules should not declare any options (i.e.
they are imports-only modules), and they should not touch user modules directly.
This is because hosts are bare-minimum builds that can boot and connect to the internet.
The way I like it is to use host configuration as the base, and build up from there with modules and presets.
-
Library (very opinionated)
Simple (sometimes useless) non-module Nix code, usually functions.
-
List of package names to be imported by syspkgs module.
Each text line is treated as pname of a Nix package.
-
Ready-to-go, import-only modules with no options defined.
-
Like defaults, but more complex. An example is
sway-dev, which provides my working environment using Sway and Helix.Presets usually cover everything but the boot process or hardware settings.
Lower-level, machine-specific configuration like the boot process, mountpoints, and kernel settings should be defined in
hosts/<host>/default.nix.Like with defaults, they provide no options.