# Makefile for Nix Home Manager configuration # Provides convenient targets for testing, building, and applying configurations # Default target shows help .DEFAULT_GOAL := help # Flake reference for configurations FLAKE_PERSONAL := .#personal FLAKE_WORK := .#work # Nix experimental features flag (enables flakes without system config changes) NIX_FLAGS := --extra-experimental-features 'nix-command flakes' # ============================================================================ # PHONY TARGETS # ============================================================================ .PHONY: check show dry-run-personal dry-run-work \ switch-personal switch-work build-personal build-work \ update update-nixpkgs gc gc-old \ fmt lint help # ============================================================================ # TESTING/VALIDATION # ============================================================================ ## check: Run nix flake check to validate the flake check: nix $(NIX_FLAGS) flake check ## show: Display the flake outputs show: nix $(NIX_FLAGS) flake show ## dry-run-personal: Dry-run build for personal configuration (shows what would be built) dry-run-personal: nix $(NIX_FLAGS) build '.#darwinConfigurations.personal.system' --dry-run ## dry-run-work: Dry-run build for work configuration (shows what would be built) dry-run-work: nix $(NIX_FLAGS) build '.#darwinConfigurations.work.system' --dry-run # ============================================================================ # BUILDING/APPLYING # ============================================================================ ## switch-personal: Apply personal configuration with darwin-rebuild (requires sudo) switch-personal: nix $(NIX_FLAGS) build '.#darwinConfigurations.personal.system' sudo ./result/sw/bin/darwin-rebuild activate ## switch-work: Apply work configuration with darwin-rebuild (requires sudo) switch-work: nix $(NIX_FLAGS) build '.#darwinConfigurations.work.system' sudo ./result/sw/bin/darwin-rebuild activate ## build-personal: Build personal configuration without switching build-personal: nix $(NIX_FLAGS) build '.#darwinConfigurations.personal.system' ## build-work: Build work configuration without switching build-work: nix $(NIX_FLAGS) build '.#darwinConfigurations.work.system' # ============================================================================ # MAINTENANCE # ============================================================================ ## update: Update all flake inputs update: nix $(NIX_FLAGS) flake update ## update-nixpkgs: Update only nixpkgs input update-nixpkgs: nix $(NIX_FLAGS) flake lock --update-input nixpkgs ## gc: Run garbage collection to free disk space gc: nix-collect-garbage ## gc-old: Delete old generations and run garbage collection gc-old: nix-collect-garbage -d # ============================================================================ # DEVELOPMENT # ============================================================================ ## fmt: Format all Nix files using nixfmt fmt: find . -name '*.nix' -exec nixfmt {} \; ## lint: Run statix linter on Nix files (if available) lint: @command -v statix >/dev/null 2>&1 && statix check . || echo "statix not installed, skipping lint" # ============================================================================ # HELP # ============================================================================ ## help: Show this help message help: @echo "Nix Home Manager Configuration - Available Targets" @echo "==================================================" @echo "" @echo "Testing/Validation:" @echo " check - Run nix flake check to validate the flake" @echo " show - Display the flake outputs" @echo " dry-run-personal - Dry-run build for personal configuration" @echo " dry-run-work - Dry-run build for work configuration" @echo "" @echo "Building/Applying:" @echo " switch-personal - Apply personal configuration with darwin-rebuild (requires sudo)" @echo " switch-work - Apply work configuration with darwin-rebuild (requires sudo)" @echo " build-personal - Build personal configuration without switching" @echo " build-work - Build work configuration without switching" @echo "" @echo "Maintenance:" @echo " update - Update all flake inputs" @echo " update-nixpkgs - Update only nixpkgs input" @echo " gc - Run garbage collection to free disk space" @echo " gc-old - Delete old generations and run garbage collection" @echo "" @echo "Development:" @echo " fmt - Format all Nix files using nixfmt" @echo " lint - Run statix linter on Nix files" @echo "" @echo "Help:" @echo " help - Show this help message"