git.iko.soy/typeable/nixpkgs
on master help sign in
calibre-server service: init
commit9c22cd380cce15f624d4e1b2d953c49304a46a1d authorRyan Mulligan <ryan@ryantm.com> dateSun 27 Sep 2015, 20:31 (11 years ago) parent9597ff6
3 files changed+80
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/misc/calibre-server.nix+77
nixos/modules/misc/ids.nix+2
@@ -234,6 +234,7 @@
234234 #lxd = 210; # unused
235235 kibana = 211;
236236 xtreemfs = 212;
237+ calibre-server = 213;
237238
238239 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
239240
@@ -446,6 +447,7 @@
446447 lxd = 210; # unused
447448 #kibana = 211;
448449 xtreemfs = 212;
450+ calibre-server = 213;
449451
450452 # When adding a gid, make sure it doesn't match an existing
451453 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -187,6 +187,7 @@
187187 ./services/misc/apache-kafka.nix
188188 #./services/misc/autofs.nix
189189 ./services/misc/canto-daemon.nix
190+ ./services/misc/calibre-server.nix
190191 ./services/misc/cpuminer-cryptonight.nix
191192 ./services/misc/cgminer.nix
192193 ./services/misc/confd.nix
nixos/modules/services/misc/calibre-server.nixnew file+77
@@ -0,0 +1,77 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+
7+ cfg = config.services.calibre-server;
8+
9+in
10+
11+{
12+
13+ ###### interface
14+
15+ options = {
16+
17+ services.calibre-server = {
18+
19+ enable = mkEnableOption "calibre-server";
20+
21+ libraryDir = mkOption {
22+ default = "/tmp/calibre-server";
23+ description = ''
24+ The directory where the Calibre library to serve is.
25+ '';
26+ };
27+
28+ user = mkOption {
29+ type = types.str;
30+ default = "calibre-server";
31+ description = "User account under which calibre-server runs.";
32+ };
33+
34+ group = mkOption {
35+ type = types.str;
36+ default = "calibre-server";
37+ description = "Group account under which calibre-server runs.";
38+ };
39+
40+ };
41+
42+ };
43+
44+
45+ ###### implementation
46+
47+ config = mkIf cfg.enable {
48+
49+ systemd.services.calibre-server =
50+ {
51+ description = "calibre-server, an OPDS server for a Calibre library";
52+ after = [ "network.target" ];
53+ wantedBy = [ "multi-user.target" ];
54+ serviceConfig = {
55+ User = "${cfg.user}";
56+ Restart = "always";
57+ ExecStart = "${pkgs.calibre}/bin/calibre-server --with-library=${cfg.libraryDir}";
58+ };
59+
60+ };
61+
62+ environment.systemPackages = [ pkgs.calibre ];
63+
64+ users.extraUsers = optionalAttrs (cfg.user == "calibre-server") (singleton
65+ { name = "calibre-server";
66+ group = cfg.group;
67+ uid = config.ids.uids.calibre-server;
68+ });
69+
70+ users.extraGroups = optionalAttrs (cfg.group == "calibre-server") (singleton
71+ { name = "calibre-server";
72+ gid = config.ids.gids.calibre-server;
73+ });
74+
75+ };
76+
77+}