Skip to content

Commit

Permalink
fish: add setEnvironment
Browse files Browse the repository at this point in the history
  • Loading branch information
yurrriq committed Oct 10, 2017
1 parent 69cf8f4 commit 0ea82db
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions modules/programs/fish.nix
Expand Up @@ -27,7 +27,7 @@ in
'';
type = types.bool;
};

vendor.config.enable = mkOption {
type = types.bool;
default = true;
Expand All @@ -43,7 +43,7 @@ in
Whether fish should use completion files provided by other packages.
'';
};

vendor.functions.enable = mkOption {
type = types.bool;
default = true;
Expand Down Expand Up @@ -103,19 +103,16 @@ in
environment.etc."fish/foreign-env/loginShellInit".text = cfge.loginShellInit;
environment.etc."fish/foreign-env/interactiveShellInit".text = cfge.interactiveShellInit;
environment.etc."fish/foreign-env/extraInit".text= cfge.extraInit;
environment.etc."nix/support/set-environment.sh".source = "${config.system.build.setEnvironment}";

environment.etc."fish/nixos-env-preinit.fish".text = ''
# This happens before $__fish_datadir/config.fish sets fish_function_path, so it is currently
# unset. We set it and then completely erase it, leaving its configuration to $__fish_datadir/config.fish
set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $__fish_datadir/functions
# For "reasons not remembered," setEnvironment does not set PATH, so do it here
set PATH ${replaceStrings [":"] [" "] config.environment.systemPath}
# source the NixOS environment config
fenv source ${config.system.build.setEnvironment}
fenv source /etc/fish/foreign-env/extraInit
# clear fish_function_path so that it will be correctly set when we return to $__fish_datadir/config.fish
set -e fish_function_path
'';
Expand All @@ -128,7 +125,7 @@ in
set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path
fenv source /etc/fish/foreign-env/shellInit > /dev/null
set -e fish_function_path[1]
${cfg.shellInit}
# and leave a note so we don't source this config section again from
Expand All @@ -142,7 +139,7 @@ in
set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path
fenv source /etc/fish/foreign-env/loginShellInit > /dev/null
set -e fish_function_path[1]
${cfg.loginShellInit}
# and leave a note so we don't source this config section again from
Expand All @@ -154,12 +151,12 @@ in
status --is-interactive; and not set -q __fish_nixos_interactive_config_sourced
and begin
${fishAliases}
set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path
fenv source /etc/fish/foreign-env/interactiveShellInit > /dev/null
set -e fish_function_path[1]
${cfg.promptInit}
${cfg.interactiveShellInit}
Expand All @@ -175,7 +172,7 @@ in
++ optional cfg.vendor.config.enable "/share/fish/vendor_conf.d"
++ optional cfg.vendor.completions.enable "/share/fish/vendor_completions.d"
++ optional cfg.vendor.functions.enable "/share/fish/vendor_functions.d";

environment.systemPackages = [ pkgs.fish ];

};
Expand Down

0 comments on commit 0ea82db

Please sign in to comment.