1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.musikcubed;
9in
10{
11 options = {
12 services.musikcubed = {
13 enable = lib.mkEnableOption "whether to enable musikcubed";
14 package = lib.mkOption {
15 type = lib.types.package;
16 default = pkgs.musikcube;
17 };
18 settings = lib.mkOption {
19 type = (pkgs.formats.json { }).type;
20 default = builtins.fromJSON (builtins.readFile ./default-config.json);
21 };
22 };
23 };
24 config = lib.mkIf cfg.enable {
25 systemd.user.services.musikcubed = {
26 Install = {
27 WantedBy = [ "default.target" ];
28 };
29 Unit = {
30 Description = "musikcubed";
31 After = "network.target";
32 };
33 Service = {
34 ExecStart = "${cfg.package}/bin/musikcubed --foreground";
35 Restart = "on-failure";
36 RestartSec = 5;
37 };
38 };
39 xdg.configFile."musikcube/plugin_musikcubeserver(wss,http).json".text =
40 builtins.toJSON cfg.settings;
41 };
42}