feat(devkit): lazygit wrapper

This commit is contained in:
Guz
2025-02-12 11:22:16 -03:00
parent 8cca510636
commit a880f24799
2 changed files with 65 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
{pkgs}: rec {
ghostty = pkgs.callPackage ./ghostty {};
git = pkgs.callPackage ./git {};
lazygit = pkgs.callPackage ./lazygit {};
}

View File

@@ -0,0 +1,64 @@
{
symlinkJoin,
makeWrapper,
pkgs,
lib,
lazygit ? pkgs.lazygit,
paths ? [],
settings ? {},
}: let
# YAML is a superset of JSON, so any JSON is valid YAML.
colors = import ../colors.nix;
cfg = pkgs.writeText "config.yml" (builtins.toJSON ({
git.paging.colorArg = "always";
git.paging.pager = "${lib.getExe pkgs.delta} --dark --paging=never";
gui.theme = {
activeBorderColor = [colors.base07 "bold"];
inactiveBorderColor = [colors.base04];
searchingActiveBorderColor = [colors.base02 "bold"];
optionsTextColor = [colors.base06];
selectedLineBgColor = [colors.base03];
cherryPickedCommitBgColor = [colors.base02];
cherryPickedCommitFgColor = [colors.base03];
unstagedChangesColor = [colors.base08];
defaultFgColor = [colors.base05];
};
}
// settings));
drv = symlinkJoin ({
paths = lazygit;
nativeBuildInputs = [makeWrapper];
postBuild = ''
wrapProgram $out/bin/lazygit ${
if (builtins.length paths) > 0
then "$PATH:${lib.makeBinPath paths}"
else ""
} --add-flags '--use-config-file' --add-flags '${cfg}'
'';
}
// {inherit (lazygit) 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}";
terminal = true;
};
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 (lazygit) meta;})