nix/common/cli.nix
2026-04-08 11:51:33 +10:00

140 lines
3.9 KiB
Nix

{
pkgs,
lib,
getPkgs,
config,
...
}:
let
pal = config.rice.palette.hex;
ui = config.rice.roles pal;
wrap =
name: pkg: args:
pkgs.symlinkJoin {
inherit name;
paths = [ pkg ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = "wrapProgram $out/bin/${name} ${args}";
};
wrapXdg =
name: pkg: configDir:
wrap name pkg ''--set XDG_CONFIG_HOME "${configDir}"'';
lazygitConfig = pkgs.writeText "lazygit-config.yml" ''
gui:
theme:
activeBorderColor:
- "${ui.highlight}"
- bold
inactiveBorderColor:
- "${ui.muted}"
searchingActiveBorderColor:
- "${ui.accent}"
- bold
optionsTextColor:
- "${ui.primary}"
selectedLineBgColor:
- "${ui.surface}"
selectedRangeBgColor:
- "${ui.surface}"
cherryPickedCommitBgColor:
- "${ui.accent}"
cherryPickedCommitFgColor:
- "${ui.bg}"
unstagedChangesColor:
- "${ui.error}"
defaultFgColor:
- "${ui.fg}"
'';
zellijConfig = pkgs.writeTextDir "zellij-config.kdl" ''
themes {
nix-rice {
fg "${ui.fg}"
bg "${ui.surface}"
black "${pal.normal.black}"
red "${pal.normal.red}"
green "${pal.normal.green}"
yellow "${pal.normal.yellow}"
blue "${pal.normal.blue}"
magenta "${pal.normal.magenta}"
cyan "${pal.normal.cyan}"
white "${pal.normal.white}"
orange "${ui.highlight}"
}
}
theme "nix-rice"
'';
btopConfig = pkgs.writeText "btop.conf" ''
color_theme = "nix-rice"
'';
btopThemeDir = pkgs.runCommand "btop-themes" { } ''
mkdir -p $out
cp ${pkgs.writeText "nix-rice.theme" ''
theme[main_bg]="${ui.bg}"
theme[main_fg]="${ui.fg}"
theme[title]="${ui.fg}"
theme[hi_fg]="${ui.accent}"
theme[selected_bg]="${ui.surface}"
theme[selected_fg]="${ui.fg}"
theme[inactive_fg]="${ui.muted}"
theme[graph_text]="${ui.fg}"
theme[meter_bg]="${ui.overlay}"
theme[proc_misc]="${ui.primary}"
theme[cpu_box]="${ui.primary}"
theme[mem_box]="${ui.accent}"
theme[net_box]="${pal.normal.green}"
theme[proc_box]="${pal.normal.magenta}"
theme[div_line]="${ui.overlay}"
theme[temp_start]="${pal.normal.green}"
theme[temp_mid]="${ui.highlight}"
theme[temp_end]="${ui.error}"
theme[cpu_start]="${ui.primary}"
theme[cpu_mid]="${ui.accent}"
theme[cpu_end]="${ui.highlight}"
theme[free_start]="${pal.normal.green}"
theme[free_mid]="${ui.accent}"
theme[free_end]="${ui.primary}"
theme[cached_start]="${ui.primary}"
theme[cached_mid]="${ui.accent}"
theme[cached_end]="${pal.normal.green}"
theme[available_start]="${pal.normal.green}"
theme[available_mid]="${ui.accent}"
theme[available_end]="${ui.highlight}"
theme[used_start]="${ui.highlight}"
theme[used_mid]="${ui.error}"
theme[used_end]="${pal.bright.red}"
theme[download_start]="${pal.normal.green}"
theme[download_mid]="${ui.accent}"
theme[download_end]="${ui.primary}"
theme[upload_start]="${ui.highlight}"
theme[upload_mid]="${pal.bright.red}"
theme[upload_end]="${ui.error}"
theme[process_start]="${ui.primary}"
theme[process_mid]="${ui.accent}"
theme[process_end]="${pal.normal.green}"
''} $out/nix-rice.theme
'';
in
{
environment.systemPackages = getPkgs {
inherit (pkgs)
curl
eza
git
ripgrep
fd
ouch
btop
bat
;
lazygit = wrap "lazygit" pkgs.lazygit ''--add-flags "--use-config-file=${lazygitConfig}"'';
zellij = wrap "zellij" pkgs.zellij ''--add-flags "--config-dir ${zellijConfig}"'';
# btop = wrap "btop" pkgs.btop ''--add-flags "--config ${btopConfig} --themes-dir ${btopThemeDir}"'';
};
environment.variables.BAT_THEME = "ansi";
}