From 03bd9b6ad5335aff65d9cb6fb1d117b5cb4b7919 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sat, 18 Jul 2026 14:55:21 +0530 Subject: refactor(scripts): split monolithic module into per-script submodules Extract shared `mkScript` and `mkScriptModule` helpers into `lib.nix` Split each script into `modules/scripts//` with its own `default.nix`, `script.sh`, and `assertions.nix` Remove `conditions` parameter from `mkScriptModule`; move condition assertions into per-script `assertions.nix` files with inline checks and error messages Simplify `mkScriptModule` to return `{ options, moduleConfig }` instead of a module function, taking `config` as a direct parameter Add `description` field to `mkScript` that inserts the description as a `# ` comment between the shebang and env vars Thread `description` through `mkScriptModule` to each `default.nix` Move top comment lines from each `script.sh` into the `description` field and remove from sources to avoid duplication Remove old flat `.sh` files from `modules/scripts/` root --- modules/scripts/deep-clean.sh | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 modules/scripts/deep-clean.sh (limited to 'modules/scripts/deep-clean.sh') diff --git a/modules/scripts/deep-clean.sh b/modules/scripts/deep-clean.sh deleted file mode 100644 index 5d1c87a..0000000 --- a/modules/scripts/deep-clean.sh +++ /dev/null @@ -1,33 +0,0 @@ -# Deep clean script for Nix systems -# Removes old generations, garbage, and optimizes store -# WARNING: Do NOT run with sudo - run as normal user -echo "--- Starting Nix Deep Clean ---" - -if [[ $EUID -eq 0 ]]; then - echo "Error: Do not run this script with 'sudo ./clean-nix.sh'." - echo "Run it as your normal user; it will ask for your password when needed." - exit 1 -fi - -echo "Cleaning system generations..." -sudo nix-env -p /nix/var/nix/profiles/system --delete-generations old - -if command -v home-manager &> /dev/null; then - echo "Cleaning Home Manager generations..." - home-manager expire-generations "-0 days" -fi - -echo "Cleaning user generations..." -nix-env --delete-generations old - -echo "Removing 'result' symlinks in current directory..." -find . -name "result" -type l -delete - -echo "Running Garbage Collector..." -sudo nix-collect-garbage -d -nix-collect-garbage -d - -echo "Optimising the store (deduplicating files)..." -nix store optimise - -echo "--- Clean Up Complete ---" -- cgit v1.2.3