loadout/alacritty/default.nix
mediocregopher 1957081c12 Update branch with all changes which could be brought in from private branches
For a while I was keeping a private branch where there were a lot of
non-public things included, and that became the de-facto branch while
this one lagged. This one is now up-to-date, all private stuff is dealt
with via config files which are not committed.
2023-08-13 21:35:17 +02:00

50 lines
1.1 KiB
Nix

{
config,
pkgs ? (import ../pkgs.nix).stable2305 {},
zsh ? pkgs.zsh,
}: rec {
defaultXDGOpenRules = [
{
name = "open-url";
pattern = "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^<>\"\\s{-}\\^`]+";
xdgOpen = "$1";
}
];
xdgOpenRules = defaultXDGOpenRules ++ config.alacritty.xdgOpenRules;
hints = {
enabled = (builtins.map (r:
{
regex = r.pattern;
hyperlinks = true;
command = (pkgs.writeShellScript "alacritty-hints-${r.name}" ''
xdg-open "${r.xdgOpen}"
'');
post_processing = true;
mouse.enabled = true;
}
) xdgOpenRules);
};
configFile = pkgs.writeText "alacritty-config" (
builtins.replaceStrings
["$HINTS"]
[(builtins.toJSON hints)]
(builtins.readFile ./alacritty.yml)
);
alacritty = pkgs.writeScriptBin "alacritty" ''
#!${pkgs.bash}/bin/bash
exec ${pkgs.nixgl}/bin/nixGL ${pkgs.alacritty}/bin/alacritty \
-o font.size=${builtins.toString config.alacritty.fontSize} \
--config-file ${configFile} \
-e "${zsh}/bin/zsh"
'';
}