A comprehensive, production-ready Nix configuration using flake-parts
for managing NixOS, Darwin, and Home Manager configurations across multiple architectures and environments.
- π§ Multi-Platform Support: macOS (Darwin), NixOS (x86_64 & aarch64), Mobile NixOS
- ποΈ Modular Architecture: Clean separation using flake-parts
- π Production-Ready Secrets: SOPS-nix with age encryption
- π Automated CI/CD: GitHub Actions with comprehensive checks
- π± Mobile Support: OnePlus 6T with Mobile NixOS
- π― Environment Separation: Production, staging, development configurations
- π οΈ Developer Experience: Rich development shells and tools
π¨βπ» Code Statistics:
Total LOC (including blanks, comments): 54873
π Click to expand code stats.
Language | Files | Lines | Code | Comments | Blanks |
---|---|---|---|---|---|
CSS | 8 | 5586 | 4248 | 316 | 1022 |
JSON | 1 | 402 | 402 | 0 | 0 |
Lua | 1 | 225 | 138 | 50 | 37 |
Markdown | 13 | 3448 | 0 | 2476 | 972 |
Nix | 286 | 39118 | 33000 | 3635 | 2483 |
Python | 5 | 1617 | 1407 | 61 | 149 |
Shell | 17 | 3936 | 2915 | 365 | 656 |
Plain Text | 1 | 1 | 0 | 1 | 0 |
TOML | 1 | 56 | 47 | 5 | 4 |
Vim script | 0 | 0 | |||
YAML | 9 | 484 | 304 | 160 | 20 |
Total | 342 | 54873 | 42461 | 7069 | 5343 |
Last updated: Fri Aug 1 11:55:02 PDT 2025
System | Architecture | Hostname | Status |
---|---|---|---|
macOS | aarch64-darwin | NIXY | β Active |
macOS | x86_64-darwin | NIXI | β Active |
NixOS Desktop | x86_64-linux | NIXSTATION64 | β Active |
NixOS ARM | aarch64-linux | NIXY2 | β Active |
Mobile NixOS | aarch64-linux | NIXEDUP (OnePlus 6T) | π§ͺ Experimental |
This repository follows a standardized flake-parts
structure for better organization and maintainability:
.
βββ flake.nix # Main flake entry point
βββ flake.lock # Flake lock file
βββ parts/ # Flake-parts modules
β βββ lib.nix # Library functions
β βββ overlays.nix # Nixpkgs overlays
β βββ sops.nix # SOPS secrets management
β βββ common.nix # Common configurations
β βββ nixos-configurations.nix
β βββ darwin-configurations.nix
β βββ home-configurations.nix
β βββ packages.nix # Custom packages
β βββ apps.nix # Flake applications
β βββ devshells.nix # Development shells
β βββ docs.nix # Documentation
β βββ ci.nix # CI/CD scripts
β βββ formatter.nix # Code formatting
β βββ checks.nix # Flake checks
βββ modules/ # Reusable modules
β βββ nixos/ # NixOS modules
β βββ darwin/ # Darwin modules
β βββ home-manager/ # Home Manager modules
βββ hosts/ # System configurations
β βββ nixos/ # NixOS hosts
β β βββ NIXSTATION64/ # Desktop workstation
β β βββ NIXY2/ # ARM development board
β β βββ NIXEDUP/ # OnePlus 6T mobile
β βββ darwin/ # Darwin hosts
β β βββ NIXY/ # MacBook Pro M1
β βββ extraConfig/ # SSH keys and additional configs
βββ profiles/ # Reusable configuration profiles
β βββ desktop/ # Desktop environment
β βββ server/ # Server configuration
β βββ mobile/ # Mobile optimizations
β βββ development/ # Development tools
βββ users/ # User-specific configurations
β βββ alex/ # Primary user
β βββ susu/ # Secondary user
βββ secrets/ # SOPS-encrypted secrets
β βββ production/ # Production environment
β βββ staging/ # Staging environment
β βββ development/ # Development environment
β βββ systems/ # System-specific secrets
β βββ users/ # User-specific secrets
βββ scripts/ # Management scripts
βββ docs/ # Comprehensive documentation
βββ lib/ # Helper functions
βββ overlays/ # Package overlays
βββ shared/ # Shared configurations
βββ tools/ # Utility tools
# Install Nix with flakes support
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
# Clone the repository
git clone https://github.com/yourusername/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
# NixOS systems
nix build .#nixosConfigurations.NIXSTATION64.config.system.build.toplevel
nix build .#nixosConfigurations.NIXY2.config.system.build.toplevel
nix build .#nixosConfigurations.NIXEDUP.config.system.build.toplevel
# Darwin systems
nix build .#darwinConfigurations.NIXY.system
nix build .#darwinConfigurations.NIXI.system
# Home Manager configurations
nix build .#homeConfigurations.alex.activationPackage
# NixOS (run on target system)
sudo nixos-rebuild switch --flake .#NIXSTATION64
sudo nixos-rebuild switch --flake .#NIXY2
sudo nixos-rebuild switch --flake .#NIXEDUP
# Darwin (run on macOS)
darwin-rebuild switch --flake .#NIXY
darwin-rebuild switch --flake .#NIXI
# Home Manager (run as user)
home-manager switch --flake .#alex
# Automated deployment (detects current system)
nix run .#ci-deploy
# Enter development shell with all tools
nix develop
# Format code
nix fmt
# Check flake validity
nix flake check
# Run comprehensive CI checks
nix run .#ci-check
# Serve documentation locally
nix run .#docs-serve
Run applications with nix run .#<app-name>
:
Application | Description |
---|---|
default |
System information and flake overview |
system-info |
Detailed system information |
secrets-manager |
Interactive SOPS secrets management |
mobile-installer |
Mobile NixOS installer for OnePlus 6T |
update-readme |
Update README.md with current code statistics |
ci-check |
Comprehensive CI/CD checks |
ci-deploy |
Automated system deployment |
docs-serve |
Local documentation server |
# Get system information
nix run .#default
# Manage secrets interactively
nix run .#secrets-manager
# Update code statistics in README
nix run .#update-readme
# Run all CI checks
nix run .#ci-check
# Deploy current system
nix run .#ci-deploy
-
Create host directory:
mkdir -p hosts/{nixos,darwin}/hostname
-
Create configuration:
# hosts/nixos/hostname/default.nix { config, lib, pkgs, ... }: { imports = [ ./hardware-configuration.nix ../../../profiles/desktop ]; networking.hostName = "hostname"; # Additional configuration... }
-
Add to flake configuration:
# parts/nixos-configurations.nix hostname = inputs.nixpkgs.lib.nixosSystem { # Configuration... };
-
Create module:
mkdir -p modules/{nixos,darwin,home-manager}/module-name
-
Implement module:
# modules/nixos/module-name/default.nix { config, lib, pkgs, ... }: { options = { # Module options... }; config = { # Module implementation... }; }
-
Import in default.nix:
# modules/nixos/default.nix { imports = [ ./module-name # Other modules... ]; }
-
Create profile directory:
mkdir -p profiles/profile-name
-
Define profile:
# profiles/profile-name/default.nix { config, lib, pkgs, ... }: { imports = [ # Required modules... ]; # Profile configuration... }
-
Import in profiles:
# profiles/default.nix { profile-name = import ./profile-name; }
This configuration uses SOPS-nix with age encryption for production-ready secrets management:
# Edit secrets (environment-specific)
sops secrets/production/secrets.yaml
sops secrets/development/secrets.yaml
sops secrets/users/alex.yaml
# Rekey secrets after adding new recipients
sops updatekeys secrets/production/secrets.yaml
# Interactive secrets management
nix run .#secrets-manager
# Validate all secrets
./scripts/secrets-manager.sh validate
# Audit secret access
./scripts/secrets-manager.sh audit
- Production:
secrets/production/
- Live environment secrets - Staging:
secrets/staging/
- Pre-production testing - Development:
secrets/development/
- Local development - Users:
secrets/users/
- Personal API keys and configs - Systems:
secrets/systems/
- Host-specific secrets
- π SOPS-nix Implementation Guide - Complete production deployment guide
- π§ Secrets Management Guide - Comprehensive secrets documentation
- π Development Guide - Development setup and workflows
- π€ Contributing Guidelines - How to contribute to this project
- π’ Deployment Guide - Production deployment procedures
- π Deployment Runbook - Step-by-step deployment instructions
- π Troubleshooting Guide - Common issues and solutions
- π Project Status - Current project status and roadmap
- Module Documentation - Detailed module documentation
- Host Configuration Examples - Host-specific configuration guides
- API Documentation - Internal API documentation
# Run all checks (recommended before commits)
nix flake check
# Test specific system builds (dry-run)
nix build .#nixosConfigurations.NIXSTATION64.config.system.build.toplevel --dry-run
nix build .#darwinConfigurations.NIXY.system --dry-run
# Format check
nix fmt --check
# Comprehensive CI checks
nix run .#ci-check
# Test secrets decryption
./scripts/secrets-manager.sh validate
# Test system deployment (dry-run)
sudo nixos-rebuild dry-run --flake .#NIXSTATION64
# Test Home Manager configuration
home-manager build --flake .#alex
- β Flake validation: Ensures flake.nix is valid
- β Format checking: Code formatting with treefmt
- β Build testing: All system configurations build successfully
- β Secrets validation: All secrets can be decrypted
- β Documentation: Links and references are valid
# Deploy current system automatically
nix run .#ci-deploy
# NixOS systems
sudo nixos-rebuild switch --flake .#NIXSTATION64
# Darwin systems
darwin-rebuild switch --flake .#NIXY
# Home Manager
home-manager switch --flake .#alex
# Deploy to remote NixOS system
nixos-rebuild switch --flake .#NIXSTATION64 --target-host user@hostname
# Deploy using deploy-rs (if configured)
deploy .#NIXSTATION64
# Enter development environment
nix develop
# Available tools in dev shell:
# - nix, nixpkgs-fmt, treefmt
# - sops, age, ssh-to-age
# - git, gh, pre-commit
# - mdbook (for documentation)
# Format all code
nix fmt
# Check formatting
nix fmt --check
# Install pre-commit hooks
pre-commit install
# Run hooks manually
pre-commit run --all-files
This configuration includes experimental support for Mobile NixOS on OnePlus 6T:
# Build mobile image
nix build .#nixosConfigurations.NIXEDUP.config.system.build.android-bootimg
# Install mobile helper
nix run .#mobile-installer
# Flash to device (requires unlocked bootloader)
fastboot flash boot result/boot.img
fastboot reboot
Note: Mobile NixOS support is experimental and may require additional setup.
We welcome contributions! Please see our Contributing Guidelines for details on:
- Code style and formatting
- Commit message conventions
- Pull request process
- Testing requirements
- Documentation standards
- Fork and clone the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make changes and test thoroughly
- Format code:
nix fmt
- Run checks:
nix flake check
- Commit changes: Follow conventional commit format
- Push and create a pull request
This configuration is available under the MIT License. See LICENSE for details.
- NixOS - The purely functional Linux distribution
- nix-darwin - Nix modules for macOS
- Home Manager - User environment management
- flake-parts - Modular flake framework
- SOPS - Secrets management
- Mobile NixOS - NixOS for mobile devices
Made with β€οΈ and Nix | Report Issues | Discussions