From 7bb8f702dc5e5f708b74c44ea62ce1d393546d50 Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Thu, 29 May 2025 00:01:35 -0400 Subject: [PATCH] Enhance __yay_rebuild function to include experimental features flag and update help message formatting --- functions/__yay_rebuild.fish | 31 ++++++++++++++++++++++--------- pkgs/default.nix | 10 +++++----- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/functions/__yay_rebuild.fish b/functions/__yay_rebuild.fish index 2ab83a1..b6d30f3 100644 --- a/functions/__yay_rebuild.fish +++ b/functions/__yay_rebuild.fish @@ -1,12 +1,13 @@ function __yay_rebuild - set -l opts h/help 'p/path=' 'H/host=' t/trace + set -l opts h/help 'p/path=' 'H/host=' t/trace e/experimental argparse $opts -- $argv; or return if set -q _flag_help echo "Usage: yay rebuild [OPTIONS]" - echo " -p, --path PATH Path to the Nix configuration (overrides FLAKE)" - echo " -H, --host HOST Hostname to build for (default: current hostname)" - echo " -t, --trace Enable trace output" - echo " -h, --help Show this help message" + echo " -h, --help Show this help message" + echo " -e, --experimental Enable experimental features (flakes and nix-commands)" + echo " -H, --host HOST Hostname to build for (default: current hostname)" + echo " -p, --path PATH Path to the Nix configuration (overrides FLAKE)" + echo " -t, --trace Enable trace output" return end set flake_path (__yay_get_flake_path $_flag_path); or return @@ -19,10 +20,22 @@ function __yay_rebuild __yay_green "««« REBUILDING NIXOS ($host) »»»" set orig (pwd) cd $flake_path + + # Base command + set -l cmd "nh os switch . -H $host -- --impure" + + # Add trace if requested if set -q _flag_trace - __yay_run "nh os switch . -H $host -- --impure --show-trace" - else - __yay_run "nh os switch . -H $host -- --impure" + set cmd "$cmd --show-trace" end + + # Add experimental features if requested + if set -q _flag_experimental + set cmd "$cmd --extra-experimental-features flakes --extra-experimental-features nix-commands" + end + + # Run the command + __yay_run $cmd + cd $orig -end \ No newline at end of file +end diff --git a/pkgs/default.nix b/pkgs/default.nix index 091c4cf..4e123a1 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -17,10 +17,10 @@ let # Create main yay binary that correctly passes args to fish yayBin = pkgs.writeShellScriptBin "yay" '' FUNCTIONS_DIR=$(dirname $(dirname $0))/share/fish/functions - + # 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 @@ -28,10 +28,10 @@ let source $FUNCTIONS_DIR/yay.fish yay_function $@ EOF - + # Execute the script ${lib.getExe pkgs.fish} $TEMP_SCRIPT "$@" - + # Clean up rm $TEMP_SCRIPT ''; @@ -69,4 +69,4 @@ pkgs.symlinkJoin { platforms = platforms.unix; maintainers = [ "Tophc7" ]; }; -} \ No newline at end of file +}