From c71e12c0909529d0276327a610d4126111e27398 Mon Sep 17 00:00:00 2001 From: Juan Barbat Date: Sun, 23 Aug 2026 20:38:21 -0300 Subject: [PATCH] fix(fish): restore Linux Nix profile path on login --- fish/conf.d/10-core.fish | 8 ++++++++ fish/tests/w2-core.fish | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/fish/conf.d/10-core.fish b/fish/conf.d/10-core.fish index 0e28632..59fe42d 100644 --- a/fish/conf.d/10-core.fish +++ b/fish/conf.d/10-core.fish @@ -41,6 +41,14 @@ else end set -gx VISUAL "$EDITOR" +if test (uname) = Linux + for nix_profile_bin in /nix/var/nix/profiles/default/bin "$HOME/.nix-profile/bin" + if test -d "$nix_profile_bin" + fish_add_path --path --move "$nix_profile_bin" + end + end +end + alias g git alias gs 'git status' alias ga 'git add' diff --git a/fish/tests/w2-core.fish b/fish/tests/w2-core.fish index 85b8214..ccc4386 100644 --- a/fish/tests/w2-core.fish +++ b/fish/tests/w2-core.fish @@ -34,6 +34,10 @@ function run_fish env -i HOME="$home" USER=test-user LOGNAME=test-user XDG_CONFIG_HOME="$xdg" PATH="$bin:/usr/bin:/bin" TERM=xterm-256color LANG=C "$fish_bin" $argv end +function run_clean_fish + env -i HOME="$home" USER=test-user LOGNAME=test-user XDG_CONFIG_HOME="$xdg" PATH="$bin:/usr/bin:/bin" TERM=xterm-256color LANG=C "$fish_bin" --no-config $argv +end + function assert_navigation_error set -l command "$argv[1]" set -l expected "$argv[2]" @@ -82,11 +86,17 @@ set -l aliases (run_fish -c 'functions gs; functions gpl' | string collect) string match -q '*git status*' "$aliases"; or fail 'gs alias' string match -q '*git pull*' "$aliases"; or fail 'gpl alias' -printf '#!/bin/sh\nprintf "%s\\n" Linux\n' >"$bin/uname" +printf '#!/bin/sh\necho Linux\n' >"$bin/uname" chmod +x "$bin/uname" set -l linux_open_alias (run_fish -c 'functions -q o; and echo defined; or echo absent') assert_equal "$linux_open_alias" absent 'Linux Fish startup excludes the macOS open alias' +mkdir -p "$home/.nix-profile/bin" +printf '#!/bin/sh\n' >"$home/.nix-profile/bin/w2-profile-command" +chmod +x "$home/.nix-profile/bin/w2-profile-command" +set -l linux_profile_command (run_clean_fish -c "source '$xdg/fish/conf.d/10-core.fish'; command -s w2-profile-command") +assert_equal "$linux_profile_command" "$home/.nix-profile/bin/w2-profile-command" 'Linux Fish startup resolves commands from the user Nix profile' + printf '#!/bin/sh\n[ "$1" = init ] && printf "set -gx W2_STARSHIP_READY 1\\n"\n' >"$bin/starship" chmod +x "$bin/starship" set -l noninteractive (run_fish -c 'set -q W2_STARSHIP_READY; and echo ready; or echo skipped')