nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 withGUI ? true,
3 stdenv,
4 lib,
5 fetchFromGitHub,
6 wrapQtAppsHook,
7
8 cmake,
9 openssl,
10 pcre,
11 util-linux,
12 libselinux,
13 libsepol,
14 pkg-config,
15 gdk-pixbuf,
16 libnotify,
17 qttools,
18 libICE,
19 libSM,
20 libX11,
21 libxkbfile,
22 libXi,
23 libXtst,
24 libXrandr,
25 libXinerama,
26 xkeyboardconfig,
27 xinput,
28 avahi-compat,
29
30}:
31
32stdenv.mkDerivation rec {
33 pname = "synergy";
34 version = "1.14.6.19-stable";
35
36 src = fetchFromGitHub {
37 owner = "symless";
38 repo = "synergy-core";
39 rev = version;
40 hash = "sha256-0QqklfSsvcXh7I2jaHk82k0nY8gQOj9haA4WOjGqBqY=";
41 fetchSubmodules = true;
42 };
43
44 patches = [
45 # Without this OpenSSL from nixpkgs is not detected
46 ./darwin-non-static-openssl.patch
47 ];
48
49 postPatch = ''
50 substituteInPlace src/gui/src/SslCertificate.cpp \
51 --replace 'kUnixOpenSslCommand[] = "openssl";' 'kUnixOpenSslCommand[] = "${openssl}/bin/openssl";'
52 ''
53 + lib.optionalString stdenv.hostPlatform.isLinux ''
54 substituteInPlace src/lib/synergy/unix/AppUtilUnix.cpp \
55 --replace "/usr/share/X11/xkb/rules/evdev.xml" "${xkeyboardconfig}/share/X11/xkb/rules/evdev.xml"
56 '';
57
58 nativeBuildInputs = [
59 cmake
60 pkg-config
61 ]
62 ++ lib.optional withGUI wrapQtAppsHook;
63
64 buildInputs = [
65 qttools # Used for translations even when not building the GUI
66 openssl
67 pcre
68 ]
69 ++ lib.optionals stdenv.hostPlatform.isLinux [
70 util-linux
71 libselinux
72 libsepol
73 libICE
74 libSM
75 libX11
76 libXi
77 libXtst
78 libXrandr
79 libXinerama
80 libxkbfile
81 xinput
82 avahi-compat
83 gdk-pixbuf
84 libnotify
85 ];
86
87 # Silences many warnings
88 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-inconsistent-missing-override";
89
90 cmakeFlags =
91 lib.optional (!withGUI) "-DSYNERGY_BUILD_LEGACY_GUI=OFF"
92 # NSFilenamesPboardType is deprecated in 10.14+
93 ++ lib.optional stdenv.hostPlatform.isDarwin "-DCMAKE_OSX_DEPLOYMENT_TARGET=${
94 if stdenv.hostPlatform.isAarch64 then "10.13" else stdenv.hostPlatform.darwinSdkVersion
95 }";
96
97 doCheck = true;
98
99 checkPhase = ''
100 runHook preCheck
101 ''
102 + lib.optionalString stdenv.hostPlatform.isDarwin ''
103 # filter out tests failing with sandboxing on darwin
104 export GTEST_FILTER=-ServerConfigTests.serverconfig_will_deem_equal_configs_with_same_cell_names:NetworkAddress.hostname_valid_parsing
105 ''
106 + ''
107 bin/unittests
108 runHook postCheck
109 '';
110
111 installPhase = ''
112 runHook preInstall
113
114 mkdir -p $out/bin
115 cp bin/{synergyc,synergys,synergyd,syntool} $out/bin/
116 ''
117 + lib.optionalString withGUI ''
118 cp bin/synergy $out/bin/
119 ''
120 + lib.optionalString stdenv.hostPlatform.isLinux ''
121 mkdir -p $out/share/{applications,icons/hicolor/scalable/apps}
122 cp ../res/synergy.svg $out/share/icons/hicolor/scalable/apps/
123 substitute ../res/synergy.desktop $out/share/applications/synergy.desktop \
124 --replace "/usr/bin" "$out/bin"
125 ''
126 + lib.optionalString (stdenv.hostPlatform.isDarwin && withGUI) ''
127 mkdir -p $out/Applications
128 cp -r bundle/Synergy.app $out/Applications
129 ln -s $out/bin $out/Applications/Synergy.app/Contents/MacOS
130 ''
131 + ''
132 runHook postInstall
133 '';
134
135 dontWrapQtApps = lib.optional (!withGUI) true;
136
137 meta = {
138 description = "Share one mouse and keyboard between multiple computers";
139 homepage = "https://symless.com/synergy";
140 changelog = "https://github.com/symless/synergy-core/blob/${version}/ChangeLog";
141 mainProgram = lib.optionalString (!withGUI) "synergyc";
142 license = lib.licenses.gpl2Only;
143 maintainers = with lib.maintainers; [ talyz ];
144 platforms = lib.platforms.unix;
145 };
146}