1 { config, lib, pkgs, ... }:
7 cfg = config.services.calibre-server;
13 (mkChangedOptionModule [ "services" "calibre-server" "libraryDir" ] [ "services" "calibre-server" "libraries" ]
15 let libraryDir = getAttrFromPath [ "services" "calibre-server" "libraryDir" ] config;
24 services.calibre-server = {
26 enable = mkEnableOption (lib.mdDoc "calibre-server");
28 libraries = mkOption {
29 description = lib.mdDoc ''
30 The directories of the libraries to serve. They must be readable for the user under which the server runs.
32 type = types.listOf types.path;
36 description = lib.mdDoc "The user under which calibre-server runs.";
38 default = "calibre-server";
42 description = lib.mdDoc "The group under which calibre-server runs.";
44 default = "calibre-server";
53 config = mkIf cfg.enable {
55 systemd.services.calibre-server = {
56 description = "Calibre Server";
57 after = [ "network.target" ];
58 wantedBy = [ "multi-user.target" ];
62 ExecStart = "${pkgs.calibre}/bin/calibre-server ${lib.concatStringsSep " " cfg.libraries}";
67 environment.systemPackages = [ pkgs.calibre ];
69 users.users = optionalAttrs (cfg.user == "calibre-server") {
71 home = "/var/lib/calibre-server";
73 uid = config.ids.uids.calibre-server;
78 users.groups = optionalAttrs (cfg.group == "calibre-server") {
80 gid = config.ids.gids.calibre-server;