Programs/common/starship: add upstream nerd font preset

This commit is contained in:
Toast 2023-12-18 09:33:09 +01:00
parent 9a8309def9
commit a80920a663

View file

@ -1,4 +1,8 @@
{ pkgs, ... }:
{ pkgs, lib, ... }:
with lib;
with builtins;
let
catppuccinFlavour = "mocha";
catppuccinStarship = pkgs.fetchFromGitHub {
@ -8,27 +12,46 @@ let
rev = "main";
hash = "sha256-nsRuxQFKbQkyEI4TXgvAjcroVdG+heKX5Pauq/4Ota0=";
} + /palettes/${catppuccinFlavour}.toml;
presets = {
nerdFontSymbols = pkgs.fetchurl {
url = "https://starship.rs/presets/toml/nerd-font-symbols.toml";
hash = "sha256-fPmZrfhwM9NakdlJ7Y4rZ5n6JjsqXNEQ9XuFa8en9n0=";
};
};
# -------------------------------- F U N C T I O N S --------------------------------
/*
Gonna be honest, I have no idea how this works, although it seems to work
Stolen from https://gist.github.com/pdalpra/daf339f59288201a6c8ba7dc84e9060e
*/
# Takes a list of attrSets and merges them
mergeAllAttrSets = attrsSets:
foldl' (recursiveUpdate) {} attrsSets;
# Reads a TOML file and parses it
readTomlPreset = file: (fromTOML (readFile file));
in
{
programs.starship = with builtins; {
programs.starship = {
enable = true;
settings = {
nix_shell = {
disabled = false;
heuristic = true;
symbol = " ";
};
os = {
disabled = false;
symbols.NixOS = " ";
};
directory = {
disabled = false;
read_only = " 󰌾";
};
palette = "catppuccin_${catppuccinFlavour}";
} //
# Add the catppuccin palette to the settings file
(fromTOML (readFile catppuccinStarship));
settings = mergeAllAttrSets [
(readTomlPreset presets.nerdFontSymbols)
(readTomlPreset catppuccinStarship)
{
nix_shell = {
disabled = false;
heuristic = true;
};
os = {
disabled = false;
};
directory = {
disabled = false;
};
palette = "catppuccin_${catppuccinFlavour}";
}
];
};
}