Skip to content

ponfertato/nixcfg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

132 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS Modular Configuration

A modular NixOS configuration with Flakes support ❄️ Snowflake-inspired infrastructure for your systems


🚀 Quick Start

Requirements

  • NixOS 26.05 (Warbler) or newer
  • Flakes enabled in /etc/nixos/configuration.nix:
    { nix.settings.experimental-features = [ "nix-command" "flakes" ]; }

Initial Setup on NixOS

# Generate hardware configuration
sudo rm -rf /etc/nixos/*; sudo nixos-generate-config

# Build and activate configuration
sudo nixos-rebuild switch --flake .#$(hostname) --impure

📂 Structure

nixcfg/
├── flake.nix                          # ❄️ Flakes entry point + unstable overlay
├── profiles/                          # 🧩 Modular system profiles
│   ├── core/                          # 🖥️ Base system: locale, kernel, nix, network, firewall
│   └── user/                          # 👤 User roles (multi-user ready)
│       └── ponfertato/                # 👤 Current user profile
│           ├── default.nix            #    Account, packages, git, aliases, services
│           ├── firefox/               # 🦊 Firefox configuration
│           │   ├── policies.nix       #    🛡️ Enterprise policies (tracking, search)
│           │   └── preferences.nix    #    ⚙️ about:config tweaks
│           └── thunderbird/           # 📨 Thunderbird configuration
│               ├── policies.nix       #    🛡️ Enterprise policies
│               └── preferences.nix    #    ⚙️ UI and composition
├── hosts/                             # 🖥️ Host-specific configs (desktop + hardware + packages)
│   ├── potatoWork/                    # 💻 Intel workstation (WoL, anydesk, mattermost)
│   │   └── default.nix
│   └── potatoLaptop/                  # 💻 AMD laptop (Bluetooth, Steam, heroic)
│       └── default.nix
└── modules/                           # 🧩 Reusable NixOS modules
    ├── docker.nix                     # 🐳 Docker configuration
    ├── flatpak.nix                    # 📦 Flatpak + auto Flathub setup
    ├── ollama.nix                     # 🤖 Ollama service
    └── waydroid.nix                   # 📱 Waydroid configuration

🔄 Maintenance

Apply new configuration (recommended)

nix-switch

Update flake inputs

nix-update

Full update workflow

nix-update && nix-check && nix-switch

Rollback to previous generation

nix-roll

Garbage Collection

nix-gc      # Delete old generations + optimise store
nix-clean   # Optimise store only (keeps generations)

Validate configuration

nix-check   # Run `nix flake check` without applying

Manual Update (if needed)

# Update flake inputs
nix flake update
# Rebuild and activate with hardware config regeneration
sudo nixos-generate-config && sudo nixos-rebuild switch --flake .#$(hostname) --impure

Package Search

nix search nixpkgs <package>          # in stable (nixos-26.05)
nix search nixpkgs-unstable <package> # in unstable

✨ Key Features

  • 🔄 Automatic Updates: Weekly GC and auto-upgrade
  • 🧩 Modular Design: core profile + per-user profile + per-host customization
  • 💻 Multi-Host Support: Shared user profile across potatoWork and potatoLaptop
  • 🛡️ Reproducible Builds: Fully declarative configuration with Flakes
  • ⚙️ Optimized Nix Settings: Yandex mirror + custom substituters for faster builds
  • 🔥 Unstable Overlay: Access pkgs.unstable.* without extra args
  • 🦊 Browser Hardening: Firefox and Thunderbird configured via enterprise policies + preferences
  • 🖥️ Desktop Integration: KDE Plasma 6, Wayland, Pipewire, Flatpak, Docker

🛠️ Customization

Create New Profile

  1. Add profiles/new-profile/ directory.
  2. Create profiles/new-profile/default.nix containing the NixOS module.
  3. Import the profile in flake.nix for the desired host configuration.

Create New User Role

  1. Add profiles/user/<username>/ directory.
  2. Create default.nix with user settings (account, packages, programs).
  3. Split large configs into subfolders (e.g. firefox/, thunderbird/) and import them.
  4. Import the user profile in hosts/<hostname>/default.nix.

Create New Module

  1. Add modules/new-module.nix.
  2. Import the module in flake.nix for the desired host configuration.

Create New Host

  1. Add hosts/<hostname>/default.nix.
  2. Import the desired user profile: imports = [ ../../profiles/user/ponfertato ];
  3. Register it in flake.nix under nixosConfigurations.
  4. Point cpuModule to the appropriate nixos-hardware module.

Hardware Configuration

  • Hardware-specific settings (kernel, CPU microcode, graphics drivers) are managed separately in /etc/nixos/hardware-configuration.nix.
  • This file is typically generated by nixos-generate-config and can be manually edited or supplemented with nixos-hardware modules if needed.
  • The configuration is included in flake.nix via --impure to allow per-machine regeneration.

About

Ponfertato NixOS configuration with modular structure (codeberg mirror)

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages