refactor(devkit,ghostty): use cli flags to set preferences

This commit is contained in:
Guz
2026-03-26 16:58:55 -03:00
parent 7ccd6bbba3
commit b9733ad4da

View File

@@ -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 ""