2015-12-25 00:17:42 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfge = config.environment;
|
|
|
|
|
|
|
|
cfg = config.programs.fish;
|
|
|
|
|
|
|
|
fishAliases = concatStringsSep "\n" (
|
|
|
|
mapAttrsFlatten (k: v: "alias ${k} '${v}'") cfg.shellAliases
|
|
|
|
);
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
programs.fish = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to configure fish as an interactive shell.
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
shellAliases = mkOption {
|
|
|
|
default = config.environment.shellAliases;
|
|
|
|
description = ''
|
|
|
|
Set of aliases for fish shell. See <option>environment.shellAliases</option>
|
|
|
|
for an option format description.
|
|
|
|
'';
|
|
|
|
type = types.attrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
shellInit = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Shell script code called during fish shell initialisation.
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
|
|
|
};
|
|
|
|
|
|
|
|
loginShellInit = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Shell script code called during fish login shell initialisation.
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
|
|
|
};
|
|
|
|
|
|
|
|
interactiveShellInit = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Shell script code called during interactive fish shell initialisation.
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
|
|
|
};
|
|
|
|
|
|
|
|
promptInit = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Shell script code used to initialise fish prompt.
|
|
|
|
'';
|
|
|
|
type = types.lines;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
environment.etc."fish/foreign-env/shellInit".text = cfge.shellInit;
|
|
|
|
environment.etc."fish/foreign-env/loginShellInit".text = cfge.loginShellInit;
|
|
|
|
environment.etc."fish/foreign-env/interactiveShellInit".text = cfge.interactiveShellInit;
|
|
|
|
|
|
|
|
environment.etc."fish/config.fish".text = ''
|
|
|
|
# /etc/fish/config.fish: DO NOT EDIT -- this file has been generated automatically.
|
|
|
|
|
|
|
|
set fish_function_path $fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions
|
|
|
|
|
2016-05-25 22:09:16 +00:00
|
|
|
fenv source ${config.system.build.setEnvironment} > /dev/null ^&1
|
|
|
|
fenv source /etc/fish/foreign-env/shellInit > /dev/null
|
2015-12-25 00:17:42 +00:00
|
|
|
|
|
|
|
${cfg.shellInit}
|
|
|
|
|
2016-05-25 22:09:16 +00:00
|
|
|
if status --is-login
|
|
|
|
fenv source /etc/fish/foreign-env/loginShellInit > /dev/null
|
2015-12-25 00:17:42 +00:00
|
|
|
${cfg.loginShellInit}
|
|
|
|
end
|
|
|
|
|
2016-05-25 22:09:16 +00:00
|
|
|
if status --is-interactive
|
2015-12-25 00:17:42 +00:00
|
|
|
${fishAliases}
|
2016-05-25 22:09:16 +00:00
|
|
|
fenv source /etc/fish/foreign-env/interactiveShellInit > /dev/null
|
2015-12-25 00:17:42 +00:00
|
|
|
${cfg.interactiveShellInit}
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
|
2016-04-08 02:13:41 +00:00
|
|
|
# include programs that bring their own completions
|
|
|
|
environment.pathsToLink = [ "/share/fish/vendor_completions.d" ];
|
|
|
|
|
2015-12-25 00:17:42 +00:00
|
|
|
environment.systemPackages = [ pkgs.fish ];
|
|
|
|
|
|
|
|
environment.shells = [
|
|
|
|
"/run/current-system/sw/bin/fish"
|
|
|
|
"/var/run/current-system/sw/bin/fish"
|
|
|
|
"${pkgs.fish}/bin/fish"
|
|
|
|
];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|