How to get rid of old no longer used channels within gcroots?

Hey all,

I’m using NixOS since Feb 2023. I recently updated the system and run into an issue that no more disk space would be available due to inode usage.
It turns out my cleanups won’t remove old gcroot entries for channels of nixos.

ls -thl /nix/var/nix/gcroots/auto
lrwxrwxrwx 1 root root 53 28. Mär 17:13 vh3ls61k14r4fk5gcr9qcasbj7gbc0m2 -> /nix/var/nix/profiles/per-user/root/channels-122-link
lrwxrwxrwx 1 root root 53 28. Mär 17:13 vc9x8qk9mbwbix9qvywkvv0j67dfqnb5 -> /nix/var/nix/profiles/per-user/root/channels-121-link
lrwxrwxrwx 1 root root 53 28. Mär 17:13 rfqqwfjsb227n603cm1lr89fs28dr4wb -> /nix/var/nix/profiles/per-user/root/channels-120-link
lrwxrwxrwx 1 root root 53 10. Mär 21:07 1pabajbbfv8v09ybk1cwpzw5k07hjmyk -> /nix/var/nix/profiles/per-user/root/channels-119-link
lrwxrwxrwx 1 root root 53 10. Mär 21:07 pvyybrbdjwv9kmj5pbn5xqscp516fq4j -> /nix/var/nix/profiles/per-user/root/channels-118-link
lrwxrwxrwx 1 root root 53 10. Mär 21:06 pakbd7pqpcim95z3s9bsqhsbw449x5fv -> /nix/var/nix/profiles/per-user/root/channels-117-link
lrwxrwxrwx 1 root root 53  2. Mär 20:34 ks17x2n3xx8qnhifq2mrl2pf6d124jgw -> /nix/var/nix/profiles/per-user/root/channels-116-link
lrwxrwxrwx 1 root root 53  2. Mär 20:34 rd83kk9rlnw9g2kl06cnqvsbkqhgvwjm -> /nix/var/nix/profiles/per-user/root/channels-115-link
lrwxrwxrwx 1 root root 53  2. Mär 20:34 wr2i8i6sxq8342b6c0k89pvlxl2hs39r -> /nix/var/nix/profiles/per-user/root/channels-114-link
lrwxrwxrwx 1 root root 53 18. Feb 21:04 b4p59cy54wz4w8yhwp08cbxl9q06gw27 -> /nix/var/nix/profiles/per-user/root/channels-113-link
lrwxrwxrwx 1 root root 53 18. Feb 21:04 srx3a4xbvclqba2i5niixn6dg7ij9k81 -> /nix/var/nix/profiles/per-user/root/channels-112-link
lrwxrwxrwx 1 root root 53 18. Feb 21:04 760b58jfhxg61nf09xzw1i93rzdnnggi -> /nix/var/nix/profiles/per-user/root/channels-111-link
lrwxrwxrwx 1 root root 53  5. Feb 21:36 1wy63jjx72ak1dg129wip8aadg8rf5sj -> /nix/var/nix/profiles/per-user/root/channels-110-link
lrwxrwxrwx 1 root root 53  5. Feb 21:36 4ll5pxnrd8rv75jja0h4bwiwc9q43ic5 -> /nix/var/nix/profiles/per-user/root/channels-109-link
lrwxrwxrwx 1 root root 53  5. Feb 21:36 mkal9k6hyd6pwdh6i828l1y8845yrgbl -> /nix/var/nix/profiles/per-user/root/channels-108-link
lrwxrwxrwx 1 root root 53 30. Jan 19:38 m99p89qghq13v0zqfrygixnw0zgkd0gc -> /nix/var/nix/profiles/per-user/root/channels-107-link
lrwxrwxrwx 1 root root 53 30. Jan 19:38 pk3jilfclsfsfrc3hmxxid6b77h5m216 -> /nix/var/nix/profiles/per-user/root/channels-106-link
lrwxrwxrwx 1 root root 53 23. Jan 18:51 ig1im8c3rw3kvjvpb915lrp1mq2l44md -> /nix/var/nix/profiles/per-user/root/channels-105-link
lrwxrwxrwx 1 root root 53 23. Jan 18:51 hq88qx6b6h6i0ak7n804bi4q43364dva -> /nix/var/nix/profiles/per-user/root/channels-104-link
lrwxrwxrwx 1 root root 53 23. Jan 18:51 k36n7f2ffap2a7lgl1npfr4a4y3bbarh -> /nix/var/nix/profiles/per-user/root/channels-103-link
lrwxrwxrwx 1 root root 53  7. Jan 08:01 43h03mb9bwsngirs6q363n7z2szwfdms -> /nix/var/nix/profiles/per-user/root/channels-102-link
lrwxrwxrwx 1 root root 53  7. Jan 08:01 23rs9wg08lziadj8v0cyi3nadqc7hqr4 -> /nix/var/nix/profiles/per-user/root/channels-101-link
lrwxrwxrwx 1 root root 53  7. Jan 08:01 xvfkr12g7b6wl138inyn6ag2kvk2dh1m -> /nix/var/nix/profiles/per-user/root/channels-100-link
lrwxrwxrwx 1 root root 52 27. Dez 14:51 8ci5qxvq6npg5bcwiai1v4a0prbr2x9z -> /nix/var/nix/profiles/per-user/root/channels-99-link
lrwxrwxrwx 1 root root 52 27. Dez 14:51 yk9x5zicrvpr3cx6900wi1n2w93nqzvp -> /nix/var/nix/profiles/per-user/root/channels-98-link
lrwxrwxrwx 1 root root 52 27. Dez 14:50 wr2hwb1nqxhm4qq5pqvxw9vsh0sbv07k -> /nix/var/nix/profiles/per-user/root/channels-97-link
lrwxrwxrwx 1 root root 52 20. Dez 18:40 b0r4a66xbv5ybrksmhpcc3c5xgg48icv -> /nix/var/nix/profiles/per-user/root/channels-96-link
lrwxrwxrwx 1 root root 52 20. Dez 18:39 59z8y7g48hldv32yhm855yipyfswzwmn -> /nix/var/nix/profiles/per-user/root/channels-95-link
lrwxrwxrwx 1 root root 52 14. Dez 15:01 r6s594vmbsf8m55cymlbirv72bn8p4h9 -> /nix/var/nix/profiles/per-user/root/channels-94-link
lrwxrwxrwx 1 root root 52 14. Dez 15:01 3mcj7lynga5k4zfwimi0xdbl481g1ln4 -> /nix/var/nix/profiles/per-user/root/channels-93-link
lrwxrwxrwx 1 root root 52 14. Dez 15:01 mkkvk3zzpp73y8gv9i1dkis7pl8if4k8 -> /nix/var/nix/profiles/per-user/root/channels-92-link
lrwxrwxrwx 1 root root 52  8. Dez 10:21 amwzvvb7drlczmih8hq3dlb2hfnk3bpf -> /nix/var/nix/profiles/per-user/root/channels-91-link
lrwxrwxrwx 1 root root 52  8. Dez 10:21 vqsfl65hs6m8l7p7n8yh13iv9q3glszw -> /nix/var/nix/profiles/per-user/root/channels-90-link
lrwxrwxrwx 1 root root 52  8. Dez 10:21 lch0inlyj9zyrazb1vf4mby5siv3kkrp -> /nix/var/nix/profiles/per-user/root/channels-89-link
lrwxrwxrwx 1 root root 52 27. Nov 21:02 qpnvazhxpbqzmpl8950lpm9f5k6qrag2 -> /nix/var/nix/profiles/per-user/root/channels-88-link
lrwxrwxrwx 1 root root 52 27. Nov 21:01 9vsdr8xvmhaqfhfdc6dhv9gdxzraphs7 -> /nix/var/nix/profiles/per-user/root/channels-87-link
lrwxrwxrwx 1 root root 52 27. Nov 21:01 imi6nfmgnb2jqsfs0ip666f5x99liq3j -> /nix/var/nix/profiles/per-user/root/channels-86-link
lrwxrwxrwx 1 root root 52 16. Nov 2023  5qlxbfz4an5zabhcrkbj0jr0wvyibbg2 -> /nix/var/nix/profiles/per-user/root/channels-85-link
lrwxrwxrwx 1 root root 52 16. Nov 2023  vyxagans8rbnma8nr9mvy7llgqc0ykli -> /nix/var/nix/profiles/per-user/root/channels-84-link
lrwxrwxrwx 1 root root 52 13. Nov 2023  ckcjanhcgy8iai7hapbllvkq9rp8cv89 -> /nix/var/nix/profiles/per-user/root/channels-83-link
lrwxrwxrwx 1 root root 52 13. Nov 2023  v1hjnl17wdsrk922c7prr0l29k43sfb1 -> /nix/var/nix/profiles/per-user/root/channels-82-link
lrwxrwxrwx 1 root root 52  5. Nov 2023  r8qzral1mf6z8mfk7j401ng02v768f0p -> /nix/var/nix/profiles/per-user/root/channels-81-link
lrwxrwxrwx 1 root root 52  5. Nov 2023  s48drgzracs48f72iq3walmyr07xb7sf -> /nix/var/nix/profiles/per-user/root/channels-80-link
lrwxrwxrwx 1 root root 52  5. Nov 2023  8d2bngbrpm442hcy98j07r9vg8f4913r -> /nix/var/nix/profiles/per-user/root/channels-79-link
lrwxrwxrwx 1 root root 52 30. Okt 2023  pm4ax820h6qzs5b01dq4a7vg7i13car0 -> /nix/var/nix/profiles/per-user/root/channels-78-link
lrwxrwxrwx 1 root root 52 30. Okt 2023  02carg788ahj9ljwglckw1wrn3cy57cg -> /nix/var/nix/profiles/per-user/root/channels-77-link
lrwxrwxrwx 1 root root 52 25. Okt 2023  ycniirk2fwngp6l4sarzqf75gp8nqibx -> /nix/var/nix/profiles/per-user/root/channels-76-link
lrwxrwxrwx 1 root root 52 25. Okt 2023  lb0xm1hrrpxlxqfxk8yfcg0mc7zfzrx0 -> /nix/var/nix/profiles/per-user/root/channels-75-link
lrwxrwxrwx 1 root root 52 25. Okt 2023  7qipmv5ky9bk23kkr5s7zwh3gid79spp -> /nix/var/nix/profiles/per-user/root/channels-74-link
lrwxrwxrwx 1 root root 52 19. Okt 2023  avy8rm8m6cwld28631x0gm9nfj6njjgc -> /nix/var/nix/profiles/per-user/root/channels-73-link
lrwxrwxrwx 1 root root 52 19. Okt 2023  8rxqyiajrmgrhd8m16y297r1hhzlw5qv -> /nix/var/nix/profiles/per-user/root/channels-72-link
lrwxrwxrwx 1 root root 52 19. Okt 2023  yqspgbhx4vc5n6wv0n42khcavpvhn78w -> /nix/var/nix/profiles/per-user/root/channels-71-link
lrwxrwxrwx 1 root root 52  8. Okt 2023  lis6r69ai7v4kmrr4yiaylhziqz62p0f -> /nix/var/nix/profiles/per-user/root/channels-70-link
lrwxrwxrwx 1 root root 52  8. Okt 2023  p2mi584sgi0cnsal86xg1d4g2cmsin99 -> /nix/var/nix/profiles/per-user/root/channels-69-link
lrwxrwxrwx 1 root root 52  8. Okt 2023  761z1ybvw5srk154gk4gnsliz37iy994 -> /nix/var/nix/profiles/per-user/root/channels-68-link
lrwxrwxrwx 1 root root 52  4. Okt 2023  qjd649cmf8mjwlmvx67w8pk2afr44pna -> /nix/var/nix/profiles/per-user/root/channels-67-link
lrwxrwxrwx 1 root root 52  4. Okt 2023  wm0l3v6pfl9rpcbvrinnfwab6s56dr96 -> /nix/var/nix/profiles/per-user/root/channels-66-link
lrwxrwxrwx 1 root root 52  4. Okt 2023  0gva1qdf1p7hwmx1vkdb190g8573327x -> /nix/var/nix/profiles/per-user/root/channels-65-link
lrwxrwxrwx 1 root root 52 21. Sep 2023  ladxx4pvfvd4m8kn0i8k42v0wpdhgcxb -> /nix/var/nix/profiles/per-user/root/channels-64-link
lrwxrwxrwx 1 root root 52 21. Sep 2023  b71scjmq4xc5yl7hzl0y0wfplidqjika -> /nix/var/nix/profiles/per-user/root/channels-63-link
lrwxrwxrwx 1 root root 52 17. Sep 2023  ggsx531vjvlr5jzw13rk6h4969ap0xkz -> /nix/var/nix/profiles/per-user/root/channels-62-link
lrwxrwxrwx 1 root root 52 17. Sep 2023  4zz2xwnf38flm0w9ywcvvhq104kyji91 -> /nix/var/nix/profiles/per-user/root/channels-61-link
lrwxrwxrwx 1 root root 52 17. Sep 2023  5cx73p5dsbrq1r8b2cxqgidzb8dsz6z2 -> /nix/var/nix/profiles/per-user/root/channels-60-link
lrwxrwxrwx 1 root root 52  8. Sep 2023  rg59ffqf8qlfkka2h5wld919qzhk82yq -> /nix/var/nix/profiles/per-user/root/channels-59-link
lrwxrwxrwx 1 root root 52  8. Sep 2023  j471drcp7lwaqhr56fsd8hd5gwbam8kf -> /nix/var/nix/profiles/per-user/root/channels-58-link
lrwxrwxrwx 1 root root 52  8. Sep 2023  4i8pifdnllrln3jip6l47fk20jgpzvdn -> /nix/var/nix/profiles/per-user/root/channels-57-link
lrwxrwxrwx 1 root root 52 21. Aug 2023  ihm26wskx40l661kidilsmxvlqnvm11y -> /nix/var/nix/profiles/per-user/root/channels-56-link
lrwxrwxrwx 1 root root 52 21. Aug 2023  243qrv29j0blfbxpzzgli4z73shnlnjk -> /nix/var/nix/profiles/per-user/root/channels-55-link
lrwxrwxrwx 1 root root 52 21. Aug 2023  72fz5845dy47g5g4qm4p2f6vlvxh8nvr -> /nix/var/nix/profiles/per-user/root/channels-54-link
lrwxrwxrwx 1 root root 52 31. Jul 2023  gcdfm1lvnf20kmjix7hl38va4k0bcwy5 -> /nix/var/nix/profiles/per-user/root/channels-53-link
lrwxrwxrwx 1 root root 52 31. Jul 2023  qc3zmrfn9kbay9hfnz513x01z0113vsz -> /nix/var/nix/profiles/per-user/root/channels-52-link
lrwxrwxrwx 1 root root 52 31. Jul 2023  i4sy4fhk3v94z0w2d4z060ldr7jshj6d -> /nix/var/nix/profiles/per-user/root/channels-51-link
lrwxrwxrwx 1 root root 52 20. Jul 2023  9m81k5bdvh003zxv5rhniniax638ns5f -> /nix/var/nix/profiles/per-user/root/channels-50-link
lrwxrwxrwx 1 root root 52 16. Jul 2023  3jnr5irk75lf4msp7nwh760iazr78klx -> /nix/var/nix/profiles/per-user/root/channels-49-link
lrwxrwxrwx 1 root root 52 16. Jul 2023  brw9l0aggw3l0azys6gk7xfs2pczdaxn -> /nix/var/nix/profiles/per-user/root/channels-48-link
lrwxrwxrwx 1 root root 52 16. Jul 2023  pr15abzdzdjp1smdv6m8jr8h0h7c5cm8 -> /nix/var/nix/profiles/per-user/root/channels-47-link
lrwxrwxrwx 1 root root 52 14. Jun 2023  ikzrd1xc4yvk8k0647c26d53l5mwq477 -> /nix/var/nix/profiles/per-user/root/channels-46-link
lrwxrwxrwx 1 root root 52 14. Jun 2023  j8pshbvhgb6sf8m0h034kknhpqv72wj9 -> /nix/var/nix/profiles/per-user/root/channels-45-link
lrwxrwxrwx 1 root root 52 14. Jun 2023  clr2dr7q361vmqv3dq8ssn2ki4gb15sf -> /nix/var/nix/profiles/per-user/root/channels-44-link
lrwxrwxrwx 1 root root 55  9. Jun 2023  ns106914149233ps8ra00phvfd5bsybl -> /nix/var/nix/profiles/per-user/daniels/channels-29-link
lrwxrwxrwx 1 root root 52  9. Jun 2023  xfd6dyvyv6mg890y0cb12qnxk3qy248c -> /nix/var/nix/profiles/per-user/root/channels-43-link
lrwxrwxrwx 1 root root 52  9. Jun 2023  6xbjwb5y9aag6md4vgw4hb36glxk6420 -> /nix/var/nix/profiles/per-user/root/channels-42-link
lrwxrwxrwx 1 root root 52  9. Jun 2023  1220svr1wkgybg5k7p68lbqhxgv310s8 -> /nix/var/nix/profiles/per-user/root/channels-41-link
lrwxrwxrwx 1 root root 52 30. Mai 2023  amrcs6qknb59rm4cnknpglp8d4dmrsli -> /nix/var/nix/profiles/per-user/root/channels-40-link
lrwxrwxrwx 1 root root 52 25. Mai 2023  5xff2naxph0dl3q10bycq7qydpkj4b2i -> /nix/var/nix/profiles/per-user/root/channels-39-link
lrwxrwxrwx 1 root root 52 25. Mai 2023  d417wf5ycyxkxy0zdjcjm7d5wzcssr9f -> /nix/var/nix/profiles/per-user/root/channels-38-link
lrwxrwxrwx 1 root root 52 25. Mai 2023  60v4sjm6zhcacfqpvd7i689srpbhmdc2 -> /nix/var/nix/profiles/per-user/root/channels-37-link
lrwxrwxrwx 1 root root 52 14. Mai 2023  a687kzjvbv91dl87kpwmrk5i3djvjc09 -> /nix/var/nix/profiles/per-user/root/channels-36-link
lrwxrwxrwx 1 root root 52 14. Mai 2023  gl6b6r5l3hnwi06gi63dhvda08h8javb -> /nix/var/nix/profiles/per-user/root/channels-35-link
lrwxrwxrwx 1 root root 52 14. Mai 2023  zhk2m2dynnc6pcly86x78ky9dpgv1kl9 -> /nix/var/nix/profiles/per-user/root/channels-34-link
lrwxrwxrwx 1 root root 52  1. Mai 2023  m6vsfapvrq4r7cgmqa4rmxn5fxj7b36c -> /nix/var/nix/profiles/per-user/root/channels-33-link
lrwxrwxrwx 1 root root 52  1. Mai 2023  81gpr49274xbv0q712aa4clmmrxnhydn -> /nix/var/nix/profiles/per-user/root/channels-32-link
lrwxrwxrwx 1 root root 52  1. Mai 2023  3aznyrg0hrw3xz2zfi1kvjw6jsjsabki -> /nix/var/nix/profiles/per-user/root/channels-31-link
lrwxrwxrwx 1 root root 52 19. Apr 2023  nwnj08179dj36h9fly3zza0bfv2qndhy -> /nix/var/nix/profiles/per-user/root/channels-30-link
lrwxrwxrwx 1 root root 52 19. Apr 2023  icq75ljddbrd4rr6ng4jslia4jdprsfw -> /nix/var/nix/profiles/per-user/root/channels-29-link
lrwxrwxrwx 1 root root 52  8. Apr 2023  lxa2vmkcmfsxy25wvawd74g2d9gvdzvb -> /nix/var/nix/profiles/per-user/root/channels-28-link
lrwxrwxrwx 1 root root 52  8. Apr 2023  m7ag5bwfwgqv1mfil787mcsj4vz6y6as -> /nix/var/nix/profiles/per-user/root/channels-27-link
lrwxrwxrwx 1 root root 52  8. Apr 2023  bykfv9armnjl5jxsrn0j4mr1h5rghqy6 -> /nix/var/nix/profiles/per-user/root/channels-26-link
lrwxrwxrwx 1 root root 52 26. Mär 2023  qhbxp9g652b2fjk7nnav3cbbhkwv6wvb -> /nix/var/nix/profiles/per-user/root/channels-25-link
lrwxrwxrwx 1 root root 52 26. Mär 2023  pqdql5a1viizvjjkhvdw1ly40dv8xn6h -> /nix/var/nix/profiles/per-user/root/channels-24-link
lrwxrwxrwx 1 root root 52 26. Mär 2023  yrqd8bd4wd3h14lajv7dmdb54aj46b6l -> /nix/var/nix/profiles/per-user/root/channels-23-link
lrwxrwxrwx 1 root root 52 15. Mär 2023  lqzyp4anm2f73ayckfh8gfpg19wrc94w -> /nix/var/nix/profiles/per-user/root/channels-22-link
lrwxrwxrwx 1 root root 52 15. Mär 2023  i7kb6qrjlnrs041dxx4xb11hpqq0zm3h -> /nix/var/nix/profiles/per-user/root/channels-21-link
lrwxrwxrwx 1 root root 52 15. Mär 2023  ikhix3f8byv0l4mjb84jx4raq8qwgi90 -> /nix/var/nix/profiles/per-user/root/channels-20-link
lrwxrwxrwx 1 root root 52  8. Mär 2023  1xjalvl27bwf19gxc5m67yax1wmjx7ij -> /nix/var/nix/profiles/per-user/root/channels-19-link
lrwxrwxrwx 1 root root 52  8. Mär 2023  q2jkvis5gzrl5xyzbz0q8syhnzhv9iki -> /nix/var/nix/profiles/per-user/root/channels-18-link
lrwxrwxrwx 1 root root 52  6. Mär 2023  nq1c63sxxzsfi0cj1r776zvqm4m34p09 -> /nix/var/nix/profiles/per-user/root/channels-17-link
lrwxrwxrwx 1 root root 52  6. Mär 2023  xw9izvwrzv6rry77whfn971wvlc1a1rc -> /nix/var/nix/profiles/per-user/root/channels-16-link
lrwxrwxrwx 1 root root 52  6. Mär 2023  ra0kn174ha6xhypii0izc7sjqc2i3nv8 -> /nix/var/nix/profiles/per-user/root/channels-15-link
lrwxrwxrwx 1 root root 52  1. Mär 2023  9hrpki5dghbva991kxa38vxv14jmm78y -> /nix/var/nix/profiles/per-user/root/channels-14-link
lrwxrwxrwx 1 root root 52 27. Feb 2023  5savw0b4s6ig3i5jpajs9bnaq5x8k84h -> /nix/var/nix/profiles/per-user/root/channels-13-link
lrwxrwxrwx 1 root root 52 27. Feb 2023  ggwp802d1k465vzb0rswyihlqlqy08mg -> /nix/var/nix/profiles/per-user/root/channels-12-link
lrwxrwxrwx 1 root root 52 27. Feb 2023  l3apzp64v4sxhxkiyx00hszchvjy8vjw -> /nix/var/nix/profiles/per-user/root/channels-11-link
lrwxrwxrwx 1 root root 52 24. Feb 2023  67qmhjicqm08mkskdlizwr5xa6wdljss -> /nix/var/nix/profiles/per-user/root/channels-10-link
lrwxrwxrwx 1 root root 51 23. Feb 2023  5zvx69hr7fn4s3jhzzyqpwhdawf8lqg0 -> /nix/var/nix/profiles/per-user/root/channels-9-link
lrwxrwxrwx 1 root root 51 23. Feb 2023  a760sph332b2fzdx69qg25pxc9nr4kxh -> /nix/var/nix/profiles/per-user/root/channels-8-link
lrwxrwxrwx 1 root root 51 19. Feb 2023  sih2iwnjgbgkh7qwd800xdx71958qi8b -> /nix/var/nix/profiles/per-user/root/channels-7-link
lrwxrwxrwx 1 root root 51 19. Feb 2023  jyjppcn18d4ansnkqpibb4pg834kdcqc -> /nix/var/nix/profiles/per-user/root/channels-6-link
lrwxrwxrwx 1 root root 51 19. Feb 2023  i3qhrlk93kckvpqiwp3bgc79ppg1wk9j -> /nix/var/nix/profiles/per-user/root/channels-5-link
lrwxrwxrwx 1 root root 51 14. Feb 2023  snfzwvf4kn7iszcz1yvd82ic5pc1k0q3 -> /nix/var/nix/profiles/per-user/root/channels-4-link
lrwxrwxrwx 1 root root 51 14. Feb 2023  lpisgbhz4y8jkxxv6skw9b6frad5l6aj -> /nix/var/nix/profiles/per-user/root/channels-3-link
lrwxrwxrwx 1 root root 51 14. Feb 2023  phm61mw9l2zpvj3fj6pmmyk22b1l3qg8 -> /nix/var/nix/profiles/per-user/root/channels-2-link

I couldn’t find anything related to this. So how am I supposed to remove these old entries in order to free up disk space and inodes?

I’m still using channels, no flakes. nixpkgs/home/packages/custom/update-nixos-system/default.nix at main - danielsiepmann/nixpkgs - Forgejo of Daniel Siepmann is my update and clean up script.

Hi !

How many old generations do you keep ?

The last three, via this line:

sudo nix-env -p /nix/var/nix/profiles/system --delete-generations +3

Maybe there is something wrong with this line?

Do paths like /nix/var/nix/profiles/per-user/root/channels-2-link actually exist? I’m not sure that those auto gcroots would prevent them from being deleted by nix.

actually, wait, no. This line won’t delete old generations of anything other than the system profile. User profiles and channel profiles won’t be affected. You can just use sudo nix-collect-garbage --delete-older-than +3 to affect all profiles and do a GC in one command.

The path exists.

User profiles are managed via home-manager.

nix-collect-garbage --delete-older-than +3 feels to broad to me, but I’ve executed sudo nix-collect-garbage --delete-older-than 30d which deletes a lot of stuff.

I still wonder what’s the intended way to keep a NixOS with channels clean? Is it that broad command?

You just need to do nix-env -p $PROFILE --delete-generations on the desired $PROFILE. In that case, /nix/var/nix/profiles/per-user/root/channels