2017-10-18 00:12:57 +00:00
|
|
|
{
|
|
|
|
|
2023-08-13 19:34:14 +00:00
|
|
|
config,
|
2023-11-17 09:55:53 +00:00
|
|
|
zsh,
|
2023-08-13 19:34:14 +00:00
|
|
|
|
2023-11-17 09:55:53 +00:00
|
|
|
pkgs ? (import ../pkgs.nix).edge {},
|
2017-10-18 00:12:57 +00:00
|
|
|
|
|
|
|
}: rec {
|
|
|
|
|
2023-08-13 19:34:14 +00:00
|
|
|
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
|
|
|
|
2023-08-13 19:34:14 +00:00
|
|
|
xdgOpenRules = defaultXDGOpenRules ++ config.alacritty.xdgOpenRules;
|
2017-10-18 00:12:57 +00:00
|
|
|
|
2023-08-13 19:34:14 +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
|
|
|
|
2023-08-13 19:34:14 +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
|
|
|
|
2023-12-17 17:04:43 +00:00
|
|
|
shellEntrypoint = pkgs.writeShellScript "alacritty-shell-entrypoint" ''
|
|
|
|
unset LD_LIBRARY_PATH
|
|
|
|
unset __EGL_VENDOR_LIBRARY_DIRS
|
|
|
|
exec "${zsh}/bin/zsh" "$@"
|
|
|
|
'';
|
|
|
|
|
|
|
|
alacritty = pkgs.writeShellScriptBin "alacritty" ''
|
|
|
|
# TODO this might break things, especially if the machine is not using
|
|
|
|
# nvidia, but more investigation is needed. But it at least lets us get rid
|
|
|
|
# of nixGL.
|
|
|
|
export LD_LIBRARY_PATH=/usr/lib
|
|
|
|
export __EGL_VENDOR_LIBRARY_DIRS=/usr/share/glvnd/egl_vendor.d
|
2023-08-13 19:34:14 +00:00
|
|
|
|
2023-12-17 17:04:43 +00:00
|
|
|
exec ${pkgs.alacritty}/bin/alacritty \
|
2023-08-13 19:34:14 +00:00
|
|
|
-o font.size=${builtins.toString config.alacritty.fontSize} \
|
|
|
|
--config-file ${configFile} \
|
2023-12-17 17:04:43 +00:00
|
|
|
-e "${shellEntrypoint}"
|
2017-10-18 00:12:57 +00:00
|
|
|
'';
|
|
|
|
}
|