diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 0d2700a126f6..de9a318fdd24 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -234,6 +234,7 @@ #lxd = 210; # unused kibana = 211; xtreemfs = 212; + calibre-server = 213; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -446,6 +447,7 @@ lxd = 210; # unused #kibana = 211; xtreemfs = 212; + calibre-server = 213; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 77575867f873..9fcb01beaf0f 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -189,6 +189,7 @@ ./services/misc/apache-kafka.nix #./services/misc/autofs.nix ./services/misc/canto-daemon.nix + ./services/misc/calibre-server.nix ./services/misc/cpuminer-cryptonight.nix ./services/misc/cgminer.nix ./services/misc/confd.nix diff --git a/nixos/modules/services/misc/calibre-server.nix b/nixos/modules/services/misc/calibre-server.nix new file mode 100644 index 000000000000..a920aa22ccdf --- /dev/null +++ b/nixos/modules/services/misc/calibre-server.nix @@ -0,0 +1,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 --with-library=${cfg.libraryDir}"; + }; + + }; + + environment.systemPackages = [ pkgs.calibre ]; + + users.extraUsers.calibre-server = { + uid = config.ids.uids.calibre-server; + group = "calibre-server"; + }; + + users.extraGroups.calibre-server = { + gid = config.ids.gids.calibre-server; + }; + + }; + +}