-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
# nixos-config
My NixOS configuration files for my laptop and the server running this site.
## Cheatsheet
Prefer the new `nix` CLI when possible instead of the old `nix-*` commands. It's way better.
| Task | Command |
| --- | --- |
| Run program | `nix run nixpkgs#hello` (needs `--` if passing args) |
| Run program from another Nixpkgs repo | `nix run github:Toby222/nixpkgs#space-station-14-launcher` |
| Clean Nix store | `run0 nix-collect-garbage && nix store optimise` |
| Get size of Nix store | `sqlite3 /nix/var/nix/db/db.sqlite 'SELECT SUM(narSize) FROM ValidPaths'` |
| Get largest packages | `sqlite3 /nix/var/nix/db/db.sqlite 'SELECT * FROM ValidPaths ORDER BY narSize DESC LIMIT 50'` |
| Check if anything depends on path | `nix-store --query --referrers /nix/store/blah` |
| List system generations | `nixos-rebuild list-generations` |
| Switch to generation | `run0 nix-env --switch-generation 1234 -p /nix/var/nix/profiles/system && run0 /nix/var/nix/profiles/system/bin/switch-to-configuration switch` |
| Run Nix file | `nix eval -f main.nix` |
| Build VM from config | `nixos-rebuild build-vm` |
| Deploy using signing key | `LOCAL_KEY=key deploy -s .` |
| Run AppImage | `appimage-run blah.AppImage` |
| Get changes between system generations | `nix profile diff-closures --profile /nix/var/nix/profiles/system` |
| Install specific version of package | https://lazamar.co.uk/nix-versions/ |
| Inspect system config in REPL | `nix repl .#nixosConfigurations.$hostname` |