23 lines
783 B
Nix
23 lines
783 B
Nix
{ lib, config, pkgs, ... }:
|
|
arg:
|
|
with lib;
|
|
let cfg = config.colorscheme;
|
|
|
|
getKittyTheme = with builtins; (theme:
|
|
let matching = filter (x: x.name == theme)
|
|
(fromJSON
|
|
(readFile
|
|
"${pkgs.kitty-themes}/share/kitty-themes/themes.json"));
|
|
|
|
in throwIf (length matching == 0)
|
|
"kitty-themes does not contain a theme named ${theme}"
|
|
"${pkgs.kitty-themes}/share/kitty-themes/${(head matching).file}");
|
|
|
|
unwrapKittyTheme = with pkgs; path: let
|
|
theme = runCommand "theme.toml" { nativebuildinputs = [ coreutils ]; } ''
|
|
cat '${path}' | sed -E '/^#|^$/d;s/\s+(.*)/ = "\1"/g' > $out
|
|
'';
|
|
in (builtins.fromTOML (builtins.readFile theme));
|
|
|
|
in unwrapKittyTheme (getKittyTheme arg)
|