Skip to content

Commit f2685b1

Browse files
authored
pkgs/readeck + nixos/readeck: init (NixOS#370354)
2 parents 66aa98b + 0be7395 commit f2685b1

File tree

6 files changed

+216
-0
lines changed

6 files changed

+216
-0
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979

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

82+
- [Readeck](https://readeck.org/), a read-it later web-application. Available as [services.readeck](#opt-services.readeck.enable).
83+
8284
- [Traccar](https://www.traccar.org/), a modern GPS Tracking Platform. Available as [services.traccar](#opt-services.traccar.enable).
8385

8486
- [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).

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@
15671567
./services/web-apps/screego.nix
15681568
./services/web-apps/sftpgo.nix
15691569
./services/web-apps/suwayomi-server.nix
1570+
./services/web-apps/readeck.nix
15701571
./services/web-apps/rss-bridge.nix
15711572
./services/web-apps/selfoss.nix
15721573
./services/web-apps/shiori.nix
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
config,
3+
pkgs,
4+
lib,
5+
...
6+
}:
7+
8+
let
9+
inherit (lib)
10+
mkEnableOption
11+
mkPackageOption
12+
mkOption
13+
mkIf
14+
types
15+
;
16+
cfg = config.services.readeck;
17+
settingsFormat = pkgs.formats.toml { };
18+
configFile = settingsFormat.generate "readeck.toml" cfg.settings;
19+
20+
in
21+
{
22+
23+
meta.maintainers = [ lib.maintainers.julienmalka ];
24+
25+
options = {
26+
services.readeck = {
27+
enable = mkEnableOption "Readeck";
28+
29+
package = mkPackageOption pkgs "readeck" { };
30+
31+
environmentFile = mkOption {
32+
type = types.nullOr types.path;
33+
description = ''
34+
File containing environment variables to be passed to Readeck.
35+
May be used to provide the Readeck secret key by setting the READECK_SECRET_KEY variable.
36+
'';
37+
default = null;
38+
};
39+
40+
settings = mkOption {
41+
type = settingsFormat.type;
42+
default = { };
43+
example = {
44+
main.log_level = "debug";
45+
server.port = 9000;
46+
};
47+
description = ''
48+
Additional configuration for Readeck, see
49+
<https://readeck.org/en/docs/configuration>
50+
for supported values.
51+
'';
52+
};
53+
54+
};
55+
};
56+
57+
config = mkIf cfg.enable {
58+
systemd.services.readeck = {
59+
description = "Readeck";
60+
after = [ "network.target" ];
61+
wantedBy = [ "multi-user.target" ];
62+
serviceConfig = {
63+
Type = "simple";
64+
StateDirectory = "readeck";
65+
WorkingDirectory = "/var/lib/readeck";
66+
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
67+
DynamicUser = true;
68+
ExecStart = "${lib.getExe cfg.package} serve -config ${configFile}";
69+
ProtectSystem = "full";
70+
SystemCallArchitectures = "native";
71+
MemoryDenyWriteExecute = true;
72+
NoNewPrivileges = true;
73+
PrivateTmp = true;
74+
PrivateDevices = true;
75+
RestrictAddressFamilies = [
76+
"AF_INET"
77+
"AF_INET6"
78+
"AF_UNIX"
79+
"AF_NETLINK"
80+
];
81+
RestrictNamespaces = true;
82+
RestrictRealtime = true;
83+
DevicePolicy = "closed";
84+
ProtectClock = true;
85+
ProtectHostname = true;
86+
ProtectProc = "invisible";
87+
ProtectControlGroups = true;
88+
ProtectKernelModules = true;
89+
ProtectKernelTunables = true;
90+
LockPersonality = true;
91+
Restart = "on-failure";
92+
93+
};
94+
};
95+
};
96+
}

nixos/tests/all-tests.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ in {
894894
rathole = handleTest ./rathole.nix {};
895895
readarr = handleTest ./readarr.nix {};
896896
realm = handleTest ./realm.nix {};
897+
readeck = runTest ./readeck.nix;
897898
redis = handleTest ./redis.nix {};
898899
redlib = handleTest ./redlib.nix {};
899900
redmine = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./redmine.nix {};

nixos/tests/readeck.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{ lib, ... }:
2+
3+
{
4+
name = "readeck";
5+
meta.maintainers = with lib.maintainers; [ julienmalka ];
6+
7+
nodes.machine =
8+
{ pkgs, ... }:
9+
{
10+
services.readeck = {
11+
enable = true;
12+
environmentFile = pkgs.writeText "env-file" ''
13+
READECK_SECRET_KEY="verysecretkey"
14+
'';
15+
};
16+
};
17+
18+
testScript = ''
19+
machine.start()
20+
machine.wait_for_unit("readeck.service")
21+
machine.wait_for_open_port(8000)
22+
machine.succeed("curl --fail http://localhost:8000/login?r=%2F")
23+
'';
24+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
fetchFromGitea,
3+
fetchNpmDeps,
4+
buildGoModule,
5+
nodejs,
6+
npmHooks,
7+
lib,
8+
}:
9+
10+
let
11+
12+
file-compose = buildGoModule {
13+
pname = "file-compose";
14+
version = "unstable-2023-10-21";
15+
16+
src = fetchFromGitea {
17+
domain = "codeberg.org";
18+
owner = "readeck";
19+
repo = "file-compose";
20+
rev = "afa938655d412556a0db74b202f9bcc1c40d8579";
21+
hash = "sha256-rMANRqUQRQ8ahlxuH1sWjlGpNvbReBOXIkmBim/wU2o=";
22+
};
23+
24+
vendorHash = "sha256-Qwixx3Evbf+53OFeS3Zr7QCkRMfgqc9hUA4eqEBaY0c=";
25+
};
26+
in
27+
28+
buildGoModule rec {
29+
pname = "readeck";
30+
version = "0.17.1";
31+
32+
src = fetchFromGitea {
33+
domain = "codeberg.org";
34+
owner = "readeck";
35+
repo = "readeck";
36+
tag = version;
37+
hash = "sha256-+GgjR1mxD93bFNaLeDuEefPlQEV9jNgFIo8jTAxphyo=";
38+
};
39+
40+
nativeBuildInputs = [
41+
nodejs
42+
npmHooks.npmConfigHook
43+
];
44+
45+
npmRoot = "web";
46+
47+
NODE_PATH = "$npmDeps";
48+
49+
preBuild = ''
50+
make web-build
51+
${file-compose}/bin/file-compose -format json docs/api/api.yaml docs/assets/api.json
52+
go run ./tools/docs docs/src docs/assets
53+
'';
54+
55+
tags = [
56+
"netgo"
57+
"osusergo"
58+
"sqlite_omit_load_extension"
59+
"sqlite_foreign_keys"
60+
"sqlite_json1"
61+
"sqlite_fts5"
62+
"sqlite_secure_delete"
63+
];
64+
65+
ldflags = [
66+
"-X"
67+
"codeberg.org/readeck/readeck/configs.version=${version}"
68+
];
69+
overrideModAttrs = oldAttrs: {
70+
# Do not add `npmConfigHook` to `goModules`
71+
nativeBuildInputs = lib.remove npmHooks.npmConfigHook oldAttrs.nativeBuildInputs;
72+
# Do not run `preBuild` when building `goModules`
73+
preBuild = null;
74+
};
75+
76+
npmDeps = fetchNpmDeps {
77+
src = "${src}/web";
78+
hash = "sha256-7fRSkXKAMEC7rFmSF50DM66SVhV68g93PMBjrtkd9/E=";
79+
};
80+
81+
vendorHash = "sha256-O/ZrpT6wTtPwBDUCAmR0XHRgQmd46/MPvWNE0EvD3bg=";
82+
83+
meta = {
84+
description = "Web application that lets you save the readable content of web pages you want to keep forever.";
85+
mainProgram = "readeck";
86+
homepage = "https://readeck.org/";
87+
changelog = "https://github.com/readeck/readeck/releases/tag/${version}";
88+
license = lib.licenses.agpl3Only;
89+
maintainers = with lib.maintainers; [ julienmalka ];
90+
};
91+
92+
}

0 commit comments

Comments
 (0)