From cb837f0cabb0dd097302205c7256a1834a6d8bf3 Mon Sep 17 00:00:00 2001 From: WitteShadovv <26429638+WitteShadovv@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:25:09 +0200 Subject: [PATCH] docs: switch project license to GPL-3.0-or-later --- LICENSE | 149 +++--- README.md | 4 +- plan.md | 1378 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1461 insertions(+), 70 deletions(-) create mode 100644 plan.md diff --git a/LICENSE b/LICENSE index 0ad25db..f288702 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies @@ -7,15 +7,17 @@ Preamble - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to +the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free -software for all its users. +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you @@ -24,34 +26,44 @@ them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. @@ -60,7 +72,7 @@ modification follow. 0. Definitions. - "This License" refers to version 3 of the GNU Affero General Public License. + "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. @@ -537,45 +549,35 @@ to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. + 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single +under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General +Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published +GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's +versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. @@ -633,29 +635,40 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. + GNU General Public License for more details. - You should have received a copy of the GNU Affero General Public License + You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see +For more information on this, and how to apply and follow the GNU GPL, see . + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 910c77d..ba9eff3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Deferred Apps [![CI](https://github.com/WitteShadovv/deferred-apps/actions/workflows/ci.yml/badge.svg)](https://github.com/WitteShadovv/deferred-apps/actions/workflows/ci.yml) -[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE) +[![License: GPL-3.0-or-later](https://img.shields.io/badge/License-GPL--3.0--or--later-blue.svg)](LICENSE) **Apps appear in your launcher but only download when first launched.** @@ -484,4 +484,4 @@ Use comma for CLI tools; use Deferred Apps for GUI applications you want in your ## License -[AGPL-3.0-or-later](LICENSE) +Deferred Apps is licensed under the GNU General Public License, version 3 or any later version ([GPL-3.0-or-later](LICENSE)). diff --git a/plan.md b/plan.md new file mode 100644 index 0000000..50bb27e --- /dev/null +++ b/plan.md @@ -0,0 +1,1378 @@ +# Deferred Apps - Ralph Wiggum Development Plan + +DOT'T CHANGE, DELETE OR CREATE ANY FILES OR FOLDERS OUTSIDE OF THE PROJECT REPO! + +DON'T RUN COMMANDS THAT USE PATHS FROM OUTSIDE THE PROJECT REPO! + +> **RALPH PHILOSOPHY**: When the agent fails, don't just fix the code — fix the prompt. Erect signs so the next loop doesn't have to rediscover fire. +> +> *"Ralph is deterministically bad in an undeterministic world."* + +--- + +## Table of Contents + +1. [Ralph Wiggum Methodology](#ralph-wiggum-methodology) +2. [Project Context](#project-context) +3. [Quality Gates](#quality-gates) +4. [Requirements](#requirements) + - [REQ-001: CLI-Only Mode](#req-001-cli-only-mode) + - [REQ-002: Status CLI Tool](#req-002-status-cli-tool) + - [REQ-003: GC Management CLI](#req-003-gc-management-cli) + - [REQ-004: Preload CLI Tool](#req-004-preload-cli-tool) + - [REQ-005: Progress Mode](#req-005-progress-mode) + - [REQ-006: Application Groups](#req-006-application-groups) + - [REQ-007: Notification Customization](#req-007-notification-customization) + - [REQ-008: NixOS VM Integration Tests](#req-008-nixos-vm-integration-tests) + - [REQ-009: nixpkgs Submission Readiness](#req-009-nixpkgs-submission-readiness) +5. [Signs (Lessons Learned)](#signs-lessons-learned) +6. [Completion Checklist](#completion-checklist) + +--- + +## Ralph Wiggum Methodology + +### Core Principles + +1. **Iteration > Perfection**: Don't aim for perfect on first try. Let the loop refine the work. +2. **Failures Are Data**: Deterministically bad means failures are predictable and informative. +3. **Operator Skill Matters**: Success depends on writing good prompts, not just having a good model. +4. **Persistence Wins**: Keep trying until success. The loop handles retry logic. + +### How to Use This Plan + +Each requirement (REQ-XXX) is designed to be executed as a single Ralph loop: + +```bash +/ralph-wiggum:ralph-loop "" --completion-promise "COMPLETE" --max-iterations 30 +``` + +Requirements are structured with: +- **Clear completion criteria** (exact conditions for success) +- **Self-correction patterns** (what to do when tests fail) +- **Verification commands** (automated checks) +- **Signs** (guardrails from past failures) + +### Loop Execution Pattern + +``` +1. Read the requirement +2. Write failing test (TDD) +3. Implement minimal code to pass +4. Run verification commands +5. If any fail → fix and retry from step 3 +6. If all pass → output COMPLETE +``` + +--- + +## Project Context + +### What Is Deferred Apps? + +Deferred Apps creates lightweight wrapper scripts (~5KB) that appear as installed applications in your desktop launcher, but only download the actual package on first launch. Perfect for apps you rarely use but want available. + +### Current State (Completed) + +- [x] Core library (`package.nix`) with `mkDeferredApp`, `mkDeferredPackages` +- [x] NixOS and Home Manager modules +- [x] Two modes: pname (nix shell) and package (nix-store -r) +- [x] Icon resolution with Papirus theme (icons COPIED, not referenced) +- [x] Collision detection for terminal commands +- [x] GC root support +- [x] Nested package support (python313Packages.numpy) +- [x] Comprehensive test suite + +### Community Feedback Addressed + +- [x] @arianvp: Use `nix-store --realise` → Implemented as package mode +- [x] Closure optimization → Icons copied (~5KB) not referenced (~1GB) +- [ ] CLI tools support → REQ-001 +- [ ] Status tracking → REQ-002 +- [ ] Preload for offline use → REQ-004 + +--- + +## Quality Gates + +### Mandatory Verification (Run After EVERY Change) + +```bash +# ALL of these must pass before marking any task complete +nix flake check # All tests pass +statix check . # No linter warnings +deadnix --fail -L . # No dead code +nix fmt -- --check # Proper formatting +``` + +### Quality Gate Protocol + +``` +IF any verification fails: + 1. Fix the issue + 2. Re-run ALL verifications + 3. Repeat until ALL pass + 4. Only then proceed to next step + +DO NOT skip verification steps. +DO NOT mark tasks complete with failing checks. +``` + +--- + +## Requirements + +--- + +### REQ-001: CLI-Only Mode + +**Priority**: HIGH +**Estimated Iterations**: 15-25 +**Dependencies**: None + +#### Rationale + +Users want deferred apps for CLI tools (ripgrep, fd, jq), not just GUI applications. Currently, all deferred apps create `.desktop` files and resolve icons, which is unnecessary overhead for terminal-only tools. + +#### User Stories + +1. As a user, I want to defer CLI tools without creating desktop files +2. As a user, I want faster builds when deferring CLI-only tools (no icon lookup) +3. As a user, I want a convenient module option for listing CLI apps + +#### Acceptance Criteria + +- [ ] `mkDeferredApp { package = pkgs.ripgrep; cliOnly = true; }` creates wrapper WITHOUT .desktop file +- [ ] `mkDeferredApp { pname = "fd"; cliOnly = true; }` works the same way +- [ ] CLI-only wrappers have terminal command symlink in `$out/bin/` +- [ ] CLI-only wrappers do NOT have `$out/share/applications/` directory +- [ ] CLI-only wrappers do NOT have `$out/share/icons/` directory +- [ ] Build time is measurably faster (no icon theme scanning) +- [ ] Module option `programs.deferredApps.cliPackages` accepts list of packages +- [ ] Module option `programs.deferredApps.cliApps` accepts list of pnames +- [ ] All existing tests continue to pass +- [ ] New tests cover all CLI-only scenarios + +#### Test Requirements + +Create `tests/cli-mode.nix` with these test cases: + +```nix +# Test 1: CLI-only has bin symlink +cli-mode-has-bin = mkBuildCheck "cli-mode-has-bin" + (deferredAppsLib.mkDeferredApp { package = pkgs.ripgrep; cliOnly = true; }) + '' + test -L "$out/bin/rg" || { echo "FAIL: missing bin symlink"; exit 1; } + echo "PASS: bin symlink exists" + ''; + +# Test 2: CLI-only has NO desktop file +cli-mode-no-desktop = mkBuildCheck "cli-mode-no-desktop" + (deferredAppsLib.mkDeferredApp { package = pkgs.ripgrep; cliOnly = true; }) + '' + if [ -d "$out/share/applications" ]; then + echo "FAIL: cli-only should not have share/applications" + exit 1 + fi + echo "PASS: no desktop directory" + ''; + +# Test 3: CLI-only has NO icons +cli-mode-no-icons = mkBuildCheck "cli-mode-no-icons" + (deferredAppsLib.mkDeferredApp { package = pkgs.ripgrep; cliOnly = true; }) + '' + if [ -d "$out/share/icons" ]; then + echo "FAIL: cli-only should not have share/icons" + exit 1 + fi + echo "PASS: no icons directory" + ''; + +# Test 4: CLI-only with pname mode +cli-mode-pname = mkBuildCheck "cli-mode-pname" + (deferredAppsLib.mkDeferredApp { pname = "fd"; cliOnly = true; }) + '' + test -L "$out/bin/fd" || { echo "FAIL: missing bin symlink"; exit 1; } + test ! -d "$out/share/applications" || { echo "FAIL: has desktop dir"; exit 1; } + echo "PASS: pname cli-only works" + ''; + +# Test 5: Module cliPackages option +cli-mode-module-packages = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + cliPackages = [ pkgs.ripgrep pkgs.fd ]; + }; + }; +in mkCheck "cli-mode-module-packages" ( + builtins.length eval.config.environment.systemPackages >= 2 +); + +# Test 6: Default cliOnly is false (backward compatibility) +cli-mode-default-false = mkBuildCheck "cli-mode-default-false" + (deferredAppsLib.mkDeferredApp { package = pkgs.hello; }) + '' + test -d "$out/share/applications" || { echo "FAIL: default should have desktop"; exit 1; } + echo "PASS: default has desktop file" + ''; +``` + +#### Implementation Steps + +1. **Add `cliOnly` parameter to `mkDeferredApp`** in `package.nix`: + - Default: `false` + - When `true`: skip desktop file creation, skip icon resolution + +2. **Modify derivation build script** to conditionally create directories: + ```bash + if [ -z "$cliOnly" ]; then + # Create desktop file and icons + mkdir -p "$out/share/applications" "$out/share/icons" + # ... existing icon/desktop logic + fi + ``` + +3. **Add module options** in `modules/shared.nix`: + ```nix + cliPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = []; + description = "CLI tools to defer (no desktop files created)"; + }; + + cliApps = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + description = "CLI tool names to defer (no desktop files created)"; + }; + ``` + +4. **Update `buildDeferredPackages`** to handle CLI apps with `cliOnly = true` + +5. **Add tests** to `tests/cli-mode.nix` + +6. **Update README** with CLI-only documentation + +#### Verification Commands + +```bash +# Run after implementation +nix flake check +nix build .#checks.x86_64-linux.cli-mode-has-bin +nix build .#checks.x86_64-linux.cli-mode-no-desktop +nix build .#checks.x86_64-linux.cli-mode-no-icons +nix build .#checks.x86_64-linux.cli-mode-pname +nix build .#checks.x86_64-linux.cli-mode-module-packages +nix build .#checks.x86_64-linux.cli-mode-default-false +statix check . +deadnix --fail -L . +nix fmt -- --check +``` + +#### Signs (Guardrails) + +- DO NOT break backward compatibility - `cliOnly` defaults to `false` +- DO NOT skip icon resolution for non-cliOnly apps +- DO NOT forget to update collision detection for CLI apps +- DO test both package mode AND pname mode with cliOnly +- DO update the module's `buildDeferredPackages` to pass cliOnly + +#### Completion Promise + +When ALL of the following are true: +- All 6 test cases pass +- All existing tests still pass +- `nix flake check` passes +- `statix check .` has no warnings +- `deadnix --fail -L .` finds no dead code +- `nix fmt -- --check` passes + +Output: `COMPLETE` + +--- + +### REQ-002: Status CLI Tool + +**Priority**: HIGH +**Estimated Iterations**: 20-30 +**Dependencies**: None + +#### Rationale + +Users want to know which deferred apps have been downloaded vs which are still pending. This is especially useful for: +- Checking disk usage of deferred apps +- Knowing which apps will work offline +- Debugging download issues + +#### User Stories + +1. As a user, I want to see a list of all my deferred apps +2. As a user, I want to know which apps are downloaded vs pending +3. As a user, I want to see how much disk space downloaded apps use +4. As a user, I want JSON output for scripting + +#### Acceptance Criteria + +- [ ] `deferred-apps status` shows all deferred apps with download status +- [ ] Status shows: app name, status (downloaded/pending), size (if downloaded) +- [ ] `deferred-apps status --json` outputs machine-readable JSON +- [ ] `deferred-apps status ` shows status of specific app +- [ ] Tool is automatically available when module is enabled +- [ ] Works for both package mode and pname mode apps +- [ ] Exit code 0 on success, non-zero on error + +#### Test Requirements + +Create tests in `tests/status-cli.nix`: + +```nix +# Test 1: Status CLI exists +status-cli-exists = let + statusPkg = pkgs.callPackage ../cli/status.nix { + inherit (deferredAppsLib) getPnameFromPackage; + }; +in mkBuildCheck "status-cli-exists" statusPkg '' + test -x "$out/bin/deferred-apps" || { echo "FAIL: missing binary"; exit 1; } + "$out/bin/deferred-apps" --help | grep -q "status" || { echo "FAIL: no status cmd"; exit 1; } + echo "PASS: status CLI exists" +''; + +# Test 2: Status CLI has subcommands +status-cli-subcommands = let + statusPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "status-cli-subcommands" statusPkg '' + "$out/bin/deferred-apps" status --help | grep -q "json" || { echo "FAIL: no --json"; exit 1; } + echo "PASS: has expected options" +''; + +# Test 3: Module includes status CLI +status-cli-in-module = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + packages = [ pkgs.hello ]; + }; + }; + hasStatusCli = builtins.any (p: + (p.pname or p.name or "") == "deferred-apps-cli" + ) eval.config.environment.systemPackages; +in mkCheck "status-cli-in-module" hasStatusCli; + +# Test 4: JSON output is valid +status-cli-json-valid = let + statusPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "status-cli-json-valid" statusPkg '' + # Create mock registry for testing + mkdir -p $TMPDIR/deferred-apps + echo '{"apps":{"hello":{"outPath":"/nix/store/xxx-hello"}}}' > $TMPDIR/deferred-apps/registry.json + + output=$("$out/bin/deferred-apps" status --json --registry "$TMPDIR/deferred-apps/registry.json" 2>/dev/null || true) + echo "$output" | ${pkgs.jq}/bin/jq . > /dev/null || { echo "FAIL: invalid JSON"; exit 1; } + echo "PASS: valid JSON output" +''; +``` + +#### Implementation Steps + +1. **Create CLI package** at `cli/status.nix`: + ```nix + { pkgs, lib, ... }: + pkgs.writeShellApplication { + name = "deferred-apps"; + runtimeInputs = with pkgs; [ jq coreutils nix ]; + text = builtins.readFile ./deferred-apps.sh; + } + ``` + +2. **Create CLI script** at `cli/deferred-apps.sh`: + - Subcommand: `status [--json] [app-name]` + - Read registry from `~/.local/share/deferred-apps/registry.json` + - Check store paths existence with `nix path-info` + - Calculate sizes with `nix path-info --size` + +3. **Create registry mechanism**: + - Module generates registry JSON at build time + - Contains: app name → store path mapping + - Registry placed in `$out/share/deferred-apps/registry.json` + +4. **Update module** to include CLI and registry: + ```nix + environment.systemPackages = [ statusCli ]; + environment.etc."deferred-apps/registry.json".source = registryJson; + ``` + +5. **Add tests** to flake checks + +#### Output Format + +Text format (default): +``` +Deferred Apps Status +==================== +App Status Size +---------------------------------------- +spotify downloaded 245 MB +discord pending - +obs-studio downloaded 189 MB +---------------------------------------- +Total downloaded: 2/3 (434 MB) +``` + +JSON format (`--json`): +```json +{ + "apps": [ + {"name": "spotify", "status": "downloaded", "size_bytes": 257000000, "path": "/nix/store/..."}, + {"name": "discord", "status": "pending", "size_bytes": null, "path": "/nix/store/..."}, + {"name": "obs-studio", "status": "downloaded", "size_bytes": 198000000, "path": "/nix/store/..."} + ], + "summary": { + "total": 3, + "downloaded": 2, + "pending": 1, + "total_size_bytes": 455000000 + } +} +``` + +#### Verification Commands + +```bash +nix flake check +nix build .#checks.x86_64-linux.status-cli-exists +nix build .#checks.x86_64-linux.status-cli-subcommands +nix build .#checks.x86_64-linux.status-cli-in-module +nix build .#checks.x86_64-linux.status-cli-json-valid +statix check . +deadnix --fail -L . +nix fmt -- --check +``` + +#### Signs (Guardrails) + +- DO NOT hardcode paths - use XDG_DATA_HOME with fallback +- DO NOT assume apps are always in nix store - check existence +- DO handle missing registry gracefully (empty list, not error) +- DO use `nix path-info` not manual store inspection +- DO make JSON output parseable by jq + +#### Completion Promise + +When ALL of the following are true: +- CLI tool builds and has `status` subcommand +- Text and JSON output formats work +- Module automatically includes the CLI +- All tests pass +- All quality gates pass + +Output: `COMPLETE` + +--- + +### REQ-003: GC Management CLI + +**Priority**: MEDIUM +**Estimated Iterations**: 15-25 +**Dependencies**: REQ-002 (shares CLI infrastructure) + +#### Rationale + +When `gcRoot = true`, downloaded packages are protected from garbage collection. Users need a way to: +- See what's protected +- Clean up when disk space is needed +- Understand disk usage impact + +#### User Stories + +1. As a user, I want to list all GC-protected deferred apps +2. As a user, I want to see total size of GC roots +3. As a user, I want to remove all GC roots to reclaim space +4. As a user, I want to remove GC root for specific app + +#### Acceptance Criteria + +- [ ] `deferred-apps gc list` shows all GC roots +- [ ] `deferred-apps gc status` shows total size +- [ ] `deferred-apps gc clean` removes all GC roots +- [ ] `deferred-apps gc clean ` removes specific app's GC root +- [ ] `deferred-apps gc clean --dry-run` shows what would be removed +- [ ] Confirmation prompt before destructive operations (unless `--yes`) +- [ ] Works with existing GC root directory structure + +#### Test Requirements + +```nix +# Test 1: GC list command exists +gc-cli-list = let + cliPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "gc-cli-list" cliPkg '' + "$out/bin/deferred-apps" gc --help | grep -q "list" || { echo "FAIL: no list"; exit 1; } + echo "PASS: gc list exists" +''; + +# Test 2: GC clean has dry-run +gc-cli-dry-run = let + cliPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "gc-cli-dry-run" cliPkg '' + "$out/bin/deferred-apps" gc clean --help | grep -q "dry-run" || { echo "FAIL: no dry-run"; exit 1; } + echo "PASS: has dry-run option" +''; + +# Test 3: GC clean requires confirmation +gc-cli-confirmation = let + cliPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "gc-cli-confirmation" cliPkg '' + # Should fail without --yes when no tty + if echo "" | "$out/bin/deferred-apps" gc clean 2>/dev/null; then + echo "FAIL: should require confirmation" + exit 1 + fi + echo "PASS: requires confirmation" +''; +``` + +#### Implementation Steps + +1. **Add `gc` subcommand** to CLI: + - `gc list` - enumerate `~/.local/share/deferred-apps/gcroots/` + - `gc status` - sum sizes of all roots + - `gc clean [--yes] [--dry-run] [app]` - remove roots + +2. **GC root directory structure**: + ``` + ~/.local/share/deferred-apps/gcroots/ + ├── spotify -> /nix/store/xxx-spotify + ├── discord -> /nix/store/xxx-discord + └── obs-studio -> /nix/store/xxx-obs-studio + ``` + +3. **Safety features**: + - Confirmation prompt (bypass with `--yes`) + - Dry-run mode + - Clear error messages + +#### Verification Commands + +```bash +nix flake check +nix build .#checks.x86_64-linux.gc-cli-list +nix build .#checks.x86_64-linux.gc-cli-dry-run +nix build .#checks.x86_64-linux.gc-cli-confirmation +statix check . +deadnix --fail -L . +nix fmt -- --check +``` + +#### Signs (Guardrails) + +- DO NOT delete without confirmation (unless --yes) +- DO NOT fail if gcroots directory doesn't exist (just show empty) +- DO use `readlink -f` to resolve symlinks for size calculation +- DO handle broken symlinks gracefully + +#### Completion Promise + +When ALL tests pass and quality gates pass: +Output: `COMPLETE` + +--- + +### REQ-004: Preload CLI Tool + +**Priority**: MEDIUM +**Estimated Iterations**: 20-30 +**Dependencies**: REQ-002 (shares CLI infrastructure) + +#### Rationale + +Users want to pre-download apps before going offline (travel, conferences, etc.). This is a common request from the community. + +#### User Stories + +1. As a user, I want to download all deferred apps at once +2. As a user, I want to download specific apps by name +3. As a user, I want to see progress during downloads +4. As a user, I want downloads to continue if one fails + +#### Acceptance Criteria + +- [ ] `deferred-apps preload` downloads all pending apps +- [ ] `deferred-apps preload spotify discord` downloads specific apps +- [ ] Shows progress: "Downloading 1/5: spotify..." +- [ ] Continues on failure, reports failures at end +- [ ] `--parallel N` option for concurrent downloads (default: 1) +- [ ] Exit code indicates success (0) or partial failure (1) + +#### Test Requirements + +```nix +# Test 1: Preload command exists +preload-cli-exists = let + cliPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "preload-cli-exists" cliPkg '' + "$out/bin/deferred-apps" preload --help || { echo "FAIL: no preload"; exit 1; } + echo "PASS: preload exists" +''; + +# Test 2: Preload has parallel option +preload-cli-parallel = let + cliPkg = pkgs.callPackage ../cli/status.nix {}; +in mkBuildCheck "preload-cli-parallel" cliPkg '' + "$out/bin/deferred-apps" preload --help | grep -q "parallel" || { echo "FAIL: no parallel"; exit 1; } + echo "PASS: has parallel option" +''; +``` + +#### Implementation Steps + +1. **Add `preload` subcommand**: + - Read registry for app → store path mapping + - For each app: run `nix-store -r ` + - Track success/failure + - Report summary + +2. **Progress display**: + ``` + Preloading deferred apps... + [1/5] spotify: downloading... done (245 MB) + [2/5] discord: downloading... done (312 MB) + [3/5] obs-studio: downloading... FAILED (network error) + [4/5] blender: downloading... done (1.2 GB) + [5/5] gimp: downloading... done (89 MB) + + Summary: 4/5 succeeded, 1 failed + Failed: obs-studio + ``` + +3. **Parallel downloads** (optional enhancement): + - Use `xargs -P` or GNU parallel + - Default to sequential for safety + +#### Verification Commands + +```bash +nix flake check +nix build .#checks.x86_64-linux.preload-cli-exists +nix build .#checks.x86_64-linux.preload-cli-parallel +statix check . +deadnix --fail -L . +nix fmt -- --check +``` + +#### Signs (Guardrails) + +- DO NOT exit early on first failure - complete all downloads +- DO report which apps failed at the end +- DO use appropriate exit codes (0 = all success, 1 = partial failure) +- DO NOT require root/sudo for downloads + +#### Completion Promise + +When ALL tests pass and quality gates pass: +Output: `COMPLETE` + +--- + +### REQ-005: Progress Mode + +**Priority**: MEDIUM +**Estimated Iterations**: 15-20 +**Dependencies**: None + +#### Rationale + +Different users want different feedback during downloads: +- GUI users: desktop notifications +- Terminal users: progress bars +- Scripts: no output (just exit codes) + +#### User Stories + +1. As a terminal user, I want to see download progress in my terminal +2. As a script author, I want silent operation +3. As a GUI user, I want notifications (current default) + +#### Acceptance Criteria + +- [ ] `progressMode = "notification"` (default) - uses notify-send +- [ ] `progressMode = "terminal"` - prints progress to stderr +- [ ] `progressMode = "none"` - silent operation +- [ ] Per-app override via extraApps +- [ ] Module option `programs.deferredApps.progressMode` + +#### Test Requirements + +```nix +# Test 1: Terminal progress mode +progress-mode-terminal = mkBuildCheck "progress-mode-terminal" + (deferredAppsLib.mkDeferredApp { package = pkgs.hello; progressMode = "terminal"; }) + '' + grep -q 'PROGRESS_MODE="terminal"' "$out/libexec/deferred-hello" || \ + { echo "FAIL: terminal mode not set"; exit 1; } + echo "PASS: terminal mode set" + ''; + +# Test 2: None progress mode +progress-mode-none = mkBuildCheck "progress-mode-none" + (deferredAppsLib.mkDeferredApp { package = pkgs.hello; progressMode = "none"; }) + '' + grep -q 'PROGRESS_MODE="none"' "$out/libexec/deferred-hello" || \ + { echo "FAIL: none mode not set"; exit 1; } + # Should not have notify-send call when mode is none + if grep -q 'notify-send' "$out/libexec/deferred-hello" | grep -v 'PROGRESS_MODE'; then + : # notify-send might still be referenced but guarded + fi + echo "PASS: none mode set" + ''; + +# Test 3: Default is notification +progress-mode-default = mkBuildCheck "progress-mode-default" + (deferredAppsLib.mkDeferredApp { package = pkgs.hello; }) + '' + grep -q 'PROGRESS_MODE="notification"' "$out/libexec/deferred-hello" || \ + { echo "FAIL: default should be notification"; exit 1; } + echo "PASS: default is notification" + ''; + +# Test 4: Module option works +progress-mode-module = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + packages = [ pkgs.hello ]; + progressMode = "terminal"; + }; + }; +in mkCheck "progress-mode-module" (eval.config.programs.deferredApps.progressMode == "terminal"); +``` + +#### Implementation Steps + +1. **Add `progressMode` parameter** to `mkDeferredApp`: + - Type: enum ["notification" "terminal" "none"] + - Default: "notification" + +2. **Update wrapper script** to respect mode: + ```bash + PROGRESS_MODE="@progressMode@" + + show_progress() { + case "$PROGRESS_MODE" in + notification) + notify-send --app-name="Deferred Apps" "$1" "$2" & + ;; + terminal) + echo "[deferred-apps] $1: $2" >&2 + ;; + none) + : # silent + ;; + esac + } + ``` + +3. **Add module option**: + ```nix + progressMode = lib.mkOption { + type = lib.types.enum [ "notification" "terminal" "none" ]; + default = "notification"; + description = "How to show download progress"; + }; + ``` + +4. **Add per-app override** in extraApps submodule + +#### Verification Commands + +```bash +nix flake check +nix build .#checks.x86_64-linux.progress-mode-terminal +nix build .#checks.x86_64-linux.progress-mode-none +nix build .#checks.x86_64-linux.progress-mode-default +nix build .#checks.x86_64-linux.progress-mode-module +statix check . +deadnix --fail -L . +nix fmt -- --check +``` + +#### Signs (Guardrails) + +- DO NOT break existing notification behavior (it's the default) +- DO use stderr for terminal output (not stdout) +- DO keep notify-send optional (graceful degradation) + +#### Completion Promise + +When ALL tests pass and quality gates pass: +Output: `COMPLETE` + +--- + +### REQ-006: Application Groups + +**Priority**: MEDIUM +**Estimated Iterations**: 25-35 +**Dependencies**: None + +#### Rationale + +Users often want to defer entire categories of apps with shared settings: +- "Multimedia apps I rarely use" (all with gcRoot=true) +- "Dev tools" (all from unstable channel) +- "Games" (all unfree) + +#### User Stories + +1. As a user, I want to group apps by category +2. As a user, I want to apply shared settings to a group +3. As a user, I want to enable/disable entire groups + +#### Acceptance Criteria + +- [ ] `programs.deferredApps.groups..packages` accepts list of packages +- [ ] `programs.deferredApps.groups..apps` accepts list of pnames +- [ ] Groups can set: `gcRoot`, `flakeRef`, `allowUnfree`, `progressMode` +- [ ] `programs.deferredApps.groups..enable` defaults to true +- [ ] Setting `enable = false` disables entire group +- [ ] Group settings are overridable per-app via extraApps +- [ ] Collision detection works across groups + +#### Test Requirements + +```nix +# Test 1: Basic group with packages +groups-basic-packages = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + groups.multimedia = { + packages = [ pkgs.vlc pkgs.mpv ]; + gcRoot = true; + }; + }; + }; +in mkCheck "groups-basic-packages" ( + builtins.length eval.config.environment.systemPackages >= 2 +); + +# Test 2: Group with apps (pnames) +groups-basic-apps = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + groups.tools = { + apps = [ "hello" "cowsay" ]; + }; + }; + }; +in mkCheck "groups-basic-apps" ( + builtins.length eval.config.environment.systemPackages >= 2 +); + +# Test 3: Disabled group produces no packages +groups-disabled = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + groups.unused = { + enable = false; + packages = [ pkgs.hello pkgs.cowsay ]; + }; + }; + }; + # Should only have libnotify, not hello/cowsay wrappers +in mkCheck "groups-disabled" ( + builtins.length eval.config.environment.systemPackages <= 2 +); + +# Test 4: Group settings inherited +groups-settings-inherited = let + eval = evalNixosModule { + programs.deferredApps = { + enable = true; + groups.protected = { + packages = [ pkgs.hello ]; + gcRoot = true; + progressMode = "terminal"; + }; + }; + }; +in mkCheck "groups-settings-inherited" ( + eval.config.programs.deferredApps.groups.protected.gcRoot == true +); + +# Test 5: Collision detection across groups +groups-collision = let + result = builtins.tryEval (evalNixosModule { + programs.deferredApps = { + enable = true; + groups.a = { packages = [ pkgs.hello ]; }; + groups.b = { packages = [ pkgs.hello ]; }; # Collision! + }; + }); +in mkCheck "groups-collision" (!result.success); +``` + +#### Implementation Steps + +1. **Define group submodule** in `shared.nix`: + ```nix + groupModule = lib.types.submodule { + options = { + enable = lib.mkEnableOption "this app group" // { default = true; }; + packages = lib.mkOption { type = lib.types.listOf lib.types.package; default = []; }; + apps = lib.mkOption { type = lib.types.listOf lib.types.str; default = []; }; + gcRoot = lib.mkOption { type = lib.types.bool; default = false; }; + flakeRef = lib.mkOption { type = lib.types.str; default = "nixpkgs"; }; + allowUnfree = lib.mkOption { type = lib.types.bool; default = false; }; + progressMode = lib.mkOption { + type = lib.types.enum [ "notification" "terminal" "none" ]; + default = "notification"; + }; + }; + }; + ``` + +2. **Add groups option**: + ```nix + groups = lib.mkOption { + type = lib.types.attrsOf groupModule; + default = {}; + description = "Named groups of deferred apps with shared settings"; + }; + ``` + +3. **Update `buildDeferredPackages`** to iterate over enabled groups + +4. **Extend collision detection** to include all group packages + +#### Verification Commands + +```bash +nix flake check +nix build .#checks.x86_64-linux.groups-basic-packages +nix build .#checks.x86_64-linux.groups-basic-apps +nix build .#checks.x86_64-linux.groups-disabled +nix build .#checks.x86_64-linux.groups-settings-inherited +nix build .#checks.x86_64-linux.groups-collision +statix check . +deadnix --fail -L . +nix fmt -- --check +``` + +#### Signs (Guardrails) + +- DO NOT forget to check collisions across ALL groups +- DO NOT ignore disabled groups in collision check (they should be excluded) +- DO propagate group settings to individual apps +- DO allow extraApps to override group settings + +#### Completion Promise + +When ALL tests pass and quality gates pass: +Output: `COMPLETE` + +--- + +### REQ-007: Notification Customization + +**Priority**: LOW +**Estimated Iterations**: 10-15 +**Dependencies**: None +**Status**: ✅ COMPLETE + +#### Rationale + +Users want to customize notification text for branding or localization. + +#### Acceptance Criteria + +- [x] `notificationTitle` option overrides "Starting {app}..." +- [x] `notificationBody` option overrides "Downloading application..." +- [x] `showNotification = false` disables notifications entirely +- [x] Per-app override via extraApps + +#### Test Requirements + +```nix +# Test 1: Custom title +notification-custom-title = mkBuildCheck "notification-custom-title" + (deferredAppsLib.mkDeferredApp { + package = pkgs.hello; + notificationTitle = "Loading {app}"; + }) + '' + grep -q 'Loading {app}' "$out/libexec/deferred-hello" || \ + { echo "FAIL: custom title not used"; exit 1; } + echo "PASS: custom title works" + ''; + +# Test 2: Show notification false +notification-disabled = mkBuildCheck "notification-disabled" + (deferredAppsLib.mkDeferredApp { + package = pkgs.hello; + showNotification = false; + }) + '' + grep -q 'SHOW_NOTIFICATION="0"' "$out/libexec/deferred-hello" || \ + { echo "FAIL: notification should be disabled"; exit 1; } + echo "PASS: notification disabled" + ''; +``` + +#### Implementation Steps + +1. Add options: `notificationTitle`, `notificationBody`, `showNotification` +2. Update wrapper script template +3. Add to module options and extraApps submodule + +#### Verification Commands + +```bash +nix flake check +``` + +#### Signs (Guardrails) + +- DO NOT break existing notification behavior (it's the default) +- DO use stderr for notifications (not stdout) +- DO keep notify-send optional (graceful degradation) + +#### Completion Promise + +When ALL tests pass and quality gates pass: +Output: `COMPLETE` + +--- + +### REQ-008: NixOS VM Integration Tests + +**Priority**: HIGH +**Estimated Iterations**: 30-40 +**Dependencies**: REQ-001 through REQ-004 (optional, but recommended) + +#### Rationale + +Some behaviors can only be verified in a full NixOS system: +- Desktop files linked into system profile +- Icons available to desktop environment +- Wrapper scripts executable with correct paths +- Module integration with environment.systemPackages + +#### Acceptance Criteria + +- [ ] VM test boots NixOS with deferred-apps module +- [ ] Verifies desktop files in `/run/current-system/sw/share/applications/` +- [ ] Verifies icons in `/run/current-system/sw/share/icons/` +- [ ] Verifies wrapper in `/run/current-system/sw/libexec/` +- [ ] Verifies terminal command in `/run/current-system/sw/bin/` +- [ ] Test runs as part of `nix flake check` + +#### Test Requirements + +Create `tests/vm.nix`: + +```nix +{ pkgs, lib, self, system }: + +let + nixosTest = pkgs.nixosTest or pkgs.testers.nixosTest; +in { + vm-integration = nixosTest { + name = "deferred-apps-integration"; + + nodes.machine = { pkgs, ... }: { + imports = [ self.nixosModules.default ]; + + programs.deferredApps = { + enable = true; + apps = [ "hello" ]; + packages = [ pkgs.cowsay ]; + }; + + # Minimal VM config + virtualisation.memorySize = 1024; + }; + + testScript = '' + machine.wait_for_unit("multi-user.target") + + # Test 1: Desktop file exists for pname mode + machine.succeed("test -f /run/current-system/sw/share/applications/hello.desktop") + + # Test 2: Desktop file exists for package mode + machine.succeed("test -f /run/current-system/sw/share/applications/cowsay.desktop") + + # Test 3: Wrapper scripts exist + machine.succeed("test -x /run/current-system/sw/libexec/deferred-hello") + machine.succeed("test -x /run/current-system/sw/libexec/deferred-cowsay") + + # Test 4: Terminal commands exist + machine.succeed("test -L /run/current-system/sw/bin/hello") + machine.succeed("test -L /run/current-system/sw/bin/cowsay") + + # Test 5: Icons exist (Papirus theme) + machine.succeed("test -d /run/current-system/sw/share/icons") + + # Test 6: Desktop file content is correct + machine.succeed("grep -q 'Exec=.*/libexec/deferred-hello' /run/current-system/sw/share/applications/hello.desktop") + + # Test 7: Wrapper is executable and runs (will fail to download, but should start) + result = machine.execute("timeout 5 /run/current-system/sw/libexec/deferred-hello --version 2>&1 || true") + # Should either succeed or fail with network/nix error, not permission error + assert "Permission denied" not in result[1], f"Permission error: {result[1]}" + ''; + }; +} +``` + +#### Implementation Steps + +1. **Create `tests/vm.nix`** with nixosTest definition +2. **Import in `tests/default.nix`**: + ```nix + vmTests = import ./vm.nix { inherit pkgs lib self system; }; + ``` +3. **Add to flake checks** (conditional on x86_64-linux due to VM support) +4. **Ensure test runs in CI** (may need KVM or QEMU) + +#### Verification Commands + +```bash +# Build and run VM test +nix build .#checks.x86_64-linux.vm-integration + +# Or run interactively for debugging +nix build .#checks.x86_64-linux.vm-integration.driverInteractive +./result/bin/nixos-test-driver +``` + +#### Signs (Guardrails) + +- DO NOT require network access in VM tests (use local store) +- DO set reasonable timeouts (VMs are slow) +- DO use minimal VM config (less memory = faster CI) +- DO test both pname AND package mode + +#### Completion Promise + +When VM test passes and all quality gates pass: +Output: `COMPLETE` + +--- + +### REQ-009: nixpkgs Submission Readiness + +**Priority**: CRITICAL +**Estimated Iterations**: 40-60 +**Dependencies**: REQ-001 through REQ-008 + +#### Rationale + +The ultimate goal is to submit deferred-apps to nixpkgs for community benefit and long-term maintenance. + +#### Acceptance Criteria + +- [ ] All functions have documentation comments +- [ ] All module options have type, default, description, example +- [ ] No `builtins.currentSystem` usage +- [ ] No hardcoded paths +- [ ] License is nixpkgs-compatible (GPL-3.0-or-later is fine) +- [ ] README documents all features +- [ ] ARCHITECTURE.md explains design decisions +- [ ] CONTRIBUTING.md exists +- [ ] Security model documented +- [ ] Benchmarks documented +- [ ] All tests pass on x86_64-linux and aarch64-linux + +#### Checklist + +**Code Quality**: +- [ ] `statix check .` - zero warnings +- [ ] `deadnix --fail -L .` - zero findings +- [ ] `nix fmt -- --check` - all formatted +- [ ] All public functions documented +- [ ] All options have examples + +**Documentation**: +- [ ] README.md complete with all features +- [ ] ARCHITECTURE.md explains: + - Why wrappers are in `/libexec` + - Why icons are copied not referenced + - Package mode vs pname mode trade-offs + - Security model +- [ ] CONTRIBUTING.md with: + - Development setup + - Test running instructions + - Code style guidelines + +**Security**: +- [ ] No shell injection vulnerabilities +- [ ] No arbitrary code execution paths +- [ ] `--impure` usage documented and justified +- [ ] GC root security implications documented + +**Testing**: +- [ ] Unit tests for all library functions +- [ ] Integration tests for modules +- [ ] VM tests for full system +- [ ] Tests pass on both x86_64 and aarch64 + +#### Verification Commands + +```bash +# Full verification suite +nix flake check +statix check . +deadnix --fail -L . +nix fmt -- --check + +# Multi-arch (if available) +nix build .#checks.x86_64-linux --all +nix build .#checks.aarch64-linux --all # Requires aarch64 builder +``` + +#### Completion Promise + +When ALL checklist items are complete and ALL verification passes: +Output: `COMPLETE` + +--- + +## Signs (Lessons Learned) + +> **RALPH PHILOSOPHY**: When Ralph falls off the slide, add a sign saying "SLIDE DOWN, DON'T JUMP" + +This section accumulates lessons learned during development. Update after each failure. + +### Architecture Signs + +``` +SIGN: Wrappers go in /libexec, symlinks in /bin +WHY: Prevents PATH pollution, follows FHS conventions + +SIGN: Icons are COPIED not referenced +WHY: Referencing pulls ~1GB Papirus theme into closure + +SIGN: Use unsafeDiscardStringContext for store paths +WHY: Prevents .drv files from polluting system closure + +SIGN: Package mode uses nix-store -r, then --realise fallback +WHY: Cache fetch is fast, local build is fallback + +SIGN: Pname mode uses nix shell with flake ref +WHY: Dynamic resolution at runtime, no build-time dependency +``` + +### Testing Signs + +``` +SIGN: Use mkCheck for pure assertions +WHY: No build required, fast evaluation + +SIGN: Use mkBuildCheck for derivation inspection +WHY: Need to examine build output + +SIGN: Use mkClosureCheck for size verification +WHY: Closure size is critical metric + +SIGN: Test names: prefix with category (lib-, pkg-, module-) +WHY: Easy to identify test scope in output +``` + +### Common Pitfalls + +``` +SIGN: Don't use builtins.currentSystem +WHY: Breaks flake purity, use system from args + +SIGN: Don't reference icon theme package in closure +WHY: ~1GB dependency for ~5KB icon + +SIGN: Always check terminal command collisions +WHY: Multiple packages can have same mainProgram + +SIGN: Default cliOnly to false +WHY: Breaking change if default is true +``` + +### Module Signs + +``` +SIGN: Use lib.mkDefault for environment variables +WHY: Allow user overrides + +SIGN: Include libnotify in systemPackages +WHY: Notifications need notify-send + +SIGN: pathsToLink includes share/applications and share/icons +WHY: Desktop files and icons must be in system profile +``` + +--- + +## Completion Checklist + +### Phase 1: CLI Features +- [ ] REQ-001: CLI-Only Mode +- [ ] REQ-002: Status CLI Tool +- [ ] REQ-003: GC Management CLI +- [ ] REQ-004: Preload CLI Tool + +### Phase 2: UX Improvements +- [ ] REQ-005: Progress Mode +- [ ] REQ-006: Application Groups +- [ ] REQ-007: Notification Customization + +### Phase 3: Quality & Submission +- [ ] REQ-008: NixOS VM Integration Tests +- [ ] REQ-009: nixpkgs Submission Readiness + +### Final Verification + +```bash +# Run this when ALL requirements are complete +nix flake check && \ +statix check . && \ +deadnix --fail -L . && \ +nix fmt -- --check && \ +echo "ALL QUALITY GATES PASSED" +``` + +When all checkboxes are checked and final verification passes: +**PROJECT COMPLETE** - Ready for nixpkgs submission! + +--- + +## Agent Instructions + +When working on any requirement: + +1. **READ THE REQUIREMENT COMPLETELY** before starting +2. **WRITE TESTS FIRST** (TDD) - verify they fail before implementing +3. **IMPLEMENT MINIMAL CODE** to pass tests +4. **RUN ALL VERIFICATIONS** after every change +5. **FIX FAILURES IMMEDIATELY** - do not accumulate debt +6. **UPDATE SIGNS** if you discover new pitfalls +7. **MARK CHECKBOXES** as complete only when verified + +```bash +# After EVERY change: +nix flake check && statix check . && deadnix --fail -L . && nix fmt -- --check +``` + +**When all verifications pass for a requirement:** +``` +COMPLETE +``` + +**If stuck after 10+ iterations:** +1. Document what's blocking in Signs section +2. List attempted approaches +3. Suggest alternative solutions +4. Output: `BLOCKED` + +--- + +*Remember: Ralph is deterministically bad in an undeterministic world. Embrace the loop.*