Unverified Commit 0be7395f authored by Julien Malka's avatar Julien Malka
Browse files

nixos/readeck: init

parent 452d86c8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@

- [Conduwuit](https://conduwuit.puppyirl.gay/), a federated chat server implementing the Matrix protocol, forked from Conduit. Available as [services.conduwuit](#opt-services.conduwuit.enable).

- [Readeck](https://readeck.org/), a read-it later web-application. Available as [services.readeck](#opt-services.readeck.enable).

- [Traccar](https://www.traccar.org/), a modern GPS Tracking Platform. Available as [services.traccar](#opt-services.traccar.enable).

- [Schroot](https://codeberg.org/shelter/reschroot), a lightweight virtualisation tool. Securely enter a chroot and run a command or login shell. Available as [programs.schroot](#opt-programs.schroot.enable).
+1 −0
Original line number Diff line number Diff line
@@ -1549,6 +1549,7 @@
  ./services/web-apps/screego.nix
  ./services/web-apps/sftpgo.nix
  ./services/web-apps/suwayomi-server.nix
  ./services/web-apps/readeck.nix
  ./services/web-apps/rss-bridge.nix
  ./services/web-apps/selfoss.nix
  ./services/web-apps/shiori.nix
+96 −0
Original line number Diff line number Diff line
{
  config,
  pkgs,
  lib,
  ...
}:

let
  inherit (lib)
    mkEnableOption
    mkPackageOption
    mkOption
    mkIf
    types
    ;
  cfg = config.services.readeck;
  settingsFormat = pkgs.formats.toml { };
  configFile = settingsFormat.generate "readeck.toml" cfg.settings;

in
{

  meta.maintainers = [ lib.maintainers.julienmalka ];

  options = {
    services.readeck = {
      enable = mkEnableOption "Readeck";

      package = mkPackageOption pkgs "readeck" { };

      environmentFile = mkOption {
        type = types.nullOr types.path;
        description = ''
          File containing environment variables to be passed to Readeck.
          May be used to provide the Readeck secret key by setting the READECK_SECRET_KEY variable.
        '';
        default = null;
      };

      settings = mkOption {
        type = settingsFormat.type;
        default = { };
        example = {
          main.log_level = "debug";
          server.port = 9000;
        };
        description = ''
          Additional configuration for Readeck, see
          <https://readeck.org/en/docs/configuration>
          for supported values.
        '';
      };

    };
  };

  config = mkIf cfg.enable {
    systemd.services.readeck = {
      description = "Readeck";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "simple";
        StateDirectory = "readeck";
        WorkingDirectory = "/var/lib/readeck";
        EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
        DynamicUser = true;
        ExecStart = "${lib.getExe cfg.package} serve -config ${configFile}";
        ProtectSystem = "full";
        SystemCallArchitectures = "native";
        MemoryDenyWriteExecute = true;
        NoNewPrivileges = true;
        PrivateTmp = true;
        PrivateDevices = true;
        RestrictAddressFamilies = [
          "AF_INET"
          "AF_INET6"
          "AF_UNIX"
          "AF_NETLINK"
        ];
        RestrictNamespaces = true;
        RestrictRealtime = true;
        DevicePolicy = "closed";
        ProtectClock = true;
        ProtectHostname = true;
        ProtectProc = "invisible";
        ProtectControlGroups = true;
        ProtectKernelModules = true;
        ProtectKernelTunables = true;
        LockPersonality = true;
        Restart = "on-failure";

      };
    };
  };
}
+1 −0
Original line number Diff line number Diff line
@@ -889,6 +889,7 @@ in {
  rathole = handleTest ./rathole.nix {};
  readarr = handleTest ./readarr.nix {};
  realm = handleTest ./realm.nix {};
  readeck = runTest ./readeck.nix;
  redis = handleTest ./redis.nix {};
  redlib = handleTest ./redlib.nix {};
  redmine = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./redmine.nix {};
+24 −0
Original line number Diff line number Diff line
{ lib, ... }:

{
  name = "readeck";
  meta.maintainers = with lib.maintainers; [ julienmalka ];

  nodes.machine =
    { pkgs, ... }:
    {
      services.readeck = {
        enable = true;
        environmentFile = pkgs.writeText "env-file" ''
          READECK_SECRET_KEY="verysecretkey"
        '';
      };
    };

  testScript = ''
    machine.start()
    machine.wait_for_unit("readeck.service")
    machine.wait_for_open_port(8000)
    machine.succeed("curl --fail http://localhost:8000/login?r=%2F")
  '';
}
+1 −1

File changed.

Contains only whitespace changes.

Loading