From e7afade2008df3dd2277480c9d7a77e8ac4294e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Mon, 19 May 2025 21:19:52 +0200 Subject: [PATCH] vanadium: source each environment when needed individually --- nix/configurations/vanadium/home/programs.nix | 17 ++--------------- .../common/fish/functions/activate-nix-env.fish | 11 +++++++++++ .../fish/functions/deactivate-nix-env.fish | 11 +++++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 nix/homeModules/common/fish/functions/activate-nix-env.fish create mode 100644 nix/homeModules/common/fish/functions/deactivate-nix-env.fish diff --git a/nix/configurations/vanadium/home/programs.nix b/nix/configurations/vanadium/home/programs.nix index e01b8592..c5ac4522 100644 --- a/nix/configurations/vanadium/home/programs.nix +++ b/nix/configurations/vanadium/home/programs.nix @@ -42,21 +42,8 @@ in { programs = { neovim.enable = true; neovim.defaultEditor = true; - fish = { - enable = true; - shellInitLast = '' - if test -d ~/.environments - for file in ~/.environments/* - if not string match -q --regex -- '-link$' $file - # - global: make sure the path added is scoped to the instance of the shell - # https://github.com/fish-shell/fish-shell/issues/8604#issuecomment-2854550904 - # - append: make my own environment come after a nix shell even if invoked by one - fish_add_path --global --append --move $file/bin - end - end - end - ''; - }; + + fish.enable = true; starship.enable = true; tmux.enable = true; direnv.enable = true; diff --git a/nix/homeModules/common/fish/functions/activate-nix-env.fish b/nix/homeModules/common/fish/functions/activate-nix-env.fish new file mode 100644 index 00000000..2d494481 --- /dev/null +++ b/nix/homeModules/common/fish/functions/activate-nix-env.fish @@ -0,0 +1,11 @@ +function activate-nix-env \ + --description "Add a nix environment into path" + ### Arguments: + if [ (count $argv) -ne 1 ] + echo "Must provide exactly one argument, the path to be added" + return 1 + end + set env_name $argv[1] + + fish_add_path --global "$HOME/.environments/$argv[1]/bin" +end diff --git a/nix/homeModules/common/fish/functions/deactivate-nix-env.fish b/nix/homeModules/common/fish/functions/deactivate-nix-env.fish new file mode 100644 index 00000000..76b1e519 --- /dev/null +++ b/nix/homeModules/common/fish/functions/deactivate-nix-env.fish @@ -0,0 +1,11 @@ +function deactivate-nix-env \ + --description "Remove a nix environment from path" + ### Arguments: + if [ (count $argv) -ne 1 ] + echo "Must provide exactly one argument, the path to be removed" + return 1 + end + set env_name $argv[1] + + fish_remove_path "$HOME/.environments/$argv[1]/bin" +end