|
| 1 | +# This module defines global configuration for the fish. |
| 2 | + |
| 3 | +{ config, lib, pkgs, ... }: |
| 4 | + |
| 5 | +with lib; |
| 6 | + |
| 7 | +let |
| 8 | + |
| 9 | +cfge = config.environment; |
| 10 | + |
| 11 | +cfg = config.programs.fish; |
| 12 | + |
| 13 | +in |
| 14 | + |
| 15 | +{ |
| 16 | + |
| 17 | + options = { |
| 18 | + |
| 19 | + programs.fish = { |
| 20 | + |
| 21 | + enable = mkOption { |
| 22 | + default = false; |
| 23 | + description = '' |
| 24 | + Whenever to configure fish as an interactive shell. |
| 25 | + ''; |
| 26 | + type = types.bool; |
| 27 | + }; |
| 28 | + |
| 29 | + shellAliases = mkOption { |
| 30 | + default = config.environment.shellAliases; |
| 31 | + description = '' |
| 32 | + Set of aliases for zsh shell. See <option>environment.shellAliases</option> |
| 33 | + for an option format description. |
| 34 | + ''; |
| 35 | + type = types.attrs; # types.attrsOf types.stringOrPath; |
| 36 | + }; |
| 37 | + |
| 38 | + shellInit = mkOption { |
| 39 | + default = ""; |
| 40 | + description = '' |
| 41 | + Shell script code called during fish shell initialisation. |
| 42 | + ''; |
| 43 | + type = types.lines; |
| 44 | + }; |
| 45 | + |
| 46 | + loginShellInit = mkOption { |
| 47 | + default = ""; |
| 48 | + description = '' |
| 49 | + Shell script code called during fish login shell initialisation. |
| 50 | + ''; |
| 51 | + type = types.lines; |
| 52 | + }; |
| 53 | + |
| 54 | + interactiveShellInit = mkOption { |
| 55 | + default = ""; |
| 56 | + description = '' |
| 57 | + Shell script code called during interactive fish initialisation. |
| 58 | + ''; |
| 59 | + type = types.lines; |
| 60 | + }; |
| 61 | + |
| 62 | + promptInit = mkOption { |
| 63 | + default = ""; |
| 64 | + description = '' |
| 65 | + Shell script code used to initialise the fish prompt. |
| 66 | + ''; |
| 67 | + type = types.lines; |
| 68 | + }; |
| 69 | + |
| 70 | + }; |
| 71 | + |
| 72 | + }; |
| 73 | + |
| 74 | + config = mkIf cfg.enable { |
| 75 | + |
| 76 | + programs.fish = { |
| 77 | + |
| 78 | + shellInit = '' |
| 79 | + . ${config.system.build.setEnvironment} |
| 80 | +
|
| 81 | + ${cfge.shellInit} |
| 82 | + ''; |
| 83 | + |
| 84 | + loginShellInit = cfge.loginShellInit; |
| 85 | + |
| 86 | + interactiveShellInit = '' |
| 87 | + ${cfge.interactiveShellInit} |
| 88 | +
|
| 89 | + ${cfg.promptInit} |
| 90 | + ''; |
| 91 | + |
| 92 | + }; |
| 93 | + |
| 94 | + environment.profileRelativeEnvVars = { }; |
| 95 | + |
| 96 | + environment.systemPackages = [ pkgs.fish ]; |
| 97 | + |
| 98 | + #users.defaultUserShell = mkDefault "/run/current-system/sw/bin/fish"; |
| 99 | + |
| 100 | + environment.shells = |
| 101 | + [ "/run/current-system/sw/bin/fish" |
| 102 | + "/var/run/current-system/sw/bin/fish" |
| 103 | + "${pkgs.fish}/bin/fish" |
| 104 | + ]; |
| 105 | + |
| 106 | + }; |
| 107 | + |
| 108 | +} |
| 109 | + |
0 commit comments