lol
1{ lib, stdenv, fetchurl, fetchpatch, zlib, protobuf, ncurses, pkg-config
2, makeWrapper, perlPackages, openssl, autoreconfHook, openssh, bash-completion
3, withUtempter ? stdenv.isLinux, libutempter }:
4
5stdenv.mkDerivation rec {
6 pname = "mosh";
7 version = "1.3.2";
8
9 src = fetchurl {
10 url = "https://mosh.org/mosh-${version}.tar.gz";
11 sha256 = "05hjhlp6lk8yjcy59zywpf0r6s0h0b9zxq0lw66dh9x8vxrhaq6s";
12 };
13
14 nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper ];
15 buildInputs = [ protobuf ncurses zlib openssl bash-completion ]
16 ++ (with perlPackages; [ perl IOTty ])
17 ++ lib.optional withUtempter libutempter;
18
19 enableParallelBuilding = true;
20
21 patches = [
22 ./ssh_path.patch
23 ./mosh-client_path.patch
24 ./utempter_path.patch
25 # Fix w/c++17, ::bind vs std::bind
26 (fetchpatch {
27 url = "https://github.com/mobile-shell/mosh/commit/e5f8a826ef9ff5da4cfce3bb8151f9526ec19db0.patch";
28 sha256 = "15518rb0r5w1zn4s6981bf1sz6ins6gpn2saizfzhmr13hw4gmhm";
29 })
30 # Fix build with bash-completion 2.10
31 ./bash_completion_datadir.patch
32 ];
33
34 postPatch = ''
35 # Fix build with Xcode 12.5 toolchain/case-insensitive filesystems
36 # Backport of https://github.com/mobile-shell/mosh/commit/12199114fe4234f791ef4c306163901643b40538;
37 # remove on next upstream release.
38 patch -p0 < ${fetchpatch {
39 url = "https://raw.githubusercontent.com/macports/macports-ports/70ca3f65e622c17582fd938602d800157ed951c3/net/mosh/files/patch-version-subdir.diff";
40 sha256 = "1yyh6d07y9zbdx4fb0r56zkq9nd9knwzj22v4dfi55k4k42qxapd";
41 }}
42
43 substituteInPlace scripts/mosh.pl \
44 --subst-var-by ssh "${openssh}/bin/ssh" \
45 --subst-var-by mosh-client "$out/bin/mosh-client"
46 '';
47
48 configureFlags = [ "--enable-completion" ]
49 ++ lib.optional withUtempter "--with-utempter";
50
51 postInstall = ''
52 wrapProgram $out/bin/mosh --prefix PERL5LIB : $PERL5LIB
53 '';
54
55 CXXFLAGS = lib.optionalString stdenv.cc.isClang "-std=c++11";
56
57 meta = with lib; {
58 homepage = "https://mosh.org/";
59 description = "Mobile shell (ssh replacement)";
60 longDescription = ''
61 Remote terminal application that allows roaming, supports intermittent
62 connectivity, and provides intelligent local echo and line editing of
63 user keystrokes.
64
65 Mosh is a replacement for SSH. It's more robust and responsive,
66 especially over Wi-Fi, cellular, and long-distance links.
67 '';
68 license = licenses.gpl3Plus;
69 maintainers = with maintainers; [ viric SuperSandro2000 ];
70 platforms = platforms.unix;
71 };
72}