fork/wezterm
git clone https://git.julia.blue/fork/wezterm
a5abd6991
vtparse-0.7.0
1{ 2description = "A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust" ; 3 4inputs = { 5nixpkgs . url = "github:NixOS/nixpkgs/nixpkgs-unstable" ; 6flake-utils . url = "github:numtide/flake-utils" ; 7rust-overlay = { 8url = "github:oxalica/rust-overlay" ; 9inputs . nixpkgs . follows = "nixpkgs" ; 10}; 11 12# NOTE: @2024-05 Nix flakes does not support getting git submodules of 'self'. 13# refs: 14# - https://discourse.nixos.org/t/get-nix-flake-to-include-git-submodule/30324 15# - https://github.com/NixOS/nix/pull/7862 16# 17# ... In the meantime we kinda duplicate the dependencies here then replace the submodules with 18# links to each repo in package sources. 19# 20# Try to use tags when possible to increase readability 21# (note: `git submodule status` in wezterm repo will show the `git describe` result for each 22# submodule, can help finding a tag if any) 23freetype2 = { 24url = "github:freetype/freetype/VER-2-13-3" ; 25flake = false ; 26}; 27harfbuzz = { 28url = "github:harfbuzz/harfbuzz/9.0.0" ; 29flake = false ; 30}; 31libpng = { 32url = "github:pnggroup/libpng/v1.6.44" ; 33flake = false ; 34}; 35zlib = { 36url = "github:madler/zlib/v1.3.1" ; 37flake = false ; 38}; 39}; 40 41outputs = 42inputs @{ self , ...} : 43inputs . flake-utils . lib . eachDefaultSystem ( 44system : 45let 46overlays = [ ( import inputs . rust-overlay ) ]; 47pkgs = import ( inputs . nixpkgs ) { inherit system overlays ; }; 48 49inherit ( inputs . nixpkgs ) lib ; 50inherit ( pkgs ) stdenv ; 51 52nativeBuildInputs = 53with pkgs ; 54[ 55installShellFiles 56ncurses # tic for terminfo 57pkg-config 58python3 59] 60++ lib . optional stdenv . isDarwin perl ; 61 62buildInputs = 63with pkgs ; 64[ 65fontconfig 66openssl 67zlib 68] 69++ lib . optionals stdenv . isLinux [ 70libxkbcommon 71wayland 72 73xorg . libX11 74xorg . libxcb 75xorg . xcbutil 76xorg . xcbutilimage 77xorg . xcbutilkeysyms 78xorg . xcbutilwm # contains xcb-ewmh among others 79] 80++ lib . optionals stdenv . isDarwin ([ 81libiconv 82]); 83 84libPath = lib . makeLibraryPath ( 85with pkgs ; 86[ 87xorg . xcbutilimage 88libGL 89vulkan-loader 90] 91); 92 93rustPlatform = pkgs . makeRustPlatform { 94cargo = pkgs . rust-bin . stable . latest . minimal ; 95rustc = pkgs . rust-bin . stable . latest . minimal ; 96}; 97in 98{ 99packages . default = rustPlatform . buildRustPackage rec { 100inherit buildInputs nativeBuildInputs ; 101 102name = "wezterm" ; 103src = ./.. ; 104version = self . shortRev or "dev" ; 105 106cargoLock = { 107lockFile = ../Cargo.lock ; 108allowBuiltinFetchGit = true ; 109}; 110 111prePatch = '' 112rm -rf deps/freetype/{freetype2,libpng,zlib} deps/harfbuzz/harfbuzz 113 114ln -s ${ inputs . freetype2 } deps/freetype/freetype2 115ln -s ${ inputs . libpng } deps/freetype/libpng 116ln -s ${ inputs . zlib } deps/freetype/zlib 117ln -s ${ inputs . harfbuzz } deps/harfbuzz/harfbuzz 118'' ; 119 120postPatch = '' 121echo ${ version } > .tag 122 123# tests are failing with: Unable to exchange encryption keys 124rm -r wezterm-ssh/tests 125 126# hash does not work well with NixOS 127substituteInPlace assets/shell-integration/wezterm.sh \ 128--replace-fail 'hash wezterm 2>/dev/null' 'command type -P wezterm &>/dev/null' \ 129--replace-fail 'hash base64 2>/dev/null' 'command type -P base64 &>/dev/null' \ 130--replace-fail 'hash hostname 2>/dev/null' 'command type -P hostname &>/dev/null' \ 131--replace-fail 'hash hostnamectl 2>/dev/null' 'command type -P hostnamectl &>/dev/null' 132'' ; 133 134preFixup = 135lib . optionalString stdenv . isLinux '' 136patchelf \ 137--add-needed " ${ pkgs . libGL } /lib/libEGL.so.1" \ 138--add-needed " ${ pkgs . vulkan-loader } /lib/libvulkan.so.1" \ 139$out/bin/wezterm-gui 140'' 141+ lib . optionalString stdenv . isDarwin '' 142mkdir -p "$out/Applications" 143OUT_APP="$out/Applications/WezTerm.app" 144cp -r assets/macos/WezTerm.app "$OUT_APP" 145rm $OUT_APP/*.dylib 146cp -r assets/shell-integration/* "$OUT_APP" 147ln -s $out/bin/{wezterm,wezterm-mux-server,wezterm-gui,strip-ansi-escapes} "$OUT_APP" 148'' ; 149 150postInstall = '' 151mkdir -p $ out /nix-support 152echo " ${ passthru . terminfo } " >> $ out /nix-support/propagated-user-env-packages 153 154install -Dm644 assets/icon/terminal.png $ out /share/icons/hicolor/128x128/apps/org.wezfurlong.wezterm.png 155install -Dm644 assets/wezterm.desktop $ out /share/applications/org.wezfurlong.wezterm.desktop 156install -Dm644 assets/wezterm.appdata.xml $ out /share/metainfo/org.wezfurlong.wezterm.appdata.xml 157 158install -Dm644 assets/shell-integration/wezterm.sh -t $ out /etc/profile.d 159installShellCompletion --cmd wezterm \ 160--bash assets/shell-completion/bash \ 161--fish assets/shell-completion/fish \ 162--zsh assets/shell-completion/zsh 163 164install -Dm644 assets/wezterm-nautilus.py -t $ out /share/nautilus-python/extensions 165'' ; 166 167passthru = { 168# the headless variant is useful when deploying wezterm's mux server on remote severs 169headless = rustPlatform . buildRustPackage { 170pname = "wezterm-headless" ; 171inherit 172version 173src 174postPatch 175cargoLock 176meta 177; 178 179nativeBuildInputs = [ pkgs . pkg-config ]; 180 181buildInputs = [ pkgs . openssl ]; 182 183cargoBuildFlags = [ 184"--package" 185"wezterm" 186"--package" 187"wezterm-mux-server" 188]; 189 190doCheck = false ; 191 192postInstall = '' 193install -Dm644 assets/shell-integration/wezterm.sh -t $ out /etc/profile.d 194install -Dm644 ${ passthru . terminfo } /share/terminfo/w/wezterm -t $ out /share/terminfo/w 195'' ; 196}; 197 198terminfo = 199pkgs . runCommand "wezterm-terminfo" 200{ 201nativeBuildInputs = [ pkgs . ncurses ]; 202} 203'' 204mkdir -p $ out /share/terminfo $ out /nix-support 205tic -x -o $ out /share/terminfo ${ src } /termwiz/data/wezterm.terminfo 206'' ; 207}; 208 209meta . mainProgram = "wezterm" ; 210}; 211 212devShell = pkgs . mkShell { 213name = "wezterm-shell" ; 214inherit nativeBuildInputs ; 215 216buildInputs = 217buildInputs 218++ ( with pkgs . rust-bin ; [ 219( stable . latest . minimal . override { 220extensions = [ 221"clippy" 222"rust-src" 223]; 224}) 225 226nightly . latest . rustfmt 227nightly . latest . rust-analyzer 228]); 229 230LD_LIBRARY_PATH = libPath ; 231RUST_BACKTRACE = 1 ; 232}; 233 234formatter = pkgs . nixfmt-rfc-style ; 235} 236); 237}