2021-05-28 09:39:13 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.botamusique;
|
|
|
|
|
|
|
|
format = pkgs.formats.ini {};
|
|
|
|
configFile = format.generate "botamusique.ini" cfg.settings;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
meta.maintainers = with lib.maintainers; [ hexa ];
|
|
|
|
|
|
|
|
options.services.botamusique = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "botamusique, a bot to play audio streams on mumble");
|
2021-05-28 09:39:13 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "botamusique" { };
|
2021-05-28 09:39:13 +00:00
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = with types; submodule {
|
|
|
|
freeformType = format.type;
|
|
|
|
options = {
|
|
|
|
server.host = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "localhost";
|
|
|
|
example = "mumble.example.com";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Hostname of the mumble server to connect to.";
|
2021-05-28 09:39:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
server.port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 64738;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Port of the mumble server to connect to.";
|
2021-05-28 09:39:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bot.username = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "botamusique";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Name the bot should appear with.";
|
2021-05-28 09:39:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bot.comment = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Comment displayed for the bot.";
|
2021-05-28 09:39:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
default = {};
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Your {file}`configuration.ini` as a Nix attribute set. Look up
|
|
|
|
possible options in the [configuration.example.ini](https://github.com/azlux/botamusique/blob/master/configuration.example.ini).
|
2021-05-28 09:39:13 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.botamusique = {
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
unitConfig.Documentation = "https://github.com/azlux/botamusique/wiki";
|
|
|
|
|
|
|
|
environment.HOME = "/var/lib/botamusique";
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${cfg.package}/bin/botamusique --config ${configFile}";
|
|
|
|
Restart = "always"; # the bot exits when the server connection is lost
|
|
|
|
|
|
|
|
# Hardening
|
|
|
|
CapabilityBoundingSet = [ "" ];
|
|
|
|
DynamicUser = true;
|
|
|
|
IPAddressDeny = [
|
|
|
|
"link-local"
|
|
|
|
"multicast"
|
|
|
|
];
|
|
|
|
LockPersonality = true;
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
ProcSubset = "pid";
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectProc = "invisible";
|
|
|
|
ProtectSystem = "strict";
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictAddressFamilies = [
|
|
|
|
"AF_INET"
|
|
|
|
"AF_INET6"
|
|
|
|
];
|
|
|
|
StateDirectory = "botamusique";
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = [
|
2022-12-17 10:02:37 +00:00
|
|
|
"@system-service @resources"
|
2021-05-28 09:39:13 +00:00
|
|
|
"~@privileged"
|
|
|
|
];
|
|
|
|
UMask = "0077";
|
|
|
|
WorkingDirectory = "/var/lib/botamusique";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|