1 { config, lib, pkgs, ... }:
6 cfg = config.services.botamusique;
8 format = pkgs.formats.ini {};
9 configFile = format.generate "botamusique.ini" cfg.settings;
12 meta.maintainers = with lib.maintainers; [ hexa ];
14 options.services.botamusique = {
15 enable = mkEnableOption (lib.mdDoc "botamusique, a bot to play audio streams on mumble");
19 default = pkgs.botamusique;
20 defaultText = literalExpression "pkgs.botamusique";
21 description = lib.mdDoc "The botamusique package to use.";
25 type = with types; submodule {
26 freeformType = format.type;
28 server.host = mkOption {
30 default = "localhost";
31 example = "mumble.example.com";
32 description = lib.mdDoc "Hostname of the mumble server to connect to.";
35 server.port = mkOption {
38 description = lib.mdDoc "Port of the mumble server to connect to.";
41 bot.username = mkOption {
43 default = "botamusique";
44 description = lib.mdDoc "Name the bot should appear with.";
47 bot.comment = mkOption {
49 default = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!";
50 description = lib.mdDoc "Comment displayed for the bot.";
55 description = lib.mdDoc ''
56 Your {file}`configuration.ini` as a Nix attribute set. Look up
57 possible options in the [configuration.example.ini](https://github.com/azlux/botamusique/blob/master/configuration.example.ini).
62 config = mkIf cfg.enable {
63 systemd.services.botamusique = {
64 after = [ "network.target" ];
65 wantedBy = [ "multi-user.target" ];
67 unitConfig.Documentation = "https://github.com/azlux/botamusique/wiki";
69 environment.HOME = "/var/lib/botamusique";
72 ExecStart = "${cfg.package}/bin/botamusique --config ${configFile}";
73 Restart = "always"; # the bot exits when the server connection is lost
76 CapabilityBoundingSet = [ "" ];
82 LockPersonality = true;
83 MemoryDenyWriteExecute = true;
85 PrivateDevices = true;
89 ProtectControlGroups = true;
91 ProtectHostname = true;
92 ProtectKernelLogs = true;
93 ProtectKernelModules = true;
94 ProtectKernelTunables = true;
95 ProtectProc = "invisible";
96 ProtectSystem = "strict";
97 RestrictNamespaces = true;
98 RestrictRealtime = true;
99 RestrictAddressFamilies = [
103 StateDirectory = "botamusique";
104 SystemCallArchitectures = "native";
111 WorkingDirectory = "/var/lib/botamusique";