1 { config, lib, options, pkgs, ... }:
9 cfg = config.services.headphones;
10 opt = options.services.headphones;
19 services.headphones = {
23 description = lib.mdDoc "Whether to enable the headphones server.";
27 default = "/var/lib/${name}";
28 description = lib.mdDoc "Path where to store data files.";
30 configFile = mkOption {
32 default = "${cfg.dataDir}/config.ini";
33 defaultText = literalExpression ''"''${config.${opt.dataDir}}/config.ini"'';
34 description = lib.mdDoc "Path to config file.";
38 default = "localhost";
39 description = lib.mdDoc "Host to listen on.";
42 type = types.ints.u16;
44 description = lib.mdDoc "Port to bind to.";
49 description = lib.mdDoc "User to run the service as";
54 description = lib.mdDoc "Group to run the service as";
62 config = mkIf cfg.enable {
64 users.users = optionalAttrs (cfg.user == name) {
66 uid = config.ids.uids.headphones;
68 description = "headphones user";
74 users.groups = optionalAttrs (cfg.group == name) {
75 ${name}.gid = config.ids.gids.headphones;
78 systemd.services.headphones = {
79 description = "Headphones Server";
80 wantedBy = [ "multi-user.target" ];
81 after = [ "network.target" ];
85 ExecStart = "${pkgs.headphones}/bin/headphones --datadir ${cfg.dataDir} --config ${cfg.configFile} --host ${cfg.host} --port ${toString cfg.port}";