From 3eb2f2e5b39576b08b52709b130c74819f0fec75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Sun, 8 Sep 2024 18:30:04 +0200 Subject: [PATCH] fish: source vendor completions by `fishEnvPreInit` credit: @budimanjojo --- modules/programs/fish.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 473d81600..e017ec693 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -251,6 +251,23 @@ in { description = '' The fish package to install. May be used to change the version. ''; + apply = + package: + package.override (old: { + fishEnvPreInit = + (old.fishEnvPreInit or "") + + '' + # This will ensure that $NIX_PROFILE variable is set as fast as possible + # so Nix managed programs can work properly without needing to tweak the OS. + # Usually this is done by Nix installer by putting these lines inside fish system config dir + # but it's a hit or miss especially when fish is not installed in the system beforehand. + # And I also found problem that vendor completion of Nix installed programs are not working + # without calling fish twice, I assume it's because $NIX_PROFILE is not set fast enough + if test -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish' + . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish' + end + ''; + }); }; shellAliases = mkOption {