diff options
author | Ryan Mulligan <ryan@ryantm.com> | 2015-09-27 20:31:17 -0700 |
---|---|---|
committer | Ryan Mulligan <ryan@ryantm.com> | 2015-09-27 20:31:17 -0700 |
commit | 9c22cd380cce15f624d4e1b2d953c49304a46a1d (patch) | |
tree | be5b4536b5c92a2d2e01b702ca9dab911f10f201 /nixos/modules/services/misc/calibre-server.nix | |
parent | 9597ff6c8c990de50fd700cfa95e7c09d6efc44c (diff) | |
download | nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.tar nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.tar.gz nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.tar.bz2 nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.tar.lz nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.tar.xz nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.tar.zst nixpkgs-9c22cd380cce15f624d4e1b2d953c49304a46a1d.zip |
calibre-server service: init
Diffstat (limited to 'nixos/modules/services/misc/calibre-server.nix')
-rw-r--r-- | nixos/modules/services/misc/calibre-server.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/calibre-server.nix b/nixos/modules/services/misc/calibre-server.nix new file mode 100644 index 00000000000..a59e68edd84 --- /dev/null +++ b/nixos/modules/services/misc/calibre-server.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.calibre-server; + +in + +{ + + ###### interface + + options = { + + services.calibre-server = { + + enable = mkEnableOption "calibre-server"; + + libraryDir = mkOption { + default = "/tmp/calibre-server"; + description = '' + The directory where the Calibre library to serve is. + ''; + }; + + user = mkOption { + type = types.str; + default = "calibre-server"; + description = "User account under which calibre-server runs."; + }; + + group = mkOption { + type = types.str; + default = "calibre-server"; + description = "Group account under which calibre-server runs."; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + systemd.services.calibre-server = + { + description = "calibre-server, an OPDS server for a Calibre library"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "${cfg.user}"; + Restart = "always"; + ExecStart = "${pkgs.calibre}/bin/calibre-server --with-library=${cfg.libraryDir}"; + }; + + }; + + environment.systemPackages = [ pkgs.calibre ]; + + users.extraUsers = optionalAttrs (cfg.user == "calibre-server") (singleton + { name = "calibre-server"; + group = cfg.group; + uid = config.ids.uids.calibre-server; + }); + + users.extraGroups = optionalAttrs (cfg.group == "calibre-server") (singleton + { name = "calibre-server"; + gid = config.ids.gids.calibre-server; + }); + + }; + +} |