A modular, scalable, and declarative NixOS environment built with Flakes and Home Manager. This repository serves as a framework to manage multiple machines across different hardware architectures and use cases (e.g., workstations, servers, laptops) from a single unified codebase.
- Nix Flakes & Home Manager: Fully reproducible system and user-level configuration.
- Feature Toggles: Granular control over software and system features using
lib.mkEnableOptionandlib.mkIf. - Domain-Driven Host Configuration: Host-specific configurations are strictly separated by logical domains (
hardware,storage,system,software). - Declarative Partitioning: Automated disk layout, formatting, and swap allocation using
disko. - Script Management: Local shell scripts managed and integrated into the environment.
.
├── flake.nix # Entry point, inputs, and outputs definition
├── flake.lock # Pinned dependency versions
├── hosts/ # Per-machine configurations
│ └── <host>/ # Replace <host> with the machine's hostname
│ ├── default.nix # Host entry point and module imports
│ ├── system.nix # Core OS setup (networking, locale, bootloader)
│ ├── software.nix # Application feature toggles (Neovim, VSCode, etc.)
│ ├── hardware.nix # Kernel modules, microcode, and physical drivers
│ └── storage.nix # Disko layouts, file systems, zramSwap, swapDevices, and backups
└── modules/ # Reusable modules containing feature toggles
├── boot.nix # Bootloader and splash screen options
├── editors.nix # Text editor configurations and XDG entries
├── options.nix # Global options schema (monitors, fonts, user)
└── ... # Terminals, window managers, tools, etc.
- Create the host directory:
mkdir -p hosts/<host>- Define domain files:
Create
system.nix,software.nix,hardware.nix, andstorage.nixinsidehosts/<host>/. - Configure
default.nix: Import../common.nixand the host domain files insidehosts/<host>/default.nix:
{
imports = [
../common.nix
./system.nix
./software.nix
./hardware.nix
./storage.nix
];
}- Update
flake.nix: Add<host>to yournixosConfigurations.
To apply the configuration to an existing NixOS installation, run:
sudo nixos-rebuild switch --flake .#<host>To update the system and pull the latest flake inputs:
nix flake update
sudo nixos-rebuild switch --flake .#<host>This framework relies on an opt-in philosophy. Modules defined in the modules/ directory do nothing until explicitly enabled.
To enable a feature for a specific host, declare it in that host's software.nix or system.nix file:
# inside hosts/<host>/software.nix
dotfiles = {
editors = {
neovim.enable = true;
vscode.enable = true;
};
};