From da02b59ebfb5dcef3183a2eae5d2993b963b17fb Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Sun, 13 Feb 2022 14:36:37 +0100 Subject: [PATCH] switch to foot --- wm/default.nix | 33 ++++++++++++++++++++++- wm/terminal/default.nix | 59 +++++++++++++++++++++++++++++++++++++++++ wm/terminal/foot.nix | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 wm/terminal/default.nix create mode 100644 wm/terminal/foot.nix diff --git a/wm/default.nix b/wm/default.nix index 665fb7c..c29f41d 100644 --- a/wm/default.nix +++ b/wm/default.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: { + imports = [ ./terminal ]; home.packages = with pkgs; [ sway @@ -23,6 +24,37 @@ LIBSEAT_BACKEND = "logind"; }; + terminal = { + enable = true; + kind = "foot"; + + colors = { + background = "000000"; + foreground = "ffffff"; + + black = { + normal = "000000"; + bright = "545454"; + }; + red = { normal = "ff5555"; }; + green = { normal = "55ff55"; }; + yellow = { normal = "ffff55"; }; + blue = { normal = "5555ff"; }; + magenta = { normal = "ff55ff"; }; + cyan = { normal = "55ffff"; }; + white = { + normal = "bbbbbb"; + bright = "ffffff"; + }; + + selectionForeground = "000000"; + }; + font = { + family = "Hack Nerd Font Mono"; + size = 7; + }; + }; + programs = { mako = { enable = true; @@ -140,7 +172,6 @@ { command = "wdumpkeys >> ~/.keydump"; } ]; menu = "${pkgs.wofi}/bin/wofi --show drun,run --allow-images"; - terminal = "${pkgs.kitty}/bin/kitty"; keybindings = let mod = config.wayland.windowManager.sway.config.modifier; diff --git a/wm/terminal/default.nix b/wm/terminal/default.nix new file mode 100644 index 0000000..853e88f --- /dev/null +++ b/wm/terminal/default.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; +with builtins; + +let + mkColor = mkOption { type = types.nullOr types.str; default = null; }; + mkColorPair = { + normal = mkColor; + bright = mkColor; + }; + cfg = config.terminal; + cCfg = cfg.colors; +in +{ + imports = [ ./foot.nix ]; + + options = { + terminal = { + enable = mkOption { + type = types.bool; + default = false; + description = "Manage terminal"; + }; + kind = mkOption { + type = types.enum [ "foot" ]; + default = "foot"; + description = "The terminal to be used"; + }; + colors = { + background = mkColor; + foreground = mkColor; + + black = mkColorPair; + red = mkColorPair; + green = mkColorPair; + yellow = mkColorPair; + blue = mkColorPair; + magenta = mkColorPair; + cyan = mkColorPair; + white = mkColorPair; + + selectionForeground = mkColor; + }; + font = { + size = mkOption { + type = types.int; + default = 12; + description = "terminal font size"; + }; + family = mkOption { + type = types.str; + default = "monospace"; + description = "font family"; + }; + }; + }; + }; +} diff --git a/wm/terminal/foot.nix b/wm/terminal/foot.nix new file mode 100644 index 0000000..5990789 --- /dev/null +++ b/wm/terminal/foot.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; +with builtins; + +let + cfg = config.terminal; + cCfg = cfg.colors; +in + +{ + config = mkIf (cfg.enable && cfg.kind == "foot") { + programs.foot = { + enable = true; + settings = { + colors = + let + colorCfg = value: mkIf (value != null) value; + colorCfgNormal = color: colorCfg color.normal; + colorCfgBright = color: if color.bright != null then color.bright else colorCfgNormal color; + in + { + background = colorCfg cCfg.background; + foreground = colorCfg cCfg.foreground; + + regular0 = colorCfgNormal cCfg.black; + bright0 = colorCfgBright cCfg.black; + + regular1 = colorCfgNormal cCfg.red; + bright1 = colorCfgBright cCfg.red; + + regular2 = colorCfgNormal cCfg.green; + bright2 = colorCfgBright cCfg.green; + + regular3 = colorCfgNormal cCfg.yellow; + bright3 = colorCfgBright cCfg.yellow; + + regular4 = colorCfgNormal cCfg.blue; + bright4 = colorCfgBright cCfg.blue; + + regular5 = colorCfgNormal cCfg.magenta; + bright5 = colorCfgBright cCfg.magenta; + + regular6 = colorCfgNormal cCfg.cyan; + bright6 = colorCfgBright cCfg.cyan; + + regular7 = colorCfgNormal cCfg.white; + bright7 = colorCfgBright cCfg.white; + + selection-foreground = colorCfg cCfg.selectionForeground; + }; + main = { + font = "${cfg.font.family}:size=${toString cfg.font.size}"; + }; + }; + }; + wayland.windowManager.sway.config.terminal = "${pkgs.foot}/bin/foot"; + }; +}