2015-09-28 04:31:17 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.calibre-server;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.calibre-server = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "calibre-server";
|
|
|
|
|
|
|
|
libraryDir = mkOption {
|
|
|
|
description = ''
|
|
|
|
The directory where the Calibre library to serve is.
|
|
|
|
'';
|
2015-10-31 21:21:56 +00:00
|
|
|
type = types.path;
|
2015-09-28 04:31:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.services.calibre-server =
|
|
|
|
{
|
2015-10-03 13:48:46 +01:00
|
|
|
description = "Calibre Server";
|
2015-09-28 04:31:17 +01:00
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2015-10-03 13:48:46 +01:00
|
|
|
User = "calibre-server";
|
2015-09-28 04:31:17 +01:00
|
|
|
Restart = "always";
|
2017-08-31 05:14:45 +01:00
|
|
|
ExecStart = "${pkgs.calibre}/bin/calibre-server ${cfg.libraryDir}";
|
2015-09-28 04:31:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.calibre ];
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users.calibre-server = {
|
2015-09-28 04:31:17 +01:00
|
|
|
uid = config.ids.uids.calibre-server;
|
2015-10-03 13:48:46 +01:00
|
|
|
group = "calibre-server";
|
|
|
|
};
|
2015-09-28 04:31:17 +01:00
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.calibre-server = {
|
2015-09-28 04:31:17 +01:00
|
|
|
gid = config.ids.gids.calibre-server;
|
2015-10-03 13:48:46 +01:00
|
|
|
};
|
2015-09-28 04:31:17 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|