commit a0c972fce5b2641b38b9272acf087181587ccf4f
parent 6a0fdd23c4ba1ed7c35d33ff22079d889dbc099c
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Fri, 22 Aug 2025 18:48:35 +0200
parent 6a0fdd23c4ba1ed7c35d33ff22079d889dbc099c
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Fri, 22 Aug 2025 18:48:35 +0200
packages: add `nix-cleanup`
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/packages/nix-cleanup/nix-cleanup.sh b/packages/nix-cleanup/nix-cleanup.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eu + +# Delete everything from this profile that isn't currently needed +nix-env --delete-generations old + +# Delete generations older than a week +nix-collect-garbage +nix-collect-garbage --delete-older-than 7d + +# Optimize +nix-store --gc --print-dead +nix-store --optimise
diff --git a/packages/nix-cleanup/package.nix b/packages/nix-cleanup/package.nix @@ -0,0 +1,26 @@ +{ + tgcMaintainers, + lib, + stdenvNoCC, + ... +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "nix-cleanup"; + version = "0.0.0.1"; + + dontUnpack = true; + src = ./nix-cleanup.sh; + + postInstall = '' + mkdir -p $out/bin + install --mode +x $src $out/bin/nix-cleanup + ''; + + meta = { + description = "Just a tiny helper to clean up your nix store!"; + license = [ lib.licenses.mit ]; + platforms = lib.platforms.linux; + maintainers = [ tgcMaintainers.zaphyra ]; + }; +})