summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hoang <enzime@users.noreply.github.com>2018-09-11 17:52:58 +1000
committerMichael Hoang <enzime@users.noreply.github.com>2018-09-14 20:48:23 +1000
commit6d013ea1668b557ea3c6183ce99fb15fb0d2741c (patch)
treeaa565de02b1e10eb7951e0d02b7532053deab165
parentadd86e33a2fd098a4745dc5d56809ebc8bac1738 (diff)
synergy: Add module for client and server
-rw-r--r--default.nix1
-rw-r--r--modules/services/synergy/default.nix116
2 files changed, 117 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index c04b297..97e1280 100644
--- a/default.nix
+++ b/default.nix
@@ -59,6 +59,7 @@ let
./modules/services/privoxy
./modules/services/redis
./modules/services/skhd
+ ./modules/services/synergy
./modules/programs/bash
./modules/programs/fish.nix
./modules/programs/gnupg.nix
diff --git a/modules/services/synergy/default.nix b/modules/services/synergy/default.nix
new file mode 100644
index 0000000..71418a6
--- /dev/null
+++ b/modules/services/synergy/default.nix
@@ -0,0 +1,116 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ cfg = config.services.synergy;
+
+in
+
+{
+ options = {
+
+ services.synergy = {
+ package = mkOption {
+ default = pkgs.synergy;
+ defaultText = "pkgs.synergy";
+ type = types.package;
+ description = "The package used for the synergy client and server.";
+ };
+
+ client = {
+ enable = mkOption {
+ default = false;
+ type = types.bool;
+ description = "
+ Whether to enable the Synergy client (receive keyboard and mouse events from a Synergy server).
+ ";
+ };
+ screenName = mkOption {
+ default = "";
+ type = types.str;
+ description = ''
+ Use the given name instead of the hostname to identify
+ ourselves to the server.
+ '';
+ };
+ serverAddress = mkOption {
+ type = types.str;
+ description = ''
+ 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.
+ '';
+ };
+ autoStart = mkOption {
+ default = true;
+ type = types.bool;
+ description = "Whether the Synergy client should be started automatically.";
+ };
+ };
+
+ server = {
+ enable = mkOption {
+ default = false;
+ type = types.bool;
+ description = ''
+ Whether to enable the Synergy server (send keyboard and mouse events).
+ '';
+ };
+ configFile = mkOption {
+ default = "/etc/synergy-server.conf";
+ type = types.str;
+ description = "The Synergy server configuration file.";
+ };
+ screenName = mkOption {
+ default = "";
+ type = types.str;
+ description = ''
+ Use the given name instead of the hostname to identify
+ this screen in the configuration.
+ '';
+ };
+ address = mkOption {
+ default = "";
+ type = types.str;
+ description = "Address on which to listen for clients.";
+ };
+ autoStart = mkOption {
+ default = true;
+ type = types.bool;
+ description = "Whether the Synergy server should be started automatically.";
+ };
+ };
+ };
+
+ };
+
+
+ config = mkMerge [
+ (mkIf cfg.client.enable {
+ launchd.user.agents."synergy-client" = {
+ path = [ config.environment.systemPath ];
+ serviceConfig.ProgramArguments = [
+ "${cfg.package}/bin/synergyc" "-f" "${cfg.client.serverAddress}"
+ ] ++ optionals (cfg.client.screenName != "") [ "-n" cfg.client.screenName ];
+ serviceConfig.KeepAlive = true;
+ serviceConfig.RunAtLoad = cfg.client.autoStart;
+ serviceConfig.ProcessType = "Interactive";
+ };
+ })
+
+ (mkIf cfg.server.enable {
+ launchd.user.agents."synergy-server" = {
+ path = [ config.environment.systemPath ];
+ serviceConfig.ProgramArguments = [
+ "${cfg.package}/bin/synergys" "-c" "${cfg.server.configFile}" "-f"
+ ] ++ optionals (cfg.server.screenName != "") [ "-n" cfg.server.screenName ]
+ ++ optionals (cfg.server.address != "") [ "-a" cfg.server.address ];
+ serviceConfig.KeepAlive = true;
+ serviceConfig.RunAtLoad = cfg.server.autoStart;
+ serviceConfig.ProcessType = "Interactive";
+ };
+ })
+ ];
+}