home/alacritty/alacritty.nix
2023-10-12 22:51:18 +02:00

155 lines
4.1 KiB
Nix

pkgs@{stdenv, ...}:
let
tmux-menu = with pkgs; writeScript "tmux-menu" "
export LC_ALL='en_US.UTF-8'
export LC_CTYPE='UTF-8'
SESSIONS=$(tmux ls)
SESSIONS=\"$ emacsclient
$ rink
$SESSIONS
Connect to coral.shoes (tmux)
Connect to coral.shoes (raw)
New session
Raw shell\"
CHOICE_LINE=$(echo \"$SESSIONS\" | fzf -1) || exit
CHOICE=$(echo \"$CHOICE_LINE\" | cut -d: -f1)
case $CHOICE in
'$ rink')
${rink}/bin/rink
;;
'$ emacsclient')
${emacs}/bin/emacsclient -n --create-frame -e '(x-focus-frame (selected-frame))' --alternate-editor=
;;
'Connect to coral.shoes (tmux)')
${mosh}/bin/mosh web -- tmux attach
;;
'Connect to coral.shoes (raw)')
${mosh}/bin/mosh web
;;
'Raw shell')
${zsh}/bin/zsh
;;
'New session')
echo 'Name? ' ; read NAME
${tmux}/bin/tmux new -s \"$NAME\" ${zsh}/bin/zsh
;;
*)
${tmux}/bin/tmux attach-session -t \"$CHOICE\"
;;
esac";
base-cfg = {
window = {
padding.x = 0;
padding.y = 0;
decorations = if stdenv.isDarwin then "Buttonless" else "Full";
startup_mode = "Windowed";
};
mouse.hide_when_typing = true;
font = {
normal.family = "SAX2";
size = 15;
};
colors.primary = {
background = "#282828";
foreground = "#ebdbb2";
};
shell.program = "${pkgs.zsh}/bin/zsh";
shell.args = [ "--login" "-c" "${tmux-menu}" ];
key_bindings = import ./keybinds.nix { bind-broken-mac-keybinds = stdenv.isDarwin; };
};
alt-patch-package = pkgs.fetchgit {
url = "https://github.com/loovjo/alacritty-modifiers-patch";
rev = "36ac4031248ba132f280017bfd8bf0a32e214f9d";
hash = "sha256-to5Tq64w8Tvt+KHjiKga3B31XC5TT/4kMR1zqp9A3AI=";
fetchSubmodules = true;
# deepClone = true;
};
rpathLibs = with pkgs; [
# expat
# fontconfig
# freetype
# libGL
# xorg.libX11
# xorg.libXcursor
# xorg.libXi
# xorg.libXrandr
# xorg.libXxf86vm
# xorg.libxcb
];
alacritty-alt-patch = with pkgs; rustPlatform.buildRustPackage {
pname = "alacritty-alt-patch";
version = "latest";
src = alt-patch-package;
cargoLock = { lockFile = alt-patch-package + "/Cargo.lock"; };
nativeBuildInputs = [
cmake
installShellFiles
makeWrapper
ncurses
pkg-config
python3
];
buildInputs = rpathLibs
++ (with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreGraphics
CoreServices
CoreText
Foundation
libiconv
OpenGL
]);
doCheck = false; # meow
outputs = [ "out" "terminfo" ];
postPatch = lib.optionalString (!xdg-utils.meta.broken) ''
substituteInPlace alacritty/src/config/ui_config.rs \
--replace xdg-open ${xdg-utils}/bin/xdg-open
'';
checkFlags = [ "--skip=term::test::mock_term" ]; # broken on aarch64
postInstall = ''
mkdir $out/Applications
cp -r extra/osx/Alacritty.app $out/Applications
cp -r $out/bin $out/Applications/Alacritty.app/Contents/MacOS # the original script used ln -s instead of cp -r, seems launchpad dies when having symlinks inside the application?
installShellCompletion --zsh extra/completions/_alacritty
installShellCompletion --bash extra/completions/alacritty.bash
installShellCompletion --fish extra/completions/alacritty.fish
install -dm 755 "$out/share/man/man1"
# gzip -c extra/alacritty.man > "$out/share/man/man1/alacritty.1.gz"
# gzip -c extra/alacritty-msg.man > "$out/share/man/man1/alacritty-msg.1.gz"
install -Dm 644 alacritty.yml $out/share/doc/alacritty.yml
install -dm 755 "$terminfo/share/terminfo/a/"
tic -xe alacritty,alacritty-direct -o "$terminfo/share/terminfo" extra/alacritty.info
mkdir -p $out/nix-support
echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
'';
dontPatchELF = true;
passthru.tests.test = nixosTests.terminal-emulators.alacritty;
};
in
{
enable = true;
settings = base-cfg;
package = if stdenv.isDarwin then alacritty-alt-patch else pkgs.alacritty;
}