Morten Olsen f42a092b60 init
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00
2025-12-15 13:15:09 +01:00

Nix Home Manager Dotfiles

A declarative, reproducible dotfiles configuration using Nix, nix-darwin, and Home Manager. This setup supports two profiles: personal and work, allowing different configurations for different machines while sharing common settings.

Overview

This repository manages:

  • Shell environment: Zsh with Starship prompt, Atuin history, Zoxide navigation, FZF fuzzy finder
  • Development tools: Neovim, Tmux, Git with delta, lazygit
  • CLI utilities: Modern replacements (eza, bat, ripgrep, fd, delta)
  • Container tools: Docker, Colima, Kubernetes (kubectl, helm, k9s)
  • macOS applications: Managed via Homebrew casks through nix-darwin
  • SSH configuration: 1Password SSH agent integration with profile-specific hosts
  • Git configuration: Profile-specific signing keys and project-based configs

Prerequisites

1. Install Nix

Install Nix with flakes support:

# Install Nix (multi-user installation recommended for macOS)
curl -L https://nixos.org/nix/install | sh

# Restart your shell or source the nix profile
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

2. Enable Flakes

Create or edit ~/.config/nix/nix.conf:

mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf

3. Install Homebrew (macOS)

Homebrew is required for GUI applications (casks):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

4. Install 1Password

This configuration uses 1Password for SSH key management. Install 1Password and enable:

  • SSH Agent: Settings → Developer → SSH Agent
  • CLI Integration: Settings → Developer → Command-Line Interface (CLI)

Quick Start

Personal Machine Setup

# Clone the repository
git clone <repository-url> ~/.dotfiles
cd ~/.dotfiles

# Build and activate the personal configuration
make switch-personal

Work Machine Setup

# Clone the repository
git clone <repository-url> ~/.dotfiles
cd ~/.dotfiles

# Build and activate the work configuration
make switch-work

Makefile Commands

The project includes a Makefile for convenient operations. Run make help to see all available commands.

Testing/Validation

Command Description
make check Run nix flake check to validate the flake
make show Display the flake outputs
make dry-run-personal Dry-run build for personal configuration
make dry-run-work Dry-run build for work configuration

Building/Applying

Command Description
make switch-personal Apply personal configuration with darwin-rebuild
make switch-work Apply work configuration with darwin-rebuild
make build-personal Build personal configuration without switching
make build-work Build work configuration without switching

Maintenance

Command Description
make update Update all flake inputs
make update-nixpkgs Update only nixpkgs input
make gc Run garbage collection to free disk space
make gc-old Delete old generations and run garbage collection

Development

Command Description
make fmt Format all Nix files using nixfmt
make lint Run statix linter on Nix files

Project Structure

.
├── flake.nix                    # Main flake entry point
├── flake.lock                   # Locked dependency versions
├── Makefile                     # Convenient make targets
├── README.md                    # This file
│
├── home/                        # Home Manager configurations
│   ├── default.nix              # Shared home configuration
│   ├── personal.nix             # Personal profile overrides
│   └── work.nix                 # Work profile overrides
│
├── hosts/                       # Machine-specific nix-darwin configs
│   ├── personal/
│   │   └── default.nix          # Personal machine darwin settings
│   └── work/
│       └── default.nix          # Work machine darwin settings
│
├── modules/                     # Reusable Nix modules
│   ├── darwin/
│   │   └── homebrew.nix         # Homebrew cask management
│   │
│   └── home/                    # Home Manager modules
│       ├── apps.nix             # Application configs (aerospace, jellyfin-tui)
│       ├── git.nix              # Git configuration
│       ├── git-files.nix        # Project-specific git configs
│       ├── packages.nix         # CLI packages via Nix
│       ├── shell.nix            # Shell environment (zsh, starship, etc.)
│       ├── ssh.nix              # SSH configuration
│       └── tmux.nix             # Tmux configuration
│
└── docs/                        # Documentation
    ├── migration-analysis.md    # Original migration analysis
    ├── nix-architecture.md      # Architecture design
    └── usage.md                 # Detailed usage guide

Customization

Adding New Packages

Via Nix (Preferred for CLI tools)

Edit modules/home/packages.nix:

home.packages = with pkgs; [
  # Add your package here
  your-package
];

Via Homebrew (For GUI apps/casks)

Edit modules/darwin/homebrew.nix:

casks = {
  shared = [
    # Add casks for all machines
    "your-app"
  ];
  personal = [
    # Add casks for personal machine only
    "personal-only-app"
  ];
};

Modifying Shell Configuration

Edit modules/home/shell.nix to customize:

  • Shell aliases
  • Environment variables
  • Zsh settings
  • Starship prompt
  • Atuin history settings

Modifying Git Configuration

Edit modules/home/git.nix for global settings, or the profile files:

Adding SSH Hosts

Edit modules/home/ssh.nix to add new SSH host configurations.

Profile Differences

Feature Personal Work
Git Email Personal email Work email
Git Signing Key Personal SSH key Work SSH key
SSH Hosts github-private, gitea github-private, github-zeronorth, coder
Homebrew Casks All + personal apps Shared apps only
Personal Apps darktable, signal, proton-*, steam -
Jellyfin TUI Enabled Disabled

Troubleshooting

Build Errors

# Check flake validity
make check

# Build with verbose output
darwin-rebuild switch --flake .#personal --show-trace

Rollback

# List generations
darwin-rebuild --list-generations

# Rollback to previous
darwin-rebuild --rollback

Clean Rebuild

# Remove result symlink and rebuild
rm -f result
make gc
make switch-personal

Homebrew Issues

# If Homebrew packages fail to install
brew update
brew doctor
make switch-personal

Documentation

License

This is a personal dotfiles repository. Feel free to use it as inspiration for your own configuration.

Description
No description provided
Readme 295 KiB
Languages
Nix 93.9%
Makefile 6.1%