Quick Start
If you already have Nix and direnv installed:Prerequisites
Install Nix
If Nix isn’t installed:Install direnv
For automatic shell activation:~/.bashrc or ~/.zshrc):
Development Shell Configuration
Theshell.nix file defines the development environment:
Available Tools
Nix Development Tools
- nil: Nix language server for IDE integration
- alejandra: Nix code formatter
- vulnix: Security vulnerability scanner for Nix packages
Secrets Management
- age: Encryption tool
- agenix: Nix secrets management
- sops: Alternative secrets backend
- ssh-to-age: Convert SSH keys to age format
System Tools (Linux only)
- disko: Declarative disk partitioning
- nixos-facter: Hardware detection and configuration generation
Direnv Integration
The.envrc file automatically activates the Nix shell:
- Loads the development shell when entering the directory
- Unloads when leaving the directory
- Watches flake.nix for changes and reloads automatically
Direnv Commands
Shell Hooks
The shell automatically runs several setup tasks:1. Pre-commit Hooks
- Code formatting checks
- Syntax validation
- Security scans
2. Agenix Shell Integration
secrets.nix become available:
3. GitHub Actions Deployment
Automatically generates workflow files fromactions.nix:
IDE Integration
VS Code / VSCodium
Install the Nix extensions:Language Server
Thenil language server provides:
- Code completion
- Go-to-definition
- Error checking
- Hover documentation
Formatting Code
Use alejandra to format Nix files:Security Scanning
Check for vulnerable packages:Common Workflows
Testing Configuration Changes
Managing Secrets
Building Installation Media
Environment Variables
The shell provides access to:- Decrypted secrets (uppercase names from
secrets.nix) - Standard Nix variables (
NIX_PATH, etc.) - Custom variables from your configuration
Troubleshooting
Direnv not activating
Check if you added the hook to your shell:~/.bashrc:
Tools not in PATH
Ensure direnv is allowed:Secrets not loading
Verify your user has access insecrets.nix:
Shell hook errors
Reload with debug output:Updating the Environment
When you modifyflake.nix or shell.nix:
- Direnv automatically detects changes
- Prompts you to reload with
direnv allow - Rebuilds the environment with new dependencies
Best Practices
Adding New Tools
To add a tool to the development environment:Non-NixOS Systems
The dev shell works on any system with Nix installed:- macOS: Full support except Linux-specific tools
- WSL2: Full Linux functionality
- Other Linux: Works without NixOS-specific tools