2009-10-12 16:36:19 +00:00
|
|
|
{ config, pkgs, ... }:
|
2009-03-30 14:58:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
with pkgs.lib;
|
2009-03-30 14:58:05 +00:00
|
|
|
|
|
|
|
let
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
cfgC = config.services.synergy.client;
|
|
|
|
cfgS = config.services.synergy.server;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
2009-03-30 14:58:05 +00:00
|
|
|
|
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
services.synergy = {
|
|
|
|
|
|
|
|
# !!! All these option descriptions needs to be cleaned up.
|
|
|
|
|
|
|
|
client = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
2013-10-31 12:18:00 +00:00
|
|
|
Whether to enable the Synergy client (receive keyboard and mouse events from a Synergy server).
|
2009-10-12 16:36:19 +00:00
|
|
|
";
|
|
|
|
};
|
|
|
|
screenName = mkOption {
|
|
|
|
default = "";
|
2013-10-31 12:18:00 +00:00
|
|
|
description = ''
|
|
|
|
Use the given name instead of the hostname to identify
|
2013-08-10 21:07:13 +00:00
|
|
|
ourselves to the server.
|
2013-10-31 12:18:00 +00:00
|
|
|
'';
|
2009-03-30 14:58:05 +00:00
|
|
|
};
|
2009-12-04 12:50:49 +00:00
|
|
|
serverAddress = mkOption {
|
2013-10-31 12:18:00 +00:00
|
|
|
description = ''
|
2009-12-04 12:50:49 +00: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 12:18:00 +00:00
|
|
|
'';
|
2009-12-04 12:50:49 +00:00
|
|
|
};
|
2013-06-26 20:13:57 +00:00
|
|
|
autoStart = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2013-10-31 12:18:00 +00:00
|
|
|
description = "Whether the Synergy client should be started automatically.";
|
2013-06-26 20:13:57 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2009-03-30 14:58:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
server = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
2013-10-31 12:18:00 +00:00
|
|
|
description = ''
|
|
|
|
Whether to enable the Synergy server (send keyboard and mouse events).
|
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
configFile = mkOption {
|
|
|
|
default = "/etc/synergy-server.conf";
|
2013-10-31 12:18:00 +00:00
|
|
|
description = "The Synergy server configuration file.";
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
screenName = mkOption {
|
|
|
|
default = "";
|
2013-10-31 12:18:00 +00:00
|
|
|
description = ''
|
|
|
|
Use the given name instead of the hostname to identify
|
2009-10-12 16:36:19 +00:00
|
|
|
this screen in the configuration.
|
2013-10-31 12:18:00 +00:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
address = mkOption {
|
|
|
|
default = "";
|
2013-10-31 12:18:00 +00:00
|
|
|
description = "Address on which to listen for clients.";
|
2009-03-30 14:58:05 +00:00
|
|
|
};
|
2013-06-26 20:13:57 +00:00
|
|
|
autoStart = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2013-10-31 12:18:00 +00:00
|
|
|
description = "Whether the Synergy server should be started automatically.";
|
2013-06-26 20:13:57 +00:00
|
|
|
};
|
2009-03-30 14:58:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
###### implementation
|
2009-03-30 14:58:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
config = {
|
2009-03-30 14:58:05 +00:00
|
|
|
|
2013-06-26 20:13:57 +00:00
|
|
|
systemd.services."synergy-client" = mkIf cfgC.enable {
|
|
|
|
after = [ "network.target" ];
|
|
|
|
description = "Synergy client";
|
|
|
|
wantedBy = optional cfgC.autoStart "multi-user.target";
|
|
|
|
path = [ pkgs.synergy ];
|
|
|
|
serviceConfig.ExecStart = ''${pkgs.synergy}/bin/synergyc -f ${optionalString (cfgC.screenName != "") "-n ${cfgC.screenName}"} ${cfgC.serverAddress}'';
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2013-06-26 20:13:57 +00:00
|
|
|
systemd.services."synergy-server" = mkIf cfgS.enable {
|
|
|
|
after = [ "network.target" ];
|
|
|
|
description = "Synergy server";
|
|
|
|
wantedBy = optional cfgS.autoStart "multi-user.target";
|
|
|
|
path = [ pkgs.synergy ];
|
|
|
|
serviceConfig.ExecStart = ''${pkgs.synergy}/bin/synergys -c ${cfgS.configFile} -f ${optionalString (cfgS.address != "") "-a ${cfgS.address}"} ${optionalString (cfgS.screenName != "") "-n ${cfgS.screenName}" }'';
|
|
|
|
};
|
2009-03-30 14:58:05 +00:00
|
|
|
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-03-30 14:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SYNERGY SERVER example configuration file
|
|
|
|
section: screens
|
|
|
|
laptop:
|
|
|
|
dm:
|
|
|
|
win:
|
|
|
|
end
|
|
|
|
section: aliases
|
2011-09-14 18:20:50 +00:00
|
|
|
laptop:
|
2009-03-30 14:58:05 +00: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
|
|
|
|
*/
|