4 KiB
4 KiB
Nix Configuration
Flake-based NixOS and nix-darwin configuration with home-manager.
Commands
Daily Use
# System rebuild
sudo darwin-rebuild switch --flake .#<host> # macOS
sudo nixos-rebuild switch --flake .#<host> # NixOS
# or use alias: oss
# Home Manager
home-manager switch --flake .#yanlin@<host>
# or use alias: hms
# the full switch alias `fs` will perform system rebuild then home manager switch
# Update flake
nix flake update
Occasional Commands
# Garbage collection
nix-collect-garbage -d
sudo nix-collect-garbage -d
# Check flake
nix flake check
nix flake show
# Search packages
nix search nixpkgs <package>
# Rollback
sudo nixos-rebuild switch --rollback
sudo darwin-rebuild switch --rollback
# Build without switching
nixos-rebuild build --flake .#<host>
darwin-rebuild build --flake .#<host>
Structure
.
├── flake.nix # Entry point
├── hosts/
│ ├── darwin/ # macOS configurations
│ │ ├── system-default.nix
│ │ ├── home-default.nix
│ │ └── <host>/
│ └── nixos/ # NixOS configurations
│ ├── system-default.nix
│ ├── home-default.nix
│ └── <host>/
├── modules/ # Reusable modules
├── config/ # Static config files
└── scripts/ # Helper scripts
Modules
Modules are self-contained and handle both package installation and configuration.
borg-client.nix- Backup client with schedulingborg-server.nix- Backup server configurationbtop.nix- System monitor with vim navigationclaude-code.nix- AI coding assistant with permissions configcontainer-updater.nix- Automated container updatesdictionary.nix- Offline dictionary system (sdcv)firefox.nix- Browser with extensions and bookmarksghostty.nix- GPU-accelerated terminal emulatorgit.nix- Version control with aliaseshomebrew.nix- macOS package managementlazygit.nix- Terminal UI for gitnvim.nix- Neovim editor configurationpapis.nix- Academic reference managerplasma.nix- KDE desktop environmentpodman.nix- Container runtimersync.nix- File synchronization toolssamba.nix- SMB file sharingsmart-report.nix- Disk health monitoringssh.nix- SSH client configurationsyncthing.nix- Continuous file synchronizationtermscp.nix- Terminal file transfer clienttmux.nix- Terminal multiplexertraefik.nix- Reverse proxy with SSLwebdav.nix- WebDAV file serverwireguard.nix- VPN networkingyt-dlp.nix- Video downloaderzsh.nix- Shell with modern tools
Scripts
borg-integrity-check.sh- Verify backup repository consistencycontainer-update.sh- Update container images safelydaily-smart-report.sh- Generate disk health reportsgotify-notify.sh- Send notifications via Gotifyproject-launcher.sh- Tmux session manager for projects
Custom Workflows
Project Management
proj - Launch tmux sessions from config/projects.json
Quick Aliases
hms- Rebuild home-manageross- Rebuild system (works on both Darwin/NixOS)cdf- Interactive file search with cdpwdf- Get file path interactivelyzi- Interactive zoxide with fzf
Tmux Reminders
- Prefix:
Ctrl-a - Split:
|and- - Navigate:
hjkl - Resize:
HJKL
Git Aliases (in config)
lg- Pretty log with graphup- Pull with rebasecm- Commit with message
Service Management (NixOS)
# Check service status
systemctl status <service>
journalctl -u <service> -f
# Container management
docker ps # Actually podman
docker logs <container>
docker exec -it <container> bash
# Systemd timers
systemctl list-timers
Notes
- Borg backups need passphrase at
/etc/borg-passphrase - Container definitions use podman backend
- WireGuard configs need manual key exchange after first deploy
- Traefik handles SSL via Cloudflare DNS challenge