Created
November 4, 2022 16:02
-
-
Save adamcstephens/c7a8d9ebb24ad3e9134c91c61a36bd5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
config, | |
lib, | |
pkgs, | |
self', | |
... | |
}: | |
with lib; let | |
cfg = config.services.minidsp; | |
in { | |
options = { | |
services.minidsp = { | |
enable = mkOption { | |
type = types.bool; | |
default = false; | |
description = '' | |
Whether to enable minidsp. | |
''; | |
}; | |
package = mkOption { | |
type = types.package; | |
default = self'.packages.minidsp; | |
defaultText = literalExpression "pkgs.minidsp"; | |
description = "minidsp package to use."; | |
}; | |
dataDir = mkOption { | |
type = types.path; | |
default = "/var/lib/minidsp"; | |
description = '' | |
The directory where minidsp stores its state, tag cache, | |
playlists etc. | |
''; | |
}; | |
}; | |
}; | |
config = mkIf cfg.enable { | |
systemd.tmpfiles.rules = [ | |
"d '${cfg.dataDir}' - minidsp minidsp - -" | |
]; | |
environment.systemPackages = [ | |
cfg.package | |
]; | |
systemd.services.minidspd = { | |
after = ["network.target"]; | |
description = "minidsp daemon"; | |
wantedBy = ["multi-user.target"]; | |
serviceConfig = { | |
User = "minidsp"; | |
ExecStart = "${cfg.package}/bin/minidspd --config /etc/minidspd.toml"; | |
}; | |
}; | |
users = { | |
users.minidsp = { | |
description = "minidsp daemon user"; | |
home = cfg.dataDir; | |
group = "minidsp"; | |
isSystemUser = true; | |
}; | |
groups.minidsp = {}; | |
}; | |
environment.etc."minidspd.toml" = { | |
text = '' | |
[http_server] | |
bind_address = "127.0.0.1:5380" | |
''; | |
}; | |
services.udev.extraRules = '' | |
ATTR{idVendor}=="2752", MODE="660", GROUP="minidsp" | |
ATTR{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="660", GROUP="minidsp" | |
''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment