···7879- `services.prometheus.exporters` has a new exporter to monitor electrical power consumption based on PowercapRAPL sensor called [Scaphandre](https://github.com/hubblo-org/scaphandre), see [#239803](https://github.com/NixOS/nixpkgs/pull/239803) for more details.
800081## Nixpkgs internals {#sec-release-23.11-nixpkgs-internals}
8283- The `qemu-vm.nix` module by default now identifies block devices via
···7879- `services.prometheus.exporters` has a new exporter to monitor electrical power consumption based on PowercapRAPL sensor called [Scaphandre](https://github.com/hubblo-org/scaphandre), see [#239803](https://github.com/NixOS/nixpkgs/pull/239803) for more details.
8081+- The module `services.calibre-server` has new options to configure the `host`, `port`, `auth.enable`, `auth.mode` and `auth.userDb` path, see [#216497](https://github.com/NixOS/nixpkgs/pull/216497/) for more details.
82+83## Nixpkgs internals {#sec-release-23.11-nixpkgs-internals}
8485- The `qemu-vm.nix` module by default now identifies block devices via
+77-17
nixos/modules/services/misc/calibre-server.nix
···67 cfg = config.services.calibre-server;
8000000000009in
1011{
···18 )
19 ];
2021- ###### interface
22-23 options = {
24 services.calibre-server = {
2526 enable = mkEnableOption (lib.mdDoc "calibre-server");
02728 libraries = mkOption {
0029 description = lib.mdDoc ''
030 The directories of the libraries to serve. They must be readable for the user under which the server runs.
031 '';
32- type = types.listOf types.path;
33 };
3435 user = mkOption {
36- description = lib.mdDoc "The user under which calibre-server runs.";
37 type = types.str;
38 default = "calibre-server";
039 };
4041 group = mkOption {
42- description = lib.mdDoc "The group under which calibre-server runs.";
43 type = types.str;
44 default = "calibre-server";
045 };
4647- };
48- };
000000049000000005051- ###### implementation
00000000000000000000000000000005253 config = mkIf cfg.enable {
5455 systemd.services.calibre-server = {
56- description = "Calibre Server";
57- after = [ "network.target" ];
58- wantedBy = [ "multi-user.target" ];
59- serviceConfig = {
60- User = cfg.user;
61- Restart = "always";
62- ExecStart = "${pkgs.calibre}/bin/calibre-server ${lib.concatStringsSep " " cfg.libraries}";
63- };
6465- };
6667 environment.systemPackages = [ pkgs.calibre ];
68···8384 };
85086}
···67 cfg = config.services.calibre-server;
89+ documentationLink = "https://manual.calibre-ebook.com";
10+ generatedDocumentationLink = documentationLink + "/generated/en/calibre-server.html";
11+12+ execFlags = (concatStringsSep " "
13+ (mapAttrsToList (k: v: "${k} ${toString v}") (filterAttrs (name: value: value != null) {
14+ "--listen-on" = cfg.host;
15+ "--port" = cfg.port;
16+ "--auth-mode" = cfg.auth.mode;
17+ "--userdb" = cfg.auth.userDb;
18+ }) ++ [(optionalString (cfg.auth.enable == true) "--enable-auth")])
19+ );
20in
2122{
···29 )
30 ];
310032 options = {
33 services.calibre-server = {
3435 enable = mkEnableOption (lib.mdDoc "calibre-server");
36+ package = lib.mkPackageOptionMD pkgs "calibre" { };
3738 libraries = mkOption {
39+ type = types.listOf types.path;
40+ default = [ "/var/lib/calibre-server" ];
41 description = lib.mdDoc ''
42+ Make sure each library path is initialized before service startup.
43 The directories of the libraries to serve. They must be readable for the user under which the server runs.
44+ See the [calibredb documentation](${documentationLink}/generated/en/calibredb.html#add) for details.
45 '';
046 };
4748 user = mkOption {
049 type = types.str;
50 default = "calibre-server";
51+ description = lib.mdDoc "The user under which calibre-server runs.";
52 };
5354 group = mkOption {
055 type = types.str;
56 default = "calibre-server";
57+ description = lib.mdDoc "The group under which calibre-server runs.";
58 };
5960+ host = mkOption {
61+ type = types.str;
62+ default = "0.0.0.0";
63+ example = "::1";
64+ description = lib.mdDoc ''
65+ The interface on which to listen for connections.
66+ See the [calibre-server documentation](${generatedDocumentationLink}#cmdoption-calibre-server-listen-on) for details.
67+ '';
68+ };
6970+ port = mkOption {
71+ default = 8080;
72+ type = types.port;
73+ description = lib.mdDoc ''
74+ The port on which to listen for connections.
75+ See the [calibre-server documentation](${generatedDocumentationLink}#cmdoption-calibre-server-port) for details.
76+ '';
77+ };
7879+ auth = {
80+ enable = mkOption {
81+ type = types.bool;
82+ default = false;
83+ description = lib.mdDoc ''
84+ Password based authentication to access the server.
85+ See the [calibre-server documentation](${generatedDocumentationLink}#cmdoption-calibre-server-enable-auth) for details.
86+ '';
87+ };
88+89+ mode = mkOption {
90+ type = types.enum [ "auto" "basic" "digest" ];
91+ default = "auto";
92+ description = lib.mdDoc ''
93+ Choose the type of authentication used.
94+ Set the HTTP authentication mode used by the server.
95+ See the [calibre-server documentation](${generatedDocumentationLink}#cmdoption-calibre-server-auth-mode) for details.
96+ '';
97+ };
98+99+ userDb = mkOption {
100+ default = null;
101+ type = types.nullOr types.path;
102+ description = lib.mdDoc ''
103+ Choose users database file to use for authentication.
104+ Make sure users database file is initialized before service startup.
105+ See the [calibre-server documentation](${documentationLink}/server.html#managing-user-accounts-from-the-command-line-only) for details.
106+ '';
107+ };
108+ };
109+ };
110+ };
111112 config = mkIf cfg.enable {
113114 systemd.services.calibre-server = {
115+ description = "Calibre Server";
116+ after = [ "network.target" ];
117+ wantedBy = [ "multi-user.target" ];
118+ serviceConfig = {
119+ User = cfg.user;
120+ Restart = "always";
121+ ExecStart = "${cfg.package}/bin/calibre-server ${lib.concatStringsSep " " cfg.libraries} ${execFlags}";
122+ };
123124+ };
125126 environment.systemPackages = [ pkgs.calibre ];
127···142143 };
144145+ meta.maintainers = with lib.maintainers; [ gaelreyrol ];
146}