1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/services/osmscout-server.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05:00

86 lines
1.9 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkOption types;
cfg = config.services.osmscout-server;
in
{
meta.maintainers = [ lib.maintainers.Thra11 ];
options = {
services.osmscout-server = {
enable = lib.mkEnableOption "OSM Scout Server";
package = lib.mkPackageOption pkgs "osmscout-server" { };
network = {
startWhenNeeded = mkOption {
type = types.bool;
default = true;
description = ''
Enable systemd socket activation.
'';
};
listenAddress = mkOption {
type = types.str;
default = "127.0.0.1";
description = ''
The address for the server to listen on.
'';
};
port = mkOption {
type = types.port;
default = 8553;
description = ''
The TCP port on which the server will listen.
'';
};
};
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.osmscout-server" pkgs lib.platforms.linux)
];
systemd.user.services.osmscout-server = {
Unit = {
Description = "OSM Scout Server";
};
Install = mkIf (!cfg.network.startWhenNeeded) {
WantedBy = [ "default.target" ];
};
Service = {
ExecStart = "'${cfg.package}/bin/osmscout-server' --systemd --quiet";
};
};
systemd.user.sockets.osmscout-server = mkIf cfg.network.startWhenNeeded {
Unit = {
Description = "OSM Scout Server Socket";
};
Socket = {
ListenStream = "${cfg.network.listenAddress}:${toString cfg.network.port}";
TriggerLimitIntervalSec = "60s";
TriggerLimitBurst = 1;
};
Install = {
WantedBy = [ "sockets.target" ];
};
};
home.packages = [ cfg.package ];
};
}