This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

lib.makeWrapper: add preHook support

- Add preHook parameter for running commands before exec
- Update pass tool to use preHook for GPG key import instead of custom wrapper
- Add preHook to passthru for inspection
- Update documentation with preHook examples

+21 -12
+17 -4
lib/make-wrapper.nix
··· 9 9 - `runtimeInputs`: List of packages to add to PATH (optional) 10 10 - `env`: Attribute set of environment variables to export (optional) 11 11 - `flags`: Attribute set of command-line flags to add (optional) 12 + - `preHook`: Shell script to run before executing the command (optional) 12 13 - `wrapper`: Custom wrapper function (optional, defaults to exec'ing the original binary with flags) 13 - - Called with { env, flags, envString, flagsString, exePath } 14 + - Called with { env, flags, envString, flagsString, exePath, preHook } 14 15 15 16 # Example 16 17 ··· 24 25 "--silent" = { }; # becomes --silent 25 26 "--connect-timeout" = "30"; # becomes --connect-timeout 30 26 27 }; 27 - wrapper = { exePath, flagsString, envString, ... }: '' 28 - ${envString} 28 + preHook = '' 29 29 echo "Making request..." >&2 30 + ''; 31 + } 32 + 33 + # Or with custom wrapper: 34 + makeWrapper pkgs.someProgram { 35 + wrapper = { exePath, flagsString, envString, preHook, ... }: '' 36 + ${envString} 37 + ${preHook} 38 + echo "Custom logic here" 30 39 exec ${exePath} ${flagsString} "$@" 31 40 ''; 32 41 } ··· 38 47 runtimeInputs ? [ ], 39 48 env ? { }, 40 49 flags ? { }, 50 + preHook ? "", 41 51 wrapper ? ( 42 52 { 43 53 exePath, 44 54 flagsString, 45 55 envString, 56 + preHook, 46 57 ... 47 58 }: 48 59 '' 49 60 ${envString} 61 + ${preHook} 50 62 exec ${exePath}${flagsString} "$@" 51 63 '' 52 64 ), ··· 85 97 envString 86 98 flagsString 87 99 exePath 100 + preHook 88 101 ; 89 102 }; 90 103 in ··· 99 112 package 100 113 ]; 101 114 passthru = (package.passthru or { }) // { 102 - inherit env flags; 115 + inherit env flags preHook; 103 116 }; 104 117 }; 105 118 }
+4 -8
tools/pass/flake-module.nix
··· 8 8 { 9 9 packages.pass = self.libWithPkgs.${system}.makeWrapper passWithOtp { 10 10 runtimeInputs = [ pkgs.gnupg ]; 11 - wrapper = 12 - { exePath, envString, ... }: 13 - '' 14 - ${envString} 15 - gpg --import ${self.keys.pgp.yubi.key} &>/dev/null 16 - echo '${self.keys.pgp.yubi.id}:6:' | gpg --import-ownertrust &>/dev/null 17 - exec ${exePath} "$@" 18 - ''; 11 + preHook = '' 12 + gpg --import ${self.keys.pgp.yubi.key} &>/dev/null 13 + echo '${self.keys.pgp.yubi.id}:6:' | gpg --import-ownertrust &>/dev/null 14 + ''; 19 15 }; 20 16 }; 21 17 }