···
+
{ config, lib, pkgs, ... }:
+
cfg = config.services.botamusique;
+
format = pkgs.formats.ini {};
+
configFile = format.generate "botamusique.ini" cfg.settings;
+
meta.maintainers = with lib.maintainers; [ hexa ];
+
options.services.botamusique = {
+
enable = mkEnableOption "botamusique, a bot to play audio streams on mumble";
+
default = pkgs.botamusique;
+
description = "The botamusique package to use.";
+
type = with types; submodule {
+
freeformType = format.type;
+
server.host = mkOption {
+
example = "mumble.example.com";
+
description = "Hostname of the mumble server to connect to.";
+
server.port = mkOption {
+
description = "Port of the mumble server to connect to.";
+
bot.username = mkOption {
+
default = "botamusique";
+
description = "Name the bot should appear with.";
+
bot.comment = mkOption {
+
default = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!";
+
description = "Comment displayed for the bot.";
+
Your <filename>configuration.ini</filename> as a Nix attribute set. Look up
+
possible options in the <link xlink:href="https://github.com/azlux/botamusique/blob/master/configuration.example.ini">configuration.example.ini</link>.
+
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";
+
ExecStart = "${cfg.package}/bin/botamusique --config ${configFile}";
+
Restart = "always"; # the bot exits when the server connection is lost
+
CapabilityBoundingSet = [ "" ];
+
LockPersonality = true;
+
MemoryDenyWriteExecute = true;
+
ProtectControlGroups = true;
+
ProtectHostname = true;
+
ProtectKernelLogs = true;
+
ProtectKernelModules = true;
+
ProtectKernelTunables = true;
+
ProtectProc = "invisible";
+
ProtectSystem = "strict";
+
RestrictNamespaces = true;
+
RestrictRealtime = true;
+
RestrictAddressFamilies = [
+
StateDirectory = "botamusique";
+
SystemCallArchitectures = "native";
+
WorkingDirectory = "/var/lib/botamusique";