1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 zlib,
6 protobuf,
7 ncurses,
8 pkg-config,
9 makeWrapper,
10 perl,
11 openssl,
12 autoreconfHook,
13 openssh,
14 bash-completion,
15 fetchpatch,
16 withUtempter ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isMusl,
17 libutempter,
18}:
19
20stdenv.mkDerivation rec {
21 pname = "mosh";
22 version = "1.4.0";
23
24 src = fetchFromGitHub {
25 owner = "mobile-shell";
26 repo = "mosh";
27 rev = "mosh-${version}";
28 hash = "sha256-tlSsHu7JnXO+sorVuWWubNUNdb9X0/pCaiGG5Y0X/g8=";
29 };
30
31 nativeBuildInputs = [
32 autoreconfHook
33 pkg-config
34 makeWrapper
35 protobuf
36 perl
37 ];
38 buildInputs = [
39 protobuf
40 ncurses
41 zlib
42 openssl
43 bash-completion
44 perl
45 ]
46 ++ lib.optional withUtempter libutempter;
47
48 strictDeps = true;
49
50 enableParallelBuilding = true;
51
52 patches = [
53 ./ssh_path.patch
54 ./mosh-client_path.patch
55 # Fix build with bash-completion 2.10
56 ./bash_completion_datadir.patch
57
58 # Fixes build with protobuf3 23.x
59 (fetchpatch {
60 url = "https://github.com/mobile-shell/mosh/commit/eee1a8cf413051c2a9104e8158e699028ff56b26.patch";
61 hash = "sha256-CouLHWSsyfcgK3k7CvTK3FP/xjdb1pfsSXYYQj3NmCQ=";
62 })
63 ];
64
65 postPatch = ''
66 substituteInPlace scripts/mosh.pl \
67 --subst-var-by ssh "${openssh}/bin/ssh" \
68 --subst-var-by mosh-client "$out/bin/mosh-client"
69 '';
70
71 configureFlags = [ "--enable-completion" ] ++ lib.optional withUtempter "--with-utempter";
72
73 postInstall = ''
74 wrapProgram $out/bin/mosh --prefix PERL5LIB : $PERL5LIB
75 '';
76
77 meta = with lib; {
78 homepage = "https://mosh.org/";
79 description = "Mobile shell (ssh replacement)";
80 longDescription = ''
81 Remote terminal application that allows roaming, supports intermittent
82 connectivity, and provides intelligent local echo and line editing of
83 user keystrokes.
84
85 Mosh is a replacement for SSH. It's more robust and responsive,
86 especially over Wi-Fi, cellular, and long-distance links.
87 '';
88 license = licenses.gpl3Plus;
89 maintainers = with lib.maintainers; [ skeuchel ];
90 platforms = platforms.unix;
91 };
92}