1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-18 15:39:46 +03:00
nixpkgs/nixos/modules/services/misc/synergy.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

165 lines
4.4 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfgC = config.services.synergy.client;
cfgS = config.services.synergy.server;
in
{
###### interface
options = {
services.synergy = {
# !!! All these option descriptions needs to be cleaned up.
client = {
enable = lib.mkEnableOption "the Synergy client (receive keyboard and mouse events from a Synergy server)";
screenName = lib.mkOption {
default = "";
type = lib.types.str;
description = ''
Use the given name instead of the hostname to identify
ourselves to the server.
'';
};
serverAddress = lib.mkOption {
type = lib.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 = lib.mkOption {
default = true;
type = lib.types.bool;
description = "Whether the Synergy client should be started automatically.";
};
};
server = {
enable = lib.mkEnableOption "the Synergy server (send keyboard and mouse events)";
configFile = lib.mkOption {
type = lib.types.path;
default = "/etc/synergy-server.conf";
description = "The Synergy server configuration file.";
};
screenName = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Use the given name instead of the hostname to identify
this screen in the configuration.
'';
};
address = lib.mkOption {
type = lib.types.str;
default = "";
description = "Address on which to listen for clients.";
};
autoStart = lib.mkOption {
default = true;
type = lib.types.bool;
description = "Whether the Synergy server should be started automatically.";
};
tls = {
enable = lib.mkOption {
type = lib.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 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "~/.synergy/SSL/Synergy.pem";
description = "The TLS certificate to use for encryption.";
};
};
};
};
};
###### implementation
config = lib.mkMerge [
(lib.mkIf cfgC.enable {
systemd.user.services.synergy-client = {
after = [
"network.target"
"graphical-session.target"
];
description = "Synergy client";
wantedBy = lib.optional cfgC.autoStart "graphical-session.target";
path = [ pkgs.synergy ];
serviceConfig.ExecStart = ''${pkgs.synergy}/bin/synergyc -f ${
lib.optionalString (cfgC.screenName != "") "-n ${cfgC.screenName}"
} ${cfgC.serverAddress}'';
serviceConfig.Restart = "on-failure";
};
})
(lib.mkIf cfgS.enable {
systemd.user.services.synergy-server = {
after = [
"network.target"
"graphical-session.target"
];
description = "Synergy server";
wantedBy = lib.optional cfgS.autoStart "graphical-session.target";
path = [ pkgs.synergy ];
serviceConfig.ExecStart = ''${pkgs.synergy}/bin/synergys -c ${cfgS.configFile} -f${
lib.optionalString (cfgS.address != "") " -a ${cfgS.address}"
}${
lib.optionalString (cfgS.screenName != "") " -n ${cfgS.screenName}"
}${lib.optionalString cfgS.tls.enable " --enable-crypto"}${
lib.optionalString (cfgS.tls.cert != null) (" --tls-cert ${cfgS.tls.cert}")
}'';
serviceConfig.Restart = "on-failure";
};
})
];
}
/*
SYNERGY SERVER example configuration file
section: screens
laptop:
dm:
win:
end
section: aliases
laptop:
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
*/