{
config,
pkgs,
lib,
...
}: let
cfg = config.services.sunshine;
in {
options.services.sunshine = with lib; {
enable = mkEnableOption "Sunshine server for Moonlight";
package = mkOption {
type = types.package;
default = pkgs.sunshine;
defaultText = literalExpression "pkgs.sunshine";
};
systemdTarget = mkOption {
type = types.str;
default = "graphical-session.target";
description = ''
Systemd target to bind to.
'';
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.sunshine" pkgs lib.platforms.linux)
];
systemd.user.services.sunshine = {
Unit.Description = ''
Sunshine self-hosted game stream host for Moonlight.
'';
Service = {
Type = "simple";
ExecStart = "${cfg.package}/bin/sunshine";
};
Install = {
WantedBy = [cfg.systemdTarget];
};
};
};
}