Add nixos config
This commit is contained in:
107
nix/nixos/QUICK_START.md
Normal file
107
nix/nixos/QUICK_START.md
Normal file
@@ -0,0 +1,107 @@
|
||||
# Quick Start Guide
|
||||
|
||||
## TL;DR - Should I Use Flakes?
|
||||
|
||||
**YES!** ✅ Use flakes because:
|
||||
|
||||
1. You get **nixos-unstable** (latest packages) with reproducibility
|
||||
2. Your config is in **git** with locked versions (flake.lock)
|
||||
3. You **already have flakes enabled** in your system
|
||||
4. It's the **modern, recommended approach**
|
||||
|
||||
## Current vs Flake Setup
|
||||
|
||||
### Current (Channels) ❌
|
||||
```bash
|
||||
# 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) ✅
|
||||
```bash
|
||||
# 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
|
||||
```bash
|
||||
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
|
||||
```bash
|
||||
sudo nixos-rebuild switch --flake .#nix --impure
|
||||
```
|
||||
|
||||
### Step 3: Verify
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
# 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:
|
||||
|
||||
```bash
|
||||
# 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](MIGRATION.md) for detailed migration guide
|
||||
- Read [README.md](README.md) for full documentation
|
||||
- Check [TODO.md](TODO.md) for known issues
|
||||
Reference in New Issue
Block a user