calibre-server service: init

wip/yesman
Ryan Mulligan 9 years ago
parent 9597ff6c8c
commit 9c22cd380c
  1. 2
      nixos/modules/misc/ids.nix
  2. 1
      nixos/modules/module-list.nix
  3. 77
      nixos/modules/services/misc/calibre-server.nix

@ -234,6 +234,7 @@
#lxd = 210; # unused
kibana = 211;
xtreemfs = 212;
calibre-server = 213;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -446,6 +447,7 @@
lxd = 210; # unused
#kibana = 211;
xtreemfs = 212;
calibre-server = 213;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal

@ -187,6 +187,7 @@
./services/misc/apache-kafka.nix
#./services/misc/autofs.nix
./services/misc/canto-daemon.nix
./services/misc/calibre-server.nix
./services/misc/cpuminer-cryptonight.nix
./services/misc/cgminer.nix
./services/misc/confd.nix

@ -0,0 +1,77 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.calibre-server;
in
{
###### interface
options = {
services.calibre-server = {
enable = mkEnableOption "calibre-server";
libraryDir = mkOption {
default = "/tmp/calibre-server";
description = ''
The directory where the Calibre library to serve is.
'';
};
user = mkOption {
type = types.str;
default = "calibre-server";
description = "User account under which calibre-server runs.";
};
group = mkOption {
type = types.str;
default = "calibre-server";
description = "Group account under which calibre-server runs.";
};
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services.calibre-server =
{
description = "calibre-server, an OPDS server for a Calibre library";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "${cfg.user}";
Restart = "always";
ExecStart = "${pkgs.calibre}/bin/calibre-server --with-library=${cfg.libraryDir}";
};
};
environment.systemPackages = [ pkgs.calibre ];
users.extraUsers = optionalAttrs (cfg.user == "calibre-server") (singleton
{ name = "calibre-server";
group = cfg.group;
uid = config.ids.uids.calibre-server;
});
users.extraGroups = optionalAttrs (cfg.group == "calibre-server") (singleton
{ name = "calibre-server";
gid = config.ids.gids.calibre-server;
});
};
}
Loading…
Cancel
Save