Skip to content

Commit 532b9e4

Browse files
stackptrclaude
andauthored
feat(home): add nixpkgs wrapper scripts to avoid permission prompts (#425)
The '#' character in 'nix eval nixpkgs#foo' breaks the claude-code permission matcher. Add nixpkgs-eval, nixpkgs-run, and nixpkgs-shell wrappers alongside the existing nix-flake wrapper, permit them in claude-code settings, and document the pattern in CLAUDE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6b7d09a commit 532b9e4

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ Custom packages and overlays are organized for clarity:
8585

8686
- Branches should be scoped to a single host whenever possible. This keeps deploys independent and reduces risk of cross-host breakage.
8787

88+
## Nix Commands
89+
90+
Never use `nix <subcommand> .#<output>` — the `#` causes permission prompt failures. Use wrapper scripts instead:
91+
92+
| Instead of | Use |
93+
|---|---|
94+
| `nix build .#foo` | `nix-flake build foo` |
95+
| `nix eval .#foo` | `nix-flake eval foo` |
96+
| `nix eval nixpkgs#foo` | `nixpkgs-eval foo` |
97+
| `nix run nixpkgs#foo` | `nixpkgs-run foo` |
98+
| `nix shell nixpkgs#foo` | `nixpkgs-shell foo` |
99+
88100
## Code style
89101

90102
- All files should end with a newline.

modules/home/development.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ in {
9292
"Bash(nix store *)"
9393
"Bash(nix why-depends *)"
9494
"Bash(nix-flake *)"
95+
"Bash(nixpkgs-eval *)"
96+
"Bash(nixpkgs-run *)"
97+
"Bash(nixpkgs-shell *)"
9598
# Git
9699
"Bash(git add *)"
97100
"Bash(git blame *)"

modules/home/utilities.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,21 @@ in {
9494
nix-flake = pkgs.writeShellScriptBin "nix-flake" ''
9595
nix "$1" ".#$2" "''${@:3}"
9696
'';
97+
nixpkgs-eval = pkgs.writeShellScriptBin "nixpkgs-eval" ''
98+
nix eval "nixpkgs#$*"
99+
'';
100+
nixpkgs-run = pkgs.writeShellScriptBin "nixpkgs-run" ''
101+
nix run "nixpkgs#$1" -- "''${@:2}"
102+
'';
103+
nixpkgs-shell = pkgs.writeShellScriptBin "nixpkgs-shell" ''
104+
nix shell "''${@/#/nixpkgs#}"
105+
'';
97106
in
98107
[
99108
nix-flake
109+
nixpkgs-eval
110+
nixpkgs-run
111+
nixpkgs-shell
100112
pkgs.manix
101113
pkgs.nix-du
102114
pkgs.nix-tree

0 commit comments

Comments
 (0)