Skip to content

Commit 7768a6e

Browse files
committed
updated nix.md
1 parent 9516cec commit 7768a6e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

nix.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
# Nix
22

3+
## Garbage Collecting Error - Disk Full
4+
5+
If you try to
6+
7+
# cd /nix/var/nix/db
8+
# nix-shell -p sqlite
9+
10+
[nix-shell:/nix/var/nix/db]# sqlite3 db.sqlite ".backup 'db.bak.sqlite' "
11+
12+
[nix-shell:/nix/var/nix/db]# sqlite3 db.sqlite
13+
SQLite version 3.24.0 2018-06-04 19:24:41
14+
Enter ".help" for usage hints.
15+
sqlite> .output db.sql
16+
sqlite> .dump
17+
sqlite>
18+
19+
[nix-shell:/nix/var/nix/db]# sqlite3 db.new.sqlite < db.sql
20+
21+
[nix-shell:/nix/var/nix/db]# mv db.new.sqlite db.sqlite
22+
```
23+
24+
---
25+
nix-env --delete-generations old
26+
nix-collect-garbage
27+
sudo nix-collect-garbage
28+
We're down to 19.1 GiB
29+
Let's do a full rebuild and make sure we're as compact as possible. Note that this removes old generations, make sure your system is stable first.
30+
nix-channel --update
31+
sudo nix-channel --update
32+
sudo rm /nix/var/nix/gcroots/auto/*
33+
nix-collect-garbage -d
34+
sudo nix-collect-garbage -d
35+
Down to 9.4 GiB
36+
By hardlinking identical files we can save some additional space:
37+
sudo nix-store --optimize
38+
Now we're down to a nice trim 9.0 GiB - a savings of 15.1 GiB at the cost of losing some history.
39+
Note that any shells you have will have to be rebuilt or refetched.
40+
Pruning docker
41+
I use docker for application development, this was done before but can save considerable space:
42+
docker system prune
43+
Note that this will delete a whole bunch of stuff, if you have any data not stored in volumes it will be lost.
44+
Clearing your .cache folder
45+
My .cache folder stands at 9.9 GiB
46+
The highest amount is currently spotify. By editing ~/.config/spotify/prefs and adding:
47+
storage.size=2048
48+
then restarting spotify it will trim down its storage.
49+
Next up is yarn.
50+
yarn cache clean
51+
saves me another 2.1 GiB
52+
~/.local/share/Trash has considerable data in it, which after quick verification doesn't have anything I care about.
53+
rm -rf ~/.local/share/Trash/files/*
54+
rm -rf ~/.local/share/Trash/files/.*
55+
After this I spent a bit poking around in ncdu and deleting old projects and forks that were not longer used.
56+
57+
---
58+
359
## Get sha256 of URL or URL tarball
460
561
```bash

0 commit comments

Comments
 (0)