2.5 KiB
2.5 KiB
Quick Start Guide
TL;DR - Should I Use Flakes?
YES! ✅ Use flakes because:
- You get nixos-unstable (latest packages) with reproducibility
- Your config is in git with locked versions (flake.lock)
- You already have flakes enabled in your system
- It's the modern, recommended approach
Current vs Flake Setup
Current (Channels) ❌
# Update
sudo nix-channel --update
sudo nixos-rebuild switch
# Config location
/etc/nixos/configuration.nix
# Package versions
Whatever the channel has (not locked)
With Flakes (Recommended) ✅
# Update
nix flake update
sudo nixos-rebuild switch --flake /home/pan/dev/config/dot/nix/nixos#nix --impure
# Config location
/home/pan/dev/config/dot/nix/nixos/
├── flake.nix (inputs: nixpkgs unstable, home-manager, nixos-wsl)
├── flake.lock (exact versions locked)
└── configuration.nix
# Package versions
Locked in flake.lock, reproducible everywhere
Apply the Flake Configuration Now
Step 1: Test it
cd /home/pan/dev/config/dot/nix/nixos
nix flake check --impure
sudo nixos-rebuild build --flake .#nix --impure
Step 2: If successful, apply it
sudo nixos-rebuild switch --flake .#nix --impure
Step 3: Verify
nixos-version
nix flake metadata /home/pan/dev/config/dot/nix/nixos
What Changes?
- ✅ Same packages, just from nixos-unstable (usually newer)
- ✅ Same home-manager config (all your dotfiles stay)
- ✅ Same NixOS-WSL functionality
- ✅ Exact versions locked in flake.lock
- ✅ Easy to rollback (NixOS generations)
Daily Usage
# Make config changes
vim /home/pan/dev/config/dot/nix/nixos/home.nix
# Apply
sudo nixos-rebuild switch --flake /home/pan/dev/config/dot/nix/nixos#nix --impure
# Update packages (weekly/monthly)
cd /home/pan/dev/config/dot/nix/nixos
nix flake update
sudo nixos-rebuild switch --flake .#nix --impure
# Rollback if needed
sudo nixos-rebuild switch --rollback
Create Convenience Alias
Add to your ~/.zshrc or shell config:
# Quick rebuild
alias nr='sudo nixos-rebuild switch --flake /home/pan/dev/config/dot/nix/nixos#nix --impure'
# Update and rebuild
alias nu='cd /home/pan/dev/config/dot/nix/nixos && nix flake update && sudo nixos-rebuild switch --flake .#nix --impure'
Then just run nr to rebuild!
Need Help?
- Read MIGRATION.md for detailed migration guide
- Read README.md for full documentation
- Check TODO.md for known issues