feat: add agenix secret add/delete support - #656
feat: add agenix secret add/delete support#656Scott McMaster (scottmcmaster) wants to merge 2 commits into
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🎨 Storybook previewUpdated for b76a140
|
📋 PR Overview
🔬 Coverage
|
There was a problem hiding this comment.
Caution
The agenix diff preview hardcodes ../../secrets/${slug}.age as the file path, which is only correct when the declaration module lives at exactly modules/darwin/agenix-secrets.nix (two directorie...
apps/native/src/components/widget/secrets/add-secret-view.tsx:24
1 finding(s) posted as inline comments.
There was a problem hiding this comment.
Pull request overview
This PR implements agenix secret add and delete support in nixmac, bringing the agenix backend to feature parity with the existing SOPS flow. Both flows encrypt/remove a per-secret .age file, edit the classic agenix rules file and the age.secrets declaration module, verify with a darwin-rebuild dry build, and commit — with bounded rollback on failure. The frontend gains a backend toggle (sops-nix / agenix) in the add-secret form and backend-aware copy across the apply and delete UIs. The change also includes DRY refactoring: shared helpers ensure_clean_repo, restore_repo_files_on_failure, and verify_dry_build_for_secret_edit; extracted sops_config_path / discover_agenix_rules_path / match_agenix_secret_entries in recipients.rs; and a new remove_attrpath_in_file plus quote-aware split_attrpath_for_match in nix_file_editor.rs.
Changes:
- Implement
add_age_secret/delete_age_secretwith agenix rules + declaration editing, age encryption over stdin, dry-build verification, and rollback. - Refactor shared secret-edit safety helpers and agenix rule discovery/matching; add quote-aware attrpath splitting so keys like
"api.token.age"resolve correctly. - Frontend: backend selector in the add-secret form, backend-aware recipient filtering/empty-state, and agenix-aware copy in the apply sheet and delete dialog.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/native/src-tauri/src/secrets/secrets_management.rs | Core agenix add/delete logic, shared clean-repo/verify/rollback helpers, agenix rule/declaration writers and tests. |
| apps/native/src-tauri/src/secrets/recipients.rs | Extracts sops_config_path, discover_agenix_rules_path, and match_agenix_secret_entries; adjusts debug logging. |
| apps/native/src-tauri/src/evolve/nix_file_editor.rs | Adds quote-aware split_attrpath_for_match and filesystem remove_attrpath_in_file, with tests. |
| apps/native/src/components/widget/secrets/add-secret-view.tsx | Backend toggle, backend-specific paths/copy, registration-based recipient filtering, empty-state message. |
| apps/native/src/components/widget/secrets/secret-detail-view.tsx | canDelete allows agenix regardless of local decrypt capability; backend-aware delete dialog copy. |
| apps/native/src/components/widget/secrets/apply-sheet.tsx | Derives backend-specific encryption label ("age"/"SOPS"/fallback) for review and applying states. |
| apps/native/src/components/widget/secrets/types.ts | Adds optional backend field to ApplyRequest. |
| apps/native/src/components/widget/secrets/secrets-management.tsx | Generalizes the add-secret failure message to be backend-agnostic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f5d297c to
b76a140
Compare
f4ee943 to
6593ba3
Compare






Summary
Implement the agenix secret add/delete analogous to what we did for SOPS. (Not including screenshots since there's no practical difference in the UI.)
Also includes some related DRY refactoring in secrets_management.rs and recipients.rs.
Test Plan
Some new unit tests where possible/appropriate, plus manual e2e testing with my test config repo.
Docs