This guide helps you diagnose and resolve common issues with the modular Nix configuration.
- Quick Diagnostics
- Installation Issues
- Build and Configuration Issues
- Module-Specific Issues
- Python Tool Issues
- Performance Issues
- Debug Mode
- Getting Help
First, gather system information to understand your environment:
# Show system info
just info
# Check flake inputs
just inputs
# Validate configuration
just validate# Check if Nix is working
nix --version
# Check if flakes are enabled
nix flake --help
# Verify Darwin installation
darwin-rebuild --version
# Check system generation
darwin-rebuild --list-generationsSolution:
# Install Nix using the Determinate Systems installer
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
# Or use the official installer
sh <(curl -L https://nixos.org/nix/install)
# Restart your shell or source the profile
source ~/.nix-profile/etc/profile.d/nix.shSolution:
# Enable flakes temporarily
export NIX_CONFIG="experimental-features = nix-command flakes"
# Or add to ~/.config/nix/nix.conf permanently
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.confSolution:
# Install nix-darwin first
nix run nix-darwin -- switch --flake .#$(hostname)
# Or if you have the configuration ready
nix --extra-experimental-features 'nix-command flakes' build ".#darwinConfigurations.$(hostname).system"
sudo ./result/sw/bin/darwin-rebuild switch --flake ".#$(hostname)"Solution:
# Ensure you have admin privileges
sudo -v
# Check if you're in the admin group
groups $USER
# If not in admin group, add yourself (requires another admin)
sudo dseditgroup -o edit -a $USER -t user adminSolution:
# Clean up and rebuild
nix-collect-garbage -d
just clean
just buildSolution:
# Update flake inputs
just update
# Or update specific input
nix flake lock --update-input nixpkgsSolution:
# Clean up old generations and garbage collect
just gc
# Check disk usage
df -h
du -sh ~/.nix-profile/
# Remove old Darwin generations
sudo nix-collect-garbage -d
sudo nix-store --gcSolution:
# Check syntax with detailed error reporting
just trace
# Format and lint your files
just fmt
just lint
# Check for common issues
just validateSolution:
# Check for circular imports in your modules
# Look for modules importing each other
grep -r "import.*modules" modules/
# Use trace to see where recursion occurs
just traceSolution:
# Ensure modules are properly imported in flake.nix
# Check that lib/default.nix exports modules correctly
# Verify module structure
find modules/ -name "*.nix" -exec nix-instantiate --parse {} \;Solution:
# Check if module is imported in the right place
# Verify module path in imports list
# Ensure module follows correct structure
# Test individual module
nix-instantiate --eval -E 'import ./modules/path/to/module.nix'Solution:
# Install Homebrew first
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add to PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"Solution:
# Update Homebrew
brew update
# Check for conflicting installations
brew list --cask
# Clean up and retry
brew cleanup
darwin-rebuild switch --flake .Solution:
# Check GPG setup
gpg --list-secret-keys
# Test signing
echo "test" | gpg --clearsign
# Configure Git to use correct GPG
git config --global gpg.program $(which gpg)Error:
error: Cannot build '.../vimplugin-nvim-treesitter-textobjects-...'
Require check failed for the following modules:
- nvim-treesitter-textobjects
- nvim-treesitter.textobjects.shared
- nvim-treesitter.textobjects.move
...
Cause: The plugin requires nvim-treesitter to be available during the Nix require check, but it's not present at build time.
Solution: Override the plugin to skip the require check:
nixCats = let
nvim-treesitter-textobjects-fixed = unstablePkgs.vimPlugins.nvim-treesitter-textobjects.overrideAttrs {
doCheck = false;
};
in {
# ... use nvim-treesitter-textobjects-fixed instead of nvim-treesitter-textobjects
};This pattern applies to other vim plugins that fail require checks due to missing dependencies at build time.
Solution:
# Check if zsh is set as default shell
echo $SHELL
# Change default shell
chsh -s $(which zsh)
# Source configuration manually
source ~/.zshrc
# Check for syntax errors in zsh config
zsh -n ~/.zshrcError:
ModuleNotFoundError: No module named 'packaging'
Cause: The fastmcp dependency doesn't properly declare packaging as a required dependency.
Solution:
# Install with the missing dependency injected
uv tool install beads-mcp --with packaging --forceThis pattern applies to other uv tools that have missing transitive dependencies. Use --with <package> to inject the missing package.
Solutions:
# Enable binary caches
echo "substituters = https://cache.nixos.org https://nix-community.cachix.org" >> ~/.config/nix/nix.conf
echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" >> ~/.config/nix/nix.conf
# Use more build cores
echo "max-jobs = auto" >> ~/.config/nix/nix.conf
echo "cores = 0" >> ~/.config/nix/nix.conf
# Enable parallel building
echo "build-cores = 0" >> ~/.config/nix/nix.confSolutions:
# Limit memory usage during builds
echo "max-jobs = 2" >> ~/.config/nix/nix.conf
# Clean up regularly
just gc
# Monitor memory usage
top -o MEM# Build with detailed output
just trace
# Enable debug logging for specific components
export NIX_DEBUG=1
export NIXPKGS_ALLOW_UNFREE=1
# Darwin rebuild with verbose output
darwin-rebuild switch --flake . --verbose# Test module in isolation
nix-instantiate --eval -E '
let
pkgs = import <nixpkgs> {};
lib = pkgs.lib;
config = {};
in
import ./modules/path/to/module.nix { inherit config lib pkgs; }
'
# Check module options
nix-instantiate --eval -E '
(import ./modules/path/to/module.nix {
config = {};
lib = (import <nixpkgs> {}).lib;
pkgs = import <nixpkgs> {};
}).options
'# Keep failed builds for inspection
export NIX_KEEP_FAILED=1
# Show build logs
nix log /nix/store/...
# Build with maximum verbosity
nix build --verbose --print-build-logs- Check this troubleshooting guide
- Run diagnostics:
just validate - Check recent changes:
git log --oneline -10 - Try a clean build:
just clean && just build - Update inputs:
just update
When reporting issues, include:
# System information
just info
# Flake metadata
nix flake metadata
# Error output with trace
just trace 2>&1 | tee error.log
# Recent changes
git log --oneline -5- GitHub Issues - Report bugs and request features
- GitHub Discussions - Ask questions and share ideas
- Nix Community - NixOS Discourse
- Discord/Matrix - Real-time chat support
When reporting issues:
- Isolate the problem - Create minimal configuration that reproduces the issue
- Test on clean system - Verify issue isn't environment-specific
- Include exact commands - Show what you ran and what happened
- Share configuration - Provide relevant parts of your config
- Updated flake inputs (
just update) - Cleaned build artifacts (
just clean) - Validated configuration (
just validate) - Checked disk space (
df -h) - Restarted shell/terminal
- Checked for typos in configuration
- Verified module imports are correct
- Tested with minimal configuration
If you're still experiencing issues after trying these solutions, please open an issue on GitHub with detailed information about your problem.