2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-03-30 16:58:05 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-03-30 16:58:05 +02:00
|
|
|
|
|
|
|
let
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
cfgC = config.services.synergy.client;
|
|
|
|
cfgS = config.services.synergy.server;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
2009-03-30 16:58:05 +02:00
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
services.synergy = {
|
|
|
|
|
|
|
|
# !!! All these option descriptions needs to be cleaned up.
|
|
|
|
|
|
|
|
client = {
|
2020-04-20 20:05:26 +02:00
|
|
|
enable = mkEnableOption "the Synergy client (receive keyboard and mouse events from a Synergy server)";
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
screenName = mkOption {
|
|
|
|
default = "";
|
2021-01-31 12:17:41 +01:00
|
|
|
type = types.str;
|
2013-10-31 13:18:00 +01:00
|
|
|
description = ''
|
|
|
|
Use the given name instead of the hostname to identify
|
2013-08-10 23:07:13 +02:00
|
|
|
ourselves to the server.
|
2013-10-31 13:18:00 +01:00
|
|
|
'';
|
2009-03-30 16:58:05 +02:00
|
|
|
};
|
2009-12-04 13:50:49 +01:00
|
|
|
serverAddress = mkOption {
|
2021-01-31 12:17:41 +01:00
|
|
|
type = types.str;
|
2013-10-31 13:18:00 +01:00
|
|
|
description = ''
|
2009-12-04 13:50:49 +01:00
|
|
|
The server address is of the form: [hostname][:port]. The
|
|
|
|
hostname must be the address or hostname of the server. The
|
|
|
|
port overrides the default port, 24800.
|
2013-10-31 13:18:00 +01:00
|
|
|
'';
|
2009-12-04 13:50:49 +01:00
|
|
|
};
|
2013-06-26 22:13:57 +02:00
|
|
|
autoStart = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2013-10-31 13:18:00 +01:00
|
|
|
description = "Whether the Synergy client should be started automatically.";
|
2013-06-26 22:13:57 +02:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-03-30 16:58:05 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
server = {
|
2020-04-20 20:05:26 +02:00
|
|
|
enable = mkEnableOption "the Synergy server (send keyboard and mouse events)";
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
configFile = mkOption {
|
2021-01-31 12:17:41 +01:00
|
|
|
type = types.path;
|
2009-10-12 18:36:19 +02:00
|
|
|
default = "/etc/synergy-server.conf";
|
2013-10-31 13:18:00 +01:00
|
|
|
description = "The Synergy server configuration file.";
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
|
|
|
screenName = mkOption {
|
2021-01-31 12:17:41 +01:00
|
|
|
type = types.str;
|
2009-10-12 18:36:19 +02:00
|
|
|
default = "";
|
2013-10-31 13:18:00 +01:00
|
|
|
description = ''
|
|
|
|
Use the given name instead of the hostname to identify
|
2009-10-12 18:36:19 +02:00
|
|
|
this screen in the configuration.
|
2013-10-31 13:18:00 +01:00
|
|
|
'';
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
|
|
|
address = mkOption {
|
2021-01-31 12:17:41 +01:00
|
|
|
type = types.str;
|
2009-10-12 18:36:19 +02:00
|
|
|
default = "";
|
2013-10-31 13:18:00 +01:00
|
|
|
description = "Address on which to listen for clients.";
|
2009-03-30 16:58:05 +02:00
|
|
|
};
|
2013-06-26 22:13:57 +02:00
|
|
|
autoStart = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2013-10-31 13:18:00 +01:00
|
|
|
description = "Whether the Synergy server should be started automatically.";
|
2013-06-26 22:13:57 +02:00
|
|
|
};
|
2021-05-31 00:15:56 +02:00
|
|
|
tls = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether TLS encryption should be used.
|
|
|
|
|
|
|
|
Using this requires a TLS certificate that can be
|
|
|
|
generated by starting the Synergy GUI once and entering
|
|
|
|
a valid product key.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cert = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "~/.synergy/SSL/Synergy.pem";
|
|
|
|
description = "The TLS certificate to use for encryption.";
|
|
|
|
};
|
|
|
|
};
|
2009-03-30 16:58:05 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
###### implementation
|
2009-03-30 16:58:05 +02:00
|
|
|
|
2014-12-05 00:25:26 +01:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfgC.enable {
|
2019-08-13 23:52:01 +02:00
|
|
|
systemd.user.services.synergy-client = {
|
2018-05-19 03:36:34 +02:00
|
|
|
after = [ "network.target" "graphical-session.target" ];
|
2014-12-05 00:25:26 +01:00
|
|
|
description = "Synergy client";
|
2018-05-19 03:36:34 +02:00
|
|
|
wantedBy = optional cfgC.autoStart "graphical-session.target";
|
2014-12-05 00:25:26 +01:00
|
|
|
path = [ pkgs.synergy ];
|
|
|
|
serviceConfig.ExecStart = ''${pkgs.synergy}/bin/synergyc -f ${optionalString (cfgC.screenName != "") "-n ${cfgC.screenName}"} ${cfgC.serverAddress}'';
|
2015-10-13 02:46:37 +02:00
|
|
|
serviceConfig.Restart = "on-failure";
|
2014-12-05 00:25:26 +01:00
|
|
|
};
|
|
|
|
})
|
|
|
|
(mkIf cfgS.enable {
|
2019-08-13 23:52:01 +02:00
|
|
|
systemd.user.services.synergy-server = {
|
2018-05-19 03:36:34 +02:00
|
|
|
after = [ "network.target" "graphical-session.target" ];
|
2014-12-05 00:25:26 +01:00
|
|
|
description = "Synergy server";
|
2018-05-19 03:36:34 +02:00
|
|
|
wantedBy = optional cfgS.autoStart "graphical-session.target";
|
2014-12-05 00:25:26 +01:00
|
|
|
path = [ pkgs.synergy ];
|
2021-05-31 00:15:56 +02:00
|
|
|
serviceConfig.ExecStart = ''${pkgs.synergy}/bin/synergys -c ${cfgS.configFile} -f${optionalString (cfgS.address != "") " -a ${cfgS.address}"}${optionalString (cfgS.screenName != "") " -n ${cfgS.screenName}"}${optionalString cfgS.tls.enable " --enable-crypto"}${optionalString (cfgS.tls.cert != null) (" --tls-cert=${cfgS.tls.cert}")}'';
|
2015-10-13 02:46:37 +02:00
|
|
|
serviceConfig.Restart = "on-failure";
|
2014-12-05 00:25:26 +01:00
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2009-03-30 16:58:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SYNERGY SERVER example configuration file
|
|
|
|
section: screens
|
|
|
|
laptop:
|
|
|
|
dm:
|
|
|
|
win:
|
|
|
|
end
|
|
|
|
section: aliases
|
2011-09-14 20:20:50 +02:00
|
|
|
laptop:
|
2009-03-30 16:58:05 +02:00
|
|
|
192.168.5.5
|
|
|
|
dm:
|
|
|
|
192.168.5.78
|
|
|
|
win:
|
|
|
|
192.168.5.54
|
|
|
|
end
|
|
|
|
section: links
|
|
|
|
laptop:
|
|
|
|
left = dm
|
|
|
|
dm:
|
|
|
|
right = laptop
|
|
|
|
left = win
|
|
|
|
win:
|
|
|
|
right = dm
|
|
|
|
end
|
|
|
|
*/
|