From b9733ad4dacd34b01f0df9a846e60b4e93958a70 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Thu, 26 Mar 2026 16:58:55 -0300 Subject: [PATCH] refactor(devkit,ghostty): use cli flags to set preferences --- packages/devkit/ghostty.nix | 69 ++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/packages/devkit/ghostty.nix b/packages/devkit/ghostty.nix index 70cc36e..b529aed 100644 --- a/packages/devkit/ghostty.nix +++ b/packages/devkit/ghostty.nix @@ -2,43 +2,56 @@ symlinkJoin, makeWrapper, pkgs, + lib, ghostty ? pkgs.ghostty, command ? null, }: let colors = import ./colors.nix; - theme = with colors; - pkgs.writeText "theme" '' - palette = 0=${base00} - palette = 1=${base08} - palette = 2=${base0B} - palette = 3=${base0A} - palette = 4=${base0D} - palette = 5=${base0E} - palette = 6=${base0C} - palette = 7=${base05} - palette = 8=${base03} - palette = 9=${base08} - palette = 10=${base0B} - palette = 11=${base0A} - palette = 12=${base0D} - palette = 13=${base0E} - palette = 14=${base0C} - palette = 15=${base07} - - background = ${base00} - background-opacity = 0.9 - foreground = ${base05} - cursor-color = ${base05} - selection-background = ${base02} - selection-foreground = ${base07} - ''; + config = with colors; { + background = base00; + background-opacity = 0.9; + cursor-color = base05; + foreground = base05; + gtk-titlebar = false; + gtk-titlebar-hide-when-maximized = true; + palette = [ + "0=${base00}" + "1=${base08}" + "2=${base0B}" + "3=${base0A}" + "4=${base0D}" + "5=${base0E}" + "6=${base0C}" + "7=${base05}" + "8=${base03}" + "9=${base08}" + "10=${base0B}" + "11=${base0A}" + "12=${base0D}" + "13=${base0E}" + "14=${base0C}" + "15=${base07}" + ]; + selection-background = base02; + selection-foreground = base07; + }; in symlinkJoin ({ paths = [ghostty]; nativeBuildInputs = [makeWrapper pkgs.coreutils]; postBuild = '' - wrapProgram $out/bin/ghostty \ - --add-flags '--theme=${theme}' ${ + wrapProgram $out/bin/ghostty ${ + with lib; + pipe config [ + (mapAttrsToList + (n: v: + if isList v + then (map (v: ["--add-flags" "--${n}='${toString v}'"]) v) + else ["--add-flags" "--${n}='${toString v}'"])) + flatten + escapeShellArgs + ] + } ${ if !(isNull command) then "--add-flags '-e' --add-flags '${command}'" else ""