nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 # build server binary only when set to false (useful for perlless systems)
19 withClient ? true,
20}:
21
22stdenv.mkDerivation (finalAttrs: {
23 pname = "mosh";
24 version = "1.4.0";
25
26 src = fetchFromGitHub {
27 owner = "mobile-shell";
28 repo = "mosh";
29 rev = "mosh-${finalAttrs.version}";
30 hash = "sha256-tlSsHu7JnXO+sorVuWWubNUNdb9X0/pCaiGG5Y0X/g8=";
31 };
32
33 nativeBuildInputs = [
34 autoreconfHook
35 pkg-config
36 makeWrapper
37 protobuf
38 perl
39 ];
40 buildInputs = [
41 protobuf
42 ncurses
43 zlib
44 openssl
45 bash-completion
46 ]
47 ++ lib.optionals withClient [
48 perl
49 ]
50 ++ lib.optional withUtempter libutempter;
51
52 strictDeps = true;
53
54 enableParallelBuilding = true;
55
56 patches = [
57 ./ssh_path.patch
58 ./mosh-client_path.patch
59 # Fix build with bash-completion 2.10
60 ./bash_completion_datadir.patch
61
62 # Fixes build with protobuf3 23.x
63 (fetchpatch {
64 url = "https://github.com/mobile-shell/mosh/commit/eee1a8cf413051c2a9104e8158e699028ff56b26.patch";
65 hash = "sha256-CouLHWSsyfcgK3k7CvTK3FP/xjdb1pfsSXYYQj3NmCQ=";
66 })
67 ];
68
69 postPatch = ''
70 substituteInPlace scripts/mosh.pl \
71 --subst-var-by ssh "${openssh}/bin/ssh" \
72 --subst-var-by mosh-client "$out/bin/mosh-client"
73 '';
74
75 configureFlags = [ "--enable-completion" ] ++ lib.optional withUtempter "--with-utempter";
76
77 postInstall =
78 if withClient then
79 ''
80 wrapProgram $out/bin/mosh --prefix PERL5LIB : $PERL5LIB
81 ''
82 else
83 ''
84 rm $out/bin/mosh
85 rm $out/bin/mosh-client
86 rm -r $out/share/{man,bash-completion}
87 '';
88
89 meta = {
90 homepage = "https://mosh.org/";
91 description = "Mobile shell (ssh replacement)";
92 longDescription = ''
93 Remote terminal application that allows roaming, supports intermittent
94 connectivity, and provides intelligent local echo and line editing of
95 user keystrokes.
96
97 Mosh is a replacement for SSH. It's more robust and responsive,
98 especially over Wi-Fi, cellular, and long-distance links.
99 '';
100 license = lib.licenses.gpl3Plus;
101 maintainers = with lib.maintainers; [ skeuchel ];
102 platforms = lib.platforms.unix;
103 };
104})