at master 2.6 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.programs.foot; 10 11 settingsFormat = pkgs.formats.ini { 12 listsAsDuplicateKeys = true; 13 mkKeyValue = 14 with lib.generators; 15 mkKeyValueDefault { 16 mkValueString = 17 v: 18 mkValueStringDefault { } ( 19 if v == true then 20 "yes" 21 else if v == false then 22 "no" 23 else if v == null then 24 "none" 25 else 26 v 27 ); 28 } "="; 29 }; 30in 31{ 32 options.programs.foot = { 33 enable = lib.mkEnableOption "foot terminal emulator"; 34 35 package = lib.mkPackageOption pkgs "foot" { }; 36 37 settings = lib.mkOption { 38 inherit (settingsFormat) type; 39 default = { }; 40 description = '' 41 Configuration for foot terminal emulator. Further information can be found in {command}`man 5 foot.ini`. 42 43 Global configuration has to be written under the [main] section. 44 ''; 45 example = { 46 main.font = "FreeMono:size=12"; 47 scrollback.lines = 100000; 48 }; 49 }; 50 51 theme = lib.mkOption { 52 type = with lib.types; nullOr str; 53 default = null; 54 description = '' 55 Theme name. Check <https://codeberg.org/dnkl/foot/src/branch/master/themes> for available themes. 56 ''; 57 example = "aeroroot"; 58 }; 59 60 enableBashIntegration = lib.mkEnableOption "foot bash integration" // { 61 default = true; 62 }; 63 64 enableFishIntegration = lib.mkEnableOption "foot fish integration" // { 65 default = true; 66 }; 67 68 enableZshIntegration = lib.mkEnableOption "foot zsh integration" // { 69 default = true; 70 }; 71 }; 72 73 config = lib.mkIf cfg.enable { 74 environment = { 75 systemPackages = [ cfg.package ]; 76 etc."xdg/foot/foot.ini".source = settingsFormat.generate "foot.ini" cfg.settings; 77 }; 78 programs = { 79 foot.settings.main.include = lib.optionals (cfg.theme != null) [ 80 "${pkgs.foot.themes}/share/foot/themes/${cfg.theme}" 81 ]; 82 # https://codeberg.org/dnkl/foot/wiki#user-content-shell-integration 83 bash.interactiveShellInit = lib.mkIf cfg.enableBashIntegration ". ${./bashrc} # enable shell integration for foot terminal"; 84 fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration "source ${./config.fish} # enable shell integration for foot terminal"; 85 zsh.interactiveShellInit = lib.mkIf cfg.enableZshIntegration ". ${./zshrc} # enable shell integration for foot terminal"; 86 }; 87 }; 88 89 meta = { 90 maintainers = with lib.maintainers; [ linsui ]; 91 }; 92}