2.1 KiB
2.1 KiB
Quick Reference
Essential Commands
# Rebuild system with new configuration
sudo
nixos-rebuild
switch - -flake.#nxs
# Test without making permanent changes
sudo nixos-rebuild
test - -flake.#nxs
# Build without activating
sudo nixos-rebuild
build - -flake.#nxs
# Check flake syntax
nix flake
check
# Update all dependencies
nix
flake
update
# Search for packages
nix
search
nixpkgs <package-name>
File Layout
|
Path |
Purpose |
| - -----|---------|
| flake.nix | Main flake entry point |
| hosts/nxs/default.nix |
System
configuration |
| hosts/nxs/hardware.nix |
Hardware
settings |
| hosts/nxs/home.nix |
User
environment |
| modules/system/ |
Reusable
system
modules |
| modules/home/ |
Reusable
user
modules |
Quick Edits
bash
# Edit system config
vim hosts/nxs/default.nix
# Edit user packages/programs
vim hosts/nxs/home.nix
# Edit Neovim config
vim modules/home/neovim/default.nix
# Add language support to Neovim
vim modules/home/neovim/languages/
<lang>.nix
Where to Add Things
| What | Where | File | | - -----|-------|------| | System package | hosts/nxs/ | default.nix → environment.systemPackages | | User package | hosts/nxs/ | home.nix → home.packages | | System service | modules/system/ | relevant-module.nix | | User program config | modules/home/ | program-name.nix | | Boot settings | modules/system/ | boot.nix | | Desktop/GUI | modules/system/ | desktop.nix |
Git Workflow
bash
# Check status
git
status
# View changes
git
diff
# Stage all changes
git
add - A
# Commit
git
commit - m "description"
# Push
git
push
Maintenance
bash
# Clean old generations (7 days)
sudo
nix-collect-garbage - -delete-older-than 7 d
# Optimize store
nix-store - -optimise
# List generations
sudo
nix-env - -list-generations - -profile /nix/var/nix/profiles/system
# Rollback
sudo
nixos-rebuild
switch - -rollback