From d3391bf18293537f97480e4b2550772f4a37531c Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Wed, 12 Feb 2025 11:21:55 -0300 Subject: [PATCH] feat(devkit): ghostty wrapper --- flake.nix | 4 ++ packages/devkit/colors.nix | 18 ++++++++ packages/devkit/default.nix | 3 ++ packages/devkit/ghostty/default.nix | 67 +++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 packages/devkit/colors.nix create mode 100644 packages/devkit/default.nix create mode 100644 packages/devkit/ghostty/default.nix diff --git a/flake.nix b/flake.nix index 56d7821..f8fccc4 100644 --- a/flake.nix +++ b/flake.nix @@ -116,5 +116,9 @@ devenv = ./modules/home-manager/devenv.nix; eww = ./modules/home-manager/eww.nix; }; + + packages = forAllSystems (pkgs: { + devkit = import ./packages/devkit {inherit pkgs;}; + }); }; } diff --git a/packages/devkit/colors.nix b/packages/devkit/colors.nix new file mode 100644 index 0000000..aab7c83 --- /dev/null +++ b/packages/devkit/colors.nix @@ -0,0 +1,18 @@ +{ + base00 = "#111111"; # base + base01 = "#101010"; # mantle + base02 = "#181818"; # surface0 + base03 = "#181818"; # surface1 + base04 = "#181818"; # surface2 + base05 = "#cdd6f4"; # text + base06 = "#f5e0dc"; # rosewater + base07 = "#b4befe"; # lavender + base08 = "#f38ba8"; # red + base09 = "#fab387"; # peach + base0A = "#f9e2af"; # yellow + base0B = "#a6e3a1"; # green + base0C = "#94e2d5"; # teal + base0D = "#89b4fa"; # blue + base0E = "#cba6f7"; # mauve + base0F = "#f2cdcd"; # flamingo +} diff --git a/packages/devkit/default.nix b/packages/devkit/default.nix new file mode 100644 index 0000000..6c89f0c --- /dev/null +++ b/packages/devkit/default.nix @@ -0,0 +1,3 @@ +{pkgs}: rec { + ghostty = pkgs.callPackage ./ghostty {}; +} diff --git a/packages/devkit/ghostty/default.nix b/packages/devkit/ghostty/default.nix new file mode 100644 index 0000000..743bc6c --- /dev/null +++ b/packages/devkit/ghostty/default.nix @@ -0,0 +1,67 @@ +{ + symlinkJoin, + makeWrapper, + pkgs, + lib, + ghostty ? pkgs.ghostty, + paths ? [], +}: let + colors = import ../colors.nix; + theme = pkgs.writeText "theme" '' + palette = 0=${colors.base00} + palette = 1=${colors.base08} + palette = 2=${colors.base0B} + palette = 3=${colors.base0A} + palette = 4=${colors.base0D} + palette = 5=${colors.base0E} + palette = 6=${colors.base0C} + palette = 7=${colors.base05} + palette = 8=${colors.base03} + palette = 9=${colors.base08} + palette = 10=${colors.base0B} + palette = 11=${colors.base0A} + palette = 12=${colors.base0D} + palette = 13=${colors.base0E} + palette = 14=${colors.base0C} + palette = 15=${colors.base07} + + background = ${colors.base00} + foreground = ${colors.base05} + cursor-color = ${colors.base05} + selection-background = ${colors.base02} + selection-foreground = ${colors.base07} + ''; + drv = symlinkJoin ({ + paths = ghostty; + + nativeBuildInputs = [makeWrapper]; + + postBuild = '' + wrapProgram $out/bin/ghostty ${ + if (builtins.length paths) > 0 + then "$PATH:${lib.makeBinPath paths}" + else "" + } --add-flags '--theme=${theme}' + ''; + } + // {inherit (ghostty) name pname meta;}); +in + pkgs.stdenv.mkDerivation (rec { + name = drv.name; + pname = drv.pname; + + buildCommand = let + desktopEntry = pkgs.makeDesktopItem { + name = pname; + desktopName = name; + exec = "${lib.getExe drv}"; + }; + in '' + mkdir -p $out/bin + cp ${lib.getExe drv} $out/bin + + mkdir -p $out/share/applications + cp ${desktopEntry}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop + ''; + } + // {inherit (ghostty) meta;})