Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabe Automatic Garbage Collection #14

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

laksith19
Copy link
Member

removes old nix store files from generations older than 30 days every week. these numbers are kinda arbitrary

Verified

This commit was signed with the committer’s verified signature.
laksith19 Laksith Prabu
@singingtelegram singingtelegram dismissed their stale review February 19, 2025 07:30

see oliver comment

Verified

This commit was signed with the committer’s verified signature.
laksith19 Laksith Prabu
@laksith19
Copy link
Member Author

yea that was my stupidity but made it home and this builds without errors now

@laksith19
Copy link
Member Author

just wanted to know if u guys had opinions on the frequency / amount of old generations we preserve. and if we need to preserve old generations on the host at all

@singingtelegram
Copy link
Member

singingtelegram commented Feb 19, 2025 via email

Verified

This commit was signed with the committer’s verified signature.
laksith19 Laksith Prabu

Verified

This commit was signed with the committer’s verified signature.
laksith19 Laksith Prabu
@laksith19
Copy link
Member Author

laksith19 commented Feb 20, 2025

@singingtelegram yea i agree loll, that felt more "correct" but it's not as clean as keeping the prev 30 days but this should basically have the intended effect. the systemd service will delete old generations and the automatic garbage collector will just clean all un-referenced paths. tested on pumpkin and it seems to work.

Logs from pumpkin deleting profiles
root@pumpkin ~                                                                                                                
> systemctl status nix-remove-profiles.service            
○ nix-remove-profiles.service - Remove old NixOS generations but leave store cleanup to nix.gc
     Loaded: loaded (/etc/systemd/system/nix-remove-profiles.service; linked; preset: ignored)
     Active: inactive (dead) since Wed 2025-02-19 19:47:53 PST; 17min ago
 Invocation: d9317ce5d439405d8633c607dfffbf9d
TriggeredBy: ● nix-remove-profiles.timer
    Process: 85460 ExecStart=/nix/store/ipcqj7j75q1vr2fd1dfjk9yr4i2b2a48-unit-script-nix-remove-profiles-start/bin/nix-remove->
   Main PID: 85460 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
         IO: 312K read, 0B written
   Mem peak: 6.9M
        CPU: 72ms

Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 124
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 125
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 126
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 127
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 128
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 129
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 130
Feb 19 19:47:53 pumpkin nix-remove-profiles-start[85473]: removing profile version 131
Feb 19 19:47:53 pumpkin systemd[1]: nix-remove-profiles.service: Deactivated successfully.
Feb 19 19:47:53 pumpkin systemd[1]: Finished Remove old NixOS generations but leave store cleanup to nix.gc.

Logs from pumpkin garbage collecting nix store
root@pumpkin ~                                                                                                                
> systemctl status nix-gc.service
○ nix-gc.service - Nix Garbage Collector
     Loaded: loaded (/etc/systemd/system/nix-gc.service; linked; preset: ignored)
     Active: inactive (dead) since Wed 2025-02-19 20:00:23 PST; 4min 33s ago
 Invocation: 5c4492f8a8ea41afadb6f2367fa92628
TriggeredBy: ● nix-gc.timer
    Process: 85870 ExecStart=/nix/store/9w8gmhhkh2spbgj7nx9q701xra62ys59-unit-script-nix-gc-start/bin/nix-gc-start (code=exite>
   Main PID: 85870 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
         IO: 4.7G read, 6.3G written
   Mem peak: 5.1G
        CPU: 3min 40.776s

Feb 19 20:00:22 pumpkin nix-gc-start[85870]: deleting '/nix/store/yxksbqrq1dw7arrzmnqaqg8skrv2krch-hsqldb_1_8_0.zip.drv'
Feb 19 20:00:22 pumpkin nix-gc-start[85870]: deleting '/nix/store/mnjxbp0pv3qfill7aiwy71sinhdhvx1x-source.drv'
Feb 19 20:00:22 pumpkin nix-gc-start[85870]: deleting '/nix/store/4aqmxb68hldq1cnh6kj2ylzlqsi65vf5-lfs64.patch.drv'
Feb 19 20:00:22 pumpkin nix-gc-start[85870]: deleting '/nix/store/ys6kgil219cpfy8fhdgnz3rj22lrs3c8-crate-idna-0.3.0.tar.gz.drv'
Feb 19 20:00:22 pumpkin nix-gc-start[85870]: deleting unused links...
Feb 19 20:00:22 pumpkin nix-gc-start[85870]: note: currently hard linking saves -0.00 MiB
Feb 19 20:00:23 pumpkin nix-gc-start[85870]: 63418 store paths deleted, 87451.44 MiB freed
Feb 19 20:00:23 pumpkin systemd[1]: nix-gc.service: Deactivated successfully.
Feb 19 20:00:23 pumpkin systemd[1]: Finished Nix Garbage Collector.
Feb 19 20:00:23 pumpkin systemd[1]: nix-gc.service: Consumed 3min 40.776s CPU time, 5.1G memory peak, 4.7G read from disk, 6.3>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants