loadout/alacritty/default.nix

50 lines
1.1 KiB
Nix
Raw Normal View History

2017-10-18 00:12:57 +00:00
{
config,
pkgs ? (import ../pkgs.nix).stable2305 {},
2017-10-18 00:12:57 +00:00
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";
}
];
2017-10-18 00:12:57 +00:00
xdgOpenRules = defaultXDGOpenRules ++ config.alacritty.xdgOpenRules;
2017-10-18 00:12:57 +00:00
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);
};
2017-10-18 00:12:57 +00:00
configFile = pkgs.writeText "alacritty-config" (
builtins.replaceStrings
["$HINTS"]
[(builtins.toJSON hints)]
(builtins.readFile ./alacritty.yml)
);
2017-10-18 00:12:57 +00:00
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} \
2017-10-18 00:12:57 +00:00
-e "${zsh}/bin/zsh"
'';
}