summary refs log tree commit diff
path: root/nixos/modules/services/misc/calibre-server.nix
blob: 84c04f403d3a3e485107d06232a6c45e679b5722 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ 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.
          '';
          type = types.path;
      };

    };

  };


  ###### implementation

  config = mkIf cfg.enable {

    systemd.services.calibre-server =
      {
        description = "Calibre Server";
        after = [ "network.target" ];
        wantedBy = [ "multi-user.target" ];
        serviceConfig = {
          User = "calibre-server";
          Restart = "always";
          ExecStart = "${pkgs.calibre}/bin/calibre-server ${cfg.libraryDir}";
        };

      };

    environment.systemPackages = [ pkgs.calibre ];

    users.users.calibre-server = {
        uid = config.ids.uids.calibre-server;
        group = "calibre-server";
      };

    users.groups.calibre-server = {
        gid = config.ids.gids.calibre-server;
      };

  };

}