From af9105e7ac0d16a53ada789831839fbb7b5388c6 Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Sun, 27 Apr 2025 16:41:57 -0400 Subject: [PATCH] Refactor bin to fix argument passing. --- pkgs/default.nix | 20 ++++++++++++++++++-- readme.md | 10 ++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pkgs/default.nix b/pkgs/default.nix index 230ecb4..3a31457 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -14,10 +14,26 @@ let cp ${../share/fish/completions}/yay.fish $out/share/fish/completions/ ''; - # Create main yay binary that uses fish's function path + # Create main yay binary that correctly passes args to fish yayBin = pkgs.writeShellScriptBin "yay" '' FUNCTIONS_DIR=$(dirname $(dirname $0))/share/fish/functions - exec ${lib.getExe pkgs.fish} -c "set fish_function_path \$fish_function_path $FUNCTIONS_DIR; source $FUNCTIONS_DIR/yay.fish; yay_function $@" + + # Create a temporary script to handle command execution + TEMP_SCRIPT=$(mktemp -t yay-command.XXXXXX) + + # Write the fish commands to the script + cat > $TEMP_SCRIPT << EOF + #!/usr/bin/env fish + set fish_function_path \$fish_function_path $FUNCTIONS_DIR + source $FUNCTIONS_DIR/yay.fish + yay_function $@ + EOF + + # Execute the script + ${lib.getExe pkgs.fish} $TEMP_SCRIPT "$@" + + # Clean up + rm $TEMP_SCRIPT ''; in pkgs.symlinkJoin { diff --git a/readme.md b/readme.md index 1500d8f..2d748f2 100644 --- a/readme.md +++ b/readme.md @@ -162,9 +162,15 @@ If theres a command you think would be useful to add let me know, I might agree. ## Technical Details -Yay.nix is implemented as a collection of fish functions that are installed into your system's fish function path. The main `yay` command is a bash script that invokes fish with the correct environment to execute the functions. +Yay.nix is implemented as a collection of fish functions that are installed into your system's fish function path. The main `yay` command is a bash script that: -All commands and options have competitions making the tool easy to use interactively +1. Creates a temporary fish script +2. Sets up the fish function path to include the installed functions +3. Sources the main yay.fish file +4. Passes all command-line arguments to the appropriate fish function +5. Cleans up after execution + +All commands and options have completions making the tool easy to use interactively. ## License