git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #10107 from ryantm/calibre-server

calibre-server service: init

commit581ae33e969b0ac95dd9cc81e442c0642a03764f authorDomen Kožar <domen@dev.si> dateSun 1 Nov 2015, 09:19 (11 years ago) parent42fffee922bf39
3 files changed+66
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/misc/calibre-server.nix+63
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
@@ -189,6 +189,7 @@
189189 ./services/misc/apache-kafka.nix
190190 #./services/misc/autofs.nix
191191 ./services/misc/canto-daemon.nix
192+ ./services/misc/calibre-server.nix
192193 ./services/misc/cpuminer-cryptonight.nix
193194 ./services/misc/cgminer.nix
194195 ./services/misc/confd.nix
nixos/modules/services/misc/calibre-server.nixnew file+63
@@ -0,0 +1,63 @@
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+ description = ''
23+ The directory where the Calibre library to serve is.
24+ '';
25+ type = types.path;
26+ };
27+
28+ };
29+
30+ };
31+
32+
33+ ###### implementation
34+
35+ config = mkIf cfg.enable {
36+
37+ systemd.services.calibre-server =
38+ {
39+ description = "Calibre Server";
40+ after = [ "network.target" ];
41+ wantedBy = [ "multi-user.target" ];
42+ serviceConfig = {
43+ User = "calibre-server";
44+ Restart = "always";
45+ ExecStart = "${pkgs.calibre}/bin/calibre-server --with-library=${cfg.libraryDir}";
46+ };
47+
48+ };
49+
50+ environment.systemPackages = [ pkgs.calibre ];
51+
52+ users.extraUsers.calibre-server = {
53+ uid = config.ids.uids.calibre-server;
54+ group = "calibre-server";
55+ };
56+
57+ users.extraGroups.calibre-server = {
58+ gid = config.ids.gids.calibre-server;
59+ };
60+
61+ };
62+
63+}