From 96d456edc253d9a22de2978040087a90919168b7 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 13 May 2026 00:44:18 -0700 Subject: [PATCH] nixos: add daily Rust target sweep --- .../agents/skills/disk-space-cleanup/SKILL.md | 2 + nixos/imalison.nix | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/dotfiles/agents/skills/disk-space-cleanup/SKILL.md b/dotfiles/agents/skills/disk-space-cleanup/SKILL.md index ef95b79b..67e42f85 100644 --- a/dotfiles/agents/skills/disk-space-cleanup/SKILL.md +++ b/dotfiles/agents/skills/disk-space-cleanup/SKILL.md @@ -112,6 +112,8 @@ Recommended sequence: Machine-specific note: - Project-local `.worktrees/*/target` directories are common cleanup wins on this machine and are easy to miss with the old hard-coded workflow. +- `cargo-sweep` is installed through the NixOS `code.nix` package set, but stale manually-installed binaries under `~/.cargo/bin` can shadow `/run/current-system/sw/bin/cargo-sweep`. If `cargo sweep` fails with a missing loader or `No such file or directory`, run `type -a cargo-sweep` and remove the stale `~/.cargo/bin/cargo-sweep` entry. +- `nixos/imalison.nix` defines a daily user timer, `cargo-sweep-rust-targets.timer`, that runs `cargo-sweep sweep -r --hidden --maxsize 15GB` across `/home/imalison/Projects`, `/home/imalison/org`, and `/home/imalison/dotfiles`. ## Step 4: Investigation with `ncdu` and `du` diff --git a/nixos/imalison.nix b/nixos/imalison.nix index e5e62952..b272b12e 100644 --- a/nixos/imalison.nix +++ b/nixos/imalison.nix @@ -1,5 +1,16 @@ {pkgs, ...}: let session = import ./session-variables.nix; + cargoSweepRustTargets = pkgs.writeShellApplication { + name = "cargo-sweep-rust-targets"; + runtimeInputs = [pkgs.cargo-sweep]; + text = '' + for root in /home/imalison/Projects /home/imalison/org /home/imalison/dotfiles; do + if [[ -d "$root" ]]; then + cargo-sweep sweep -r --hidden --maxsize 15GB "$root" + fi + done + ''; + }; in { home-manager.users.imalison = { imports = [ @@ -52,6 +63,33 @@ in { }; }; + systemd.user.services.cargo-sweep-rust-targets = { + Unit = { + Description = "Sweep Rust target directories"; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${cargoSweepRustTargets}/bin/cargo-sweep-rust-targets"; + }; + }; + + systemd.user.timers.cargo-sweep-rust-targets = { + Unit = { + Description = "Sweep Rust target directories daily"; + }; + + Timer = { + OnCalendar = "daily"; + Persistent = true; + RandomizedDelaySec = "2h"; + }; + + Install = { + WantedBy = ["timers.target"]; + }; + }; + systemd.user.services.hyprpaper = let hyprpaperConf = pkgs.writeText "hyprpaper.conf" '' ipc = true