A modular, reproducible NixOS configuration using flakes with home-manager integration. Supports multiple hosts, desktop environments, and a layered profile system for maximum reusability.
| Host | Description | User | Desktop | Hardware |
|---|---|---|---|---|
| VNPC-21 | ThinkPad P53 workstation | odin | Hyprland | Lenovo ThinkPad P53, NVIDIA GPU |
| laptop | Portable laptop | none | Hyprland | Generic laptop |
| station | Desktop build server | none | Hyprland | AMD desktop, NVIDIA GPU |
- Hyprland (primary) - Modern Wayland compositor with custom animations and keybinds
- BSPWM (alternative) - X11 tiling window manager
- COSMIC (experimental) - System76's new desktop environment
- Waybar - Customized status bar with system monitoring
- Rofi - Application launcher with Nord theming
- SwayNC - Notification daemon for Wayland
- Neovim - Full IDE via nixvim (LSP, completion, formatting, linting)
- Zellij - Terminal multiplexer with persistent sessions
- Zsh - Shell with oh-my-zsh, custom aliases, and completions
- Git - Configured with lazygit integration
- Docker - Container runtime with rootless mode
- Direnv - Automatic environment loading per project
- Language Support - LSPs and formatters for Nix, Python, Go, Rust, TypeScript, and more
- Stylix - Unified theming system across all applications
- Nord - Primary color scheme
- Custom fonts - Nerd Fonts with Japanese and CJK support
- Dynamic wallpapers - Random rotation in Hyprland
- Transparency - Configurable terminal opacity
- Tailscale - Mesh VPN networking
- Syncthing - Peer-to-peer file synchronization
- SOPS-nix - Encrypted secrets management
- PipeWire - Modern audio server with PulseAudio compatibility
- Flatpak - Additional application packaging
- Printing - CUPS with Brother printer drivers
- QEMU/KVM - Virtual machines via virt-manager
- VirtualBox - Additional VM support
- Docker - Container orchestration
- Gaming (station) - Heroic launcher, Bottles, Steam via Flatpak
# Enable flakes in your NixOS configuration
nix.settings.experimental-features = [ "nix-command" "flakes" ];-
Clone the repository
git clone https://github.com/Odinyg/nixflake.git cd nixflake -
Build and switch to your host
# Using justfile (recommended) just rebuild # Or manually sudo nixos-rebuild switch --flake .#<hostname>
-
Available just commands
just rebuild # Rebuild current host (auto-detects) just upgrade # Update flake inputs + rebuild just boot # Build new boot configuration just verbose # Rebuild with detailed output just gc # Clean generations older than 14 days just diff # View git changes (excludes flake.lock)
.
├── flake.nix # Main flake entry point
├── flake.lock # Pinned dependency versions
├── justfile # Build automation commands
├── CLAUDE.md # AI assistant instructions
│
├── hosts/ # Host-specific configurations
│ ├── vnpc-21/ # ThinkPad P53 workstation
│ ├── laptop/ # Generic laptop
│ └── station/ # Desktop build server
│
├── profiles/ # Layered configuration profiles
│ ├── base.nix # Minimal base system
│ ├── laptop.nix # Laptop-specific settings (extends base)
│ ├── desktop.nix # Desktop hardware (extends base)
│ └── workstation.nix # Full workstation (extends desktop)
│
├── modules/
│ ├── nixos/ # System-level modules
│ │ ├── hardware/ # GPU, audio, bluetooth, networking
│ │ ├── services/ # System services
│ │ ├── general.nix # Core system packages
│ │ ├── fonts.nix # Font configuration
│ │ └── secrets.nix # SOPS secrets management
│ │
│ └── home-manager/ # User-level modules
│ ├── app/ # GUI applications
│ ├── cli/ # Terminal tools (neovim, zsh, git)
│ ├── desktop/ # Desktop environments
│ │ ├── hyprland/ # Hyprland configuration
│ │ ├── bspwm/ # BSPWM configuration
│ │ └── cosmic/ # COSMIC desktop
│ └── misc/ # Miscellaneous configs
│
└── secrets/ # Encrypted secrets (SOPS)
├── secrets.yaml
└── general.yaml
Configurations are layered for maximum reusability:
base.nix (core system)
├─→ laptop.nix (base + laptop hardware)
└─→ desktop.nix (base + desktop hardware)
└─→ workstation.nix (desktop + dev tools)
Each host imports a profile and adds host-specific overrides.
All optional features use the enable pattern:
# In host configuration
moduleName.enable = true;This makes it easy to mix and match features per host.
-
Generate hardware configuration
nixos-generate-config --show-hardware-config > hosts/newhost/hardware-configuration.nix -
Create host configuration
# hosts/newhost/default.nix { config, pkgs, lib, inputs, ... }: { imports = [ ./hardware-configuration.nix ../../profiles/laptop.nix # Choose appropriate profile ]; # Networking networking.hostName = "newhost"; # User configuration users.users.myuser = { isNormalUser = true; extraGroups = [ "networkmanager" "wheel" ]; shell = pkgs.zsh; }; # Enable desired features hyprland.enable = true; neovim.enable = true; system.stateVersion = "25.05"; }
-
Add to flake.nix
nixosConfigurations.newhost = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; modules = commonModules ++ [ ./hosts/newhost { user = "myuser"; } { nixpkgs.config.allowUnfree = true; home-manager = { useGlobalPkgs = true; useUserPackages = true; extraSpecialArgs = { inherit inputs; }; users.myuser = mkHomeConfig { username = "myuser"; stateVersion = "25.05"; }; }; } ]; };
-
Build and test
nix flake check sudo nixos-rebuild switch --flake .#newhost
Most modules use boolean enable options:
# Desktop environments
hyprland.enable = true;
bspwm.enable = false;
# Applications
discord.enable = true;
firefox.enable = false;
# System features
secrets.enable = true;
gaming.enable = true;Host-specific overrides go in hosts/<hostname>/default.nix:
# Override terminal opacity
styling.opacity.terminal = 0.85;
# Enable specific services
init-net.enable = true;
hosted-services.n8n.enable = true;
# Add extra packages
users.users.odin.packages = with pkgs; [
custom-package
];This configuration uses SOPS-nix for encrypted secrets:
# Initialize age key for new host
mkdir -p ~/.config/sops/age
age-keygen -o ~/.config/sops/age/keys.txt
# Edit secrets
sops secrets/secrets.yamlSecrets are automatically decrypted at boot and placed in /run/secrets/.
Theming is managed by Stylix with the Nord color scheme. To customize:
# In host configuration
stylix = {
base16Scheme = "${pkgs.base16-schemes}/share/themes/nord.yaml";
image = ./wallpaper.png;
fonts = {
monospace = {
package = pkgs.nerdfonts;
name = "JetBrainsMono Nerd Font";
};
};
};Build fails with syntax error
nix flake check # Validate flake syntaxNeed to rollback to previous generation
sudo nixos-rebuild switch --rollbackChecking system logs
journalctl -xe # System logs
journalctl -u SERVICE # Specific serviceHyprland issues
# Check Hyprland logs
cat ~/.local/share/hyprland/hyprland.log
# Restart Hyprland
hyprctl reloadHome Manager issues
# Rebuild just home-manager
home-manager switch --flake .#<user>@<host># Remove old generations
sudo nix-collect-garbage -d
# Remove old boot entries
sudo /run/current-system/bin/switch-to-configuration boot
# Optimize nix store
nix-store --optimize