nixos/readeck: init

This commit is contained in:
Julien Malka 2025-01-02 21:09:06 +01:00
parent 452d86c88e
commit 0be7395f95
No known key found for this signature in database
GPG key ID: 6FC74C847011FD83
6 changed files with 125 additions and 1 deletions

View file

@ -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).

View file

@ -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

View file

@ -0,0 +1,96 @@
{
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";
};
};
};
}

View file

@ -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
nixos/tests/readeck.nix Normal file
View file

@ -0,0 +1,24 @@
{ 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")
'';
}