Unverified Commit 1edcdf34 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge staging-next into staging

parents 3d40c1b0 95930c37
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -14679,12 +14679,6 @@
    githubId = 6391601;
    name = "Roger Mason";
  };
  spwhitt = {
    email = "sw@swhitt.me";
    github = "spwhitt";
    githubId = 1414088;
    name = "Spencer Whitt";
  };
  squalus = {
    email = "squalus@squalus.net";
    github = "squalus";
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ In addition to numerous new and upgraded packages, this release has the followin

- [opensearch](https://opensearch.org), a search server alternative to Elasticsearch. Available as [services.opensearch](options.html#opt-services.opensearch.enable).

- [kavita](https://kavitareader.com), a self-hosted digital library. Available as [services.kavita](options.html#opt-services.kavita.enable).

- [monica](https://www.monicahq.com), an open source personal CRM. Available as [services.monica](options.html#opt-services.monica.enable).

- [authelia](https://www.authelia.com/), is an open-source authentication and authorization server. Available under [services.authelia](options.html#opt-services.authelia.enable).
+2 −2
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ in
    system.nixos-generate-config.configuration = mkDefault ''
      # Edit this configuration file to define what should be installed on
      # your system.  Help is available in the configuration.nix(5) man page
      # and in the NixOS manual (accessible by running nixos-help).
      # and in the NixOS manual (accessible by running `nixos-help`).

      { config, pkgs, ... }:

@@ -218,7 +218,7 @@ in

        # This value determines the NixOS release from which the default
        # settings for stateful data, like file locations and database versions
        # on your system were taken. Its perfectly fine and recommended to leave
        # on your system were taken. It's perfectly fine and recommended to leave
        # this value at the release version of the first install of this system.
        # Before changing this value read the documentation for this option
        # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
+1 −0
Original line number Diff line number Diff line
@@ -1184,6 +1184,7 @@
  ./services/web-apps/jirafeau.nix
  ./services/web-apps/jitsi-meet.nix
  ./services/web-apps/kasmweb/default.nix
  ./services/web-apps/kavita.nix
  ./services/web-apps/keycloak.nix
  ./services/web-apps/komga.nix
  ./services/web-apps/lemmy.nix
+83 −0
Original line number Diff line number Diff line
{ config, lib, pkgs, ... }:

let
  cfg = config.services.kavita;
in {
  options.services.kavita = {
    enable = lib.mkEnableOption (lib.mdDoc "Kavita reading server");

    user = lib.mkOption {
      type = lib.types.str;
      default = "kavita";
      description = lib.mdDoc "User account under which Kavita runs.";
    };

    package = lib.mkPackageOptionMD pkgs "kavita" { };

    dataDir = lib.mkOption {
      default = "/var/lib/kavita";
      type = lib.types.str;
      description = lib.mdDoc "The directory where Kavita stores its state.";
    };

    tokenKeyFile = lib.mkOption {
      type = lib.types.path;
      description = lib.mdDoc ''
        A file containing the TokenKey, a secret with at 128+ bits.
        It can be generated with `head -c 32 /dev/urandom | base64`.
      '';
    };
    port = lib.mkOption {
      default = 5000;
      type = lib.types.port;
      description = lib.mdDoc "Port to bind to.";
    };
    ipAdresses = lib.mkOption {
      default = ["0.0.0.0" "::"];
      type = lib.types.listOf lib.types.str;
      description = lib.mdDoc "IP Adresses to bind to. The default is to bind
      to all IPv4 and IPv6 addresses.";
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.kavita = {
      description = "Kavita";
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];
      preStart = ''
        umask u=rwx,g=rx,o=
        cat > "${cfg.dataDir}/config/appsettings.json" <<EOF
        {
          "TokenKey": "$(cat ${cfg.tokenKeyFile})",
          "Port": ${toString cfg.port},
          "IpAddresses": "${lib.concatStringsSep "," cfg.ipAdresses}"
        }
        EOF
      '';
      serviceConfig = {
        WorkingDirectory = cfg.dataDir;
        ExecStart = "${lib.getExe cfg.package}";
        Restart = "always";
        User = cfg.user;
      };
    };

    systemd.tmpfiles.rules = [
      "d '${cfg.dataDir}'        0750 ${cfg.user} ${cfg.user} - -"
      "d '${cfg.dataDir}/config' 0750 ${cfg.user} ${cfg.user} - -"
    ];

    users = {
      users.${cfg.user} = {
        description = "kavita service user";
        isSystemUser = true;
        group = cfg.user;
        home = cfg.dataDir;
      };
      groups.${cfg.user} = { };
    };
  };

  meta.maintainers = with lib.maintainers; [ misterio77 ];
}
Loading