Skip to content

LoneExile/.dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Modular Nix Configuration

A modular, well-documented Nix configuration for macOS that follows community best practices. This configuration provides a flexible, maintainable system for managing your development environment using Nix Darwin and Home Manager.

✨ Features

  • 🧩 Modular Architecture - Organized into reusable, configurable modules
  • πŸ“š Well Documented - Comprehensive documentation and examples
  • 🎯 Profile System - Predefined configurations for different use cases
  • πŸ”’ Secrets Management - SOPS integration for secure configuration
  • πŸ› οΈ Development Ready - Full development environment with modern tools
  • πŸ”„ Easy Updates - Simple commands for system updates and maintenance
  • πŸ§ͺ Testing Support - Built-in validation and testing tools

πŸš€ Quick Start

Prerequisites

Before installing, ensure you have:

  • macOS (Darwin) - This configuration is designed for macOS systems
  • Nix Package Manager with flakes enabled
  • Git for cloning the repository
  • Command Line Tools for Xcode (install with xcode-select --install)

Installation

  1. Install Nix (if not already installed):

    curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  2. Clone this repository:

    git clone https://github.com/loneexile/.dotfiles.git ~/.dotfiles
    cd ~/.dotfiles
  3. Review and customize the configuration:

    # Copy the example host configuration
    cp hosts/_template/default.nix hosts/$(hostname)/default.nix
    
    # Edit the new host configuration
    $EDITOR hosts/$(hostname)/default.nix
    
    # Update flake.nix to include your host
    # Add your hostname to darwinConfigurations
  4. Build and activate the configuration:

    # First time setup (install nix-darwin)
    nix run nix-darwin -- switch --flake .#$(hostname)
    
    # Subsequent updates
    darwin-rebuild switch --flake .#$(hostname)
    
    # Or use the convenient just command
    just switch

Quick Configuration Examples

Minimal Setup

# hosts/your-hostname/default.nix
{
  modules = {
    darwin.system.enable = true;
    home.shell.zsh.enable = true;
  };
  
  profiles = {
    minimal = true;
  };
}

Development Environment

# hosts/your-hostname/default.nix
{
  modules = {
    darwin = {
      system.enable = true;
      homebrew.enable = true;
    };
    home = {
      shell.zsh.enable = true;
      development = {
        git.enable = true;
        editors.enable = true;
        languages.enable = true;
      };
    };
  };
  
  profiles = {
    development = true;
    personal = true;
  };
}

Work Environment

# hosts/your-hostname/default.nix
{
  modules = {
    darwin = {
      system.enable = true;
      homebrew.enable = true;
      security.enable = true;
    };
    home = {
      shell.zsh.enable = true;
      development.git.enable = true;
      desktop.productivity.enable = true;
    };
  };
  
  profiles = {
    work = true;
    development = true;
  };
}

πŸ“ Structure

This configuration is organized into the following directories:

β”œβ”€β”€ README.md                     # This file
β”œβ”€β”€ flake.nix                     # Main flake configuration
β”œβ”€β”€ flake.lock                    # Locked dependencies
β”œβ”€β”€ lib/                          # Reusable library functions
β”‚   β”œβ”€β”€ default.nix              # Main library exports
β”‚   β”œβ”€β”€ builders.nix             # System builders (mkDarwin, etc.)
β”‚   └── utils.nix                # Utility functions
β”œβ”€β”€ modules/                      # Feature modules organized by category
β”‚   β”œβ”€β”€ darwin/                  # macOS-specific modules
β”‚   β”‚   β”œβ”€β”€ system.nix          # Core system settings
β”‚   β”‚   β”œβ”€β”€ homebrew.nix        # Homebrew configuration
β”‚   β”‚   β”œβ”€β”€ security.nix        # Security settings
β”‚   β”‚   └── defaults.nix        # macOS preferences
β”‚   β”œβ”€β”€ home/                   # Home Manager modules
β”‚   β”‚   β”œβ”€β”€ shell/              # Shell configuration
β”‚   β”‚   β”œβ”€β”€ development/        # Development tools
β”‚   β”‚   β”œβ”€β”€ desktop/            # Desktop applications
β”‚   β”‚   └── security/           # Security tools
β”‚   └── shared/                 # Cross-platform modules
β”œβ”€β”€ profiles/                   # Predefined configuration profiles
β”‚   β”œβ”€β”€ minimal.nix            # Essential tools only
β”‚   β”œβ”€β”€ development.nix        # Full development environment
β”‚   β”œβ”€β”€ work.nix              # Work-specific configuration
β”‚   └── personal.nix          # Personal use optimization
β”œβ”€β”€ hosts/                     # Host-specific configurations
β”‚   β”œβ”€β”€ common/               # Shared host configuration
β”‚   └── your-hostname/        # Host-specific overrides
β”œβ”€β”€ config/                   # Configuration files
β”œβ”€β”€ docs/                     # Documentation
β”œβ”€β”€ scripts/                  # Utility scripts
└── secrets/                  # SOPS encrypted secrets

🎯 Profiles

Choose from predefined profiles that suit your use case:

Profile Description Includes
minimal Essential tools only Basic shell, core utilities
development Full development environment Git, editors, languages, containers
work Work-specific configuration Productivity apps, security tools
personal Personal use optimization Media tools, personal apps

Profiles can be combined - for example, you can enable both development and work profiles.

πŸ”§ Common Tasks

Update System

# Update flake inputs and rebuild
just update

# Or manually:
nix flake update
darwin-rebuild switch --flake .

Add New Software

# Add to a module or host configuration
# Then rebuild
darwin-rebuild switch --flake .

Validate Configuration

# Check configuration syntax and formatting
just check

# Or use individual commands:
nix flake check
nixfmt **/*.nix
statix check .

Development Environment

# Enter development shell
nix develop

# Or use specific shells:
nix develop .#minimal    # Minimal tools
nix develop .#docs      # Documentation tools

πŸ“š Documentation

πŸ› οΈ Available Commands

This configuration includes a justfile with common commands:

just --list              # Show all available commands
just check               # Validate configuration
just build               # Build configuration
just update              # Update and rebuild system
just clean               # Clean build artifacts
just docs                # Build documentation
just format              # Format Nix files

πŸ”’ Secrets Management

This configuration uses SOPS for managing secrets:

  1. Setup SOPS (first time):

    # Generate age key
    age-keygen -o ~/.config/sops/age/keys.txt
    
    # Add public key to .sops.yaml
  2. Edit secrets:

    sops secrets/secrets.yaml
  3. Use in configuration:

    sops.secrets.example = {
      sopsFile = ../secrets/secrets.yaml;
    };

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for:

  • Development setup
  • Code style guidelines
  • Testing procedures
  • Pull request process

πŸ“„ License

This configuration is provided as-is for educational and personal use. Feel free to fork and adapt for your own needs.

πŸ†˜ Support

  • Issues: Report bugs or request features via GitHub Issues
  • Discussions: Ask questions in GitHub Discussions
  • Documentation: Check the docs/ directory for detailed guides

Happy Nix-ing! πŸŽ‰

About

Dotfile with Nix

Topics

Resources

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •