1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-24 18:16:21 +03:00
nixpkgs/nixos/modules/services/audio/music-assistant.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

119 lines
2.5 KiB
Nix

{
config,
lib,
pkgs,
utils,
...
}:
let
inherit (lib)
mkIf
mkEnableOption
mkOption
mkPackageOption
types
;
inherit (types)
listOf
enum
str
;
cfg = config.services.music-assistant;
finalPackage = cfg.package.override {
inherit (cfg) providers;
};
in
{
meta.buildDocsInSandbox = false;
options.services.music-assistant = {
enable = mkEnableOption "Music Assistant";
package = mkPackageOption pkgs "music-assistant" { };
extraOptions = mkOption {
type = listOf str;
default = [
"--config"
"/var/lib/music-assistant"
];
example = [
"--log-level"
"DEBUG"
];
description = ''
List of extra options to pass to the music-assistant executable.
'';
};
providers = mkOption {
type = listOf (enum cfg.package.providerNames);
default = [ ];
example = [
"opensubsonic"
"snapcast"
];
description = ''
List of provider names for which dependencies will be installed.
'';
};
};
config = mkIf cfg.enable {
systemd.services.music-assistant = {
description = "Music Assistant";
documentation = [ "https://music-assistant.io" ];
wantedBy = [ "multi-user.target" ];
environment = {
HOME = "/var/lib/music-assistant";
PYTHONPATH = finalPackage.pythonPath;
};
serviceConfig = {
ExecStart = utils.escapeSystemdExecArgs (
[
(lib.getExe cfg.package)
]
++ cfg.extraOptions
);
DynamicUser = true;
StateDirectory = "music-assistant";
AmbientCapabilities = "";
CapabilityBoundingSet = [ "" ];
DevicePolicy = "closed";
LockPersonality = true;
MemoryDenyWriteExecute = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
"AF_NETLINK"
];
RestrictNamespaces = true;
RestrictRealtime = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@privileged @resources"
];
RestrictSUIDSGID = true;
UMask = "0077";
};
};
};
}