Add slimserver nixos module

This commit is contained in:
Philipp Hausmann 2017-03-16 20:42:49 +01:00
parent ad88df249c
commit 45d8d6ebeb
3 changed files with 98 additions and 0 deletions

View File

@ -288,6 +288,7 @@
kresd = 270;
rpc = 271;
geoip = 272;
slimserver = 273;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -545,6 +546,7 @@
kresd = 270;
#rpc = 271; # unused
#geoip = 272; # unused
slimserver = 273;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal

View File

@ -128,6 +128,7 @@
./services/audio/liquidsoap.nix
./services/audio/mpd.nix
./services/audio/mopidy.nix
./services/audio/slimserver.nix
./services/audio/squeezelite.nix
./services/audio/ympd.nix
./services/backup/almir.nix

View File

@ -0,0 +1,95 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.slimserver;
in {
options = {
services.slimserver = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable slimserver.
'';
};
package = mkOption {
type = types.package;
default = pkgs.slimserver;
defaultText = "pkgs.slimserver";
description = "Slimserver package to use.";
};
dataDir = mkOption {
type = types.path;
default = "/var/lib/slimserver";
description = ''
The directory where slimserver stores its state, tag cache,
playlists etc.
'';
};
network = {
listenAddress = mkOption {
type = types.str;
default = "127.0.0.1";
example = "any";
description = ''
The address for the daemon to listen on.
Use <literal>any</literal> to listen on all addresses.
'';
};
port = mkOption {
type = types.int;
default = 6600;
description = ''
This setting is the TCP port that is desired for the daemon to get assigned
to.
'';
};
};
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services.slimserver = {
after = [ "network.target" ];
description = "Slim Server for Logitech Squeezebox Players";
wantedBy = [ "multi-user.target" ];
preStart = "mkdir -p ${cfg.dataDir} && chown -R slimserver:slimserver ${cfg.dataDir}";
serviceConfig = {
User = "slimserver";
PermissionsStartOnly = true;
ExecStart = "${cfg.package}/slimserver.pl --logdir ${cfg.dataDir}/logs --prefsdir ${cfg.dataDir}/prefs --cachedir ${cfg.dataDir}/cache";
};
};
users = {
groups.slimserver.gid = config.ids.gids.slimserver;
users.slimserver = {
uid = config.ids.uids.slimserver;
description = "Slimserver daemon user";
home = cfg.dataDir;
group = "slimserver";
};
};
};
}