Signed-off-by: Seongmin Lee git@boltless.me
flake.nix
flake.nix
This file has not been changed.
+118
-116
nix/modules/knotmirror.nix
+118
-116
nix/modules/knotmirror.nix
···
5
5
...
6
6
}: let
7
7
cfg = config.services.tangled.knotmirror;
8
-
in with lib; {
9
-
options.services.tangled.knotmirror = {
10
-
enable = mkOption {
11
-
type = types.bool;
12
-
default = false;
13
-
description = "Enable a tangled knot";
14
-
};
15
-
16
-
package = mkOption {
17
-
type = types.package;
18
-
description = "Package to use for the knotmirror";
19
-
};
20
-
21
-
tap-package = mkOption {
22
-
type = types.package;
23
-
description = "tap package to use for the knotmirror";
24
-
};
25
-
26
-
listenAddr = mkOption {
27
-
type = types.str;
28
-
default = "0.0.0.0:7000";
29
-
description = "Address to listen on";
30
-
};
8
+
in
9
+
with lib; {
10
+
options.services.tangled.knotmirror = {
11
+
enable = mkOption {
12
+
type = types.bool;
13
+
default = false;
14
+
description = "Enable a tangled knot";
15
+
};
31
16
32
-
adminListenAddr = mkOption {
33
-
type = types.str;
34
-
default = "127.0.0.1:7200";
35
-
description = "Address to listen on";
36
-
};
17
+
package = mkOption {
18
+
type = types.package;
19
+
description = "Package to use for the knotmirror";
20
+
};
37
21
38
-
hostname = mkOption {
39
-
type = types.str;
40
-
example = "my.knotmirror.com";
41
-
description = "Hostname for the server (required)";
42
-
};
22
+
tap-package = mkOption {
23
+
type = types.package;
24
+
description = "tap package to use for the knotmirror";
25
+
};
43
26
44
-
dbUrl = mkOption {
45
-
type = types.str;
46
-
example = "postgresql://...";
47
-
description = "Database URL. postgresql expected (required)";
48
-
};
27
+
listenAddr = mkOption {
28
+
type = types.str;
29
+
default = "0.0.0.0:7000";
30
+
description = "Address to listen on";
31
+
};
49
32
50
-
atpPlcUrl = mkOption {
51
-
type = types.str;
52
-
default = "https://plc.directory";
53
-
description = "atproto PLC directory";
54
-
};
33
+
adminListenAddr = mkOption {
34
+
type = types.str;
35
+
default = "127.0.0.1:7200";
36
+
description = "Address to listen on";
37
+
};
55
38
56
-
atpRelayUrl = mkOption {
57
-
type = types.str;
58
-
default = "https://relay1.us-east.bsky.network";
59
-
description = "atproto relay";
60
-
};
39
+
hostname = mkOption {
40
+
type = types.str;
41
+
example = "my.knotmirror.com";
42
+
description = "Hostname for the server (required)";
43
+
};
61
44
62
-
fullNetwork = mkOption {
63
-
type = types.bool;
64
-
default = false;
65
-
description = "Whether to automatically mirror from entire network";
66
-
};
45
+
dbUrl = mkOption {
46
+
type = types.str;
47
+
example = "postgresql://...";
48
+
description = "Database URL. postgresql expected (required)";
49
+
};
67
50
68
-
tap = {
69
-
port = mkOption {
70
-
type = types.port;
71
-
default = 7480;
72
-
description = "Internal port to run the knotmirror tap";
51
+
atpPlcUrl = mkOption {
52
+
type = types.str;
53
+
default = "https://plc.directory";
54
+
description = "atproto PLC directory";
73
55
};
74
56
75
-
dbUrl = mkOption {
57
+
atpRelayUrl = mkOption {
76
58
type = types.str;
77
-
default = "sqlite:///var/lib/knotmirror-tap/tap.db";
78
-
description = "database connection string (sqlite://path or postgres://...)";
59
+
default = "https://relay1.us-east.bsky.network";
60
+
description = "atproto relay";
79
61
};
80
-
};
81
-
};
82
-
config = mkIf cfg.enable {
83
-
environment.systemPackages = [
84
-
pkgs.git
85
-
cfg.package
86
-
];
87
-
88
-
systemd.services.tap-knotmirror = {
89
-
description = "knotmirror tap service";
90
-
after = ["network.target"];
91
-
wantedBy = ["multi-user.target"];
92
-
serviceConfig = {
93
-
LogsDirectory = "knotmirror-tap";
94
-
StateDirectory = "knotmirror-tap";
95
-
Environment = [
96
-
"TAP_BIND=:${toString cfg.tap.port}"
97
-
"TAP_PLC_URL=${cfg.atpPlcUrl}"
98
-
"TAP_RELAY_URL=${cfg.atpRelayUrl}"
99
-
"TAP_RESYNC_PARALLELISM=10"
100
-
"TAP_DATABASE_URL=${cfg.tap.dbUrl}"
101
-
"TAP_RETRY_TIMEOUT=60s"
102
-
"TAP_COLLECTION_FILTERS=sh.tangled.repo"
103
-
(if cfg.fullNetwork then
104
-
"TAP_SIGNAL_COLLECTION=sh.tangled.repo"
105
-
else
106
-
"TAP_FULL_NETWORK=false")
107
-
];
108
-
ExecStart = "${getExe cfg.tap-package} run";
62
+
63
+
fullNetwork = mkOption {
64
+
type = types.bool;
65
+
default = false;
66
+
description = "Whether to automatically mirror from entire network";
109
67
};
110
-
};
111
68
112
-
systemd.services.knotmirror = {
113
-
description = "knotmirror service";
114
-
after = ["network.target" "tap-knotmirror.service"];
115
-
wantedBy = ["multi-user.target"];
116
-
path = [
69
+
tap = {
70
+
port = mkOption {
71
+
type = types.port;
72
+
default = 7480;
73
+
description = "Internal port to run the knotmirror tap";
74
+
};
75
+
76
+
dbUrl = mkOption {
77
+
type = types.str;
78
+
default = "sqlite:///var/lib/knotmirror-tap/tap.db";
79
+
description = "database connection string (sqlite://path or postgres://...)";
80
+
};
81
+
};
82
+
};
83
+
config = mkIf cfg.enable {
84
+
environment.systemPackages = [
117
85
pkgs.git
86
+
cfg.package
118
87
];
119
-
serviceConfig = {
120
-
LogsDirectory = "knotmirror";
121
-
StateDirectory = "knotmirror";
122
-
Environment = [
123
-
# TODO: add environment variables
124
-
"MIRROR_LISTEN=${cfg.listenAddr}"
125
-
"MIRROR_HOSTNAME=${cfg.hostname}"
126
-
"MIRROR_TAP_URL=http://localhost:${toString cfg.tap.port}"
127
-
"MIRROR_DB_URL=${cfg.dbUrl}"
128
-
"MIRROR_GIT_BASEPATH=/var/lib/knotmirror/repos"
129
-
"MIRROR_KNOT_USE_SSL=true"
130
-
"MIRROR_KNOT_SSRF=true"
131
-
"MIRROR_RESYNC_PARALLELISM=12"
132
-
"MIRROR_METRICS_LISTEN=127.0.0.1:7100"
133
-
"MIRROR_ADMIN_LISTEN=${cfg.adminListenAddr}"
134
-
"MIRROR_SLURPER_CONCURRENCY=4"
88
+
89
+
systemd.services.tap-knotmirror = {
90
+
description = "knotmirror tap service";
91
+
after = ["network.target"];
92
+
wantedBy = ["multi-user.target"];
93
+
serviceConfig = {
94
+
LogsDirectory = "knotmirror-tap";
95
+
StateDirectory = "knotmirror-tap";
96
+
Environment = [
97
+
"TAP_BIND=:${toString cfg.tap.port}"
98
+
"TAP_PLC_URL=${cfg.atpPlcUrl}"
99
+
"TAP_RELAY_URL=${cfg.atpRelayUrl}"
100
+
"TAP_RESYNC_PARALLELISM=10"
101
+
"TAP_DATABASE_URL=${cfg.tap.dbUrl}"
102
+
"TAP_RETRY_TIMEOUT=60s"
103
+
"TAP_COLLECTION_FILTERS=sh.tangled.repo"
104
+
(
105
+
if cfg.fullNetwork
106
+
then "TAP_SIGNAL_COLLECTION=sh.tangled.repo"
107
+
else "TAP_FULL_NETWORK=false"
108
+
)
109
+
];
110
+
ExecStart = "${getExe cfg.tap-package} run";
111
+
};
112
+
};
113
+
114
+
systemd.services.knotmirror = {
115
+
description = "knotmirror service";
116
+
after = ["network.target" "tap-knotmirror.service"];
117
+
wantedBy = ["multi-user.target"];
118
+
path = [
119
+
pkgs.git
135
120
];
136
-
ExecStart = "${getExe cfg.package} serve";
137
-
Restart = "always";
121
+
serviceConfig = {
122
+
LogsDirectory = "knotmirror";
123
+
StateDirectory = "knotmirror";
124
+
Environment = [
125
+
# TODO: add environment variables
126
+
"MIRROR_LISTEN=${cfg.listenAddr}"
127
+
"MIRROR_HOSTNAME=${cfg.hostname}"
128
+
"MIRROR_TAP_URL=http://localhost:${toString cfg.tap.port}"
129
+
"MIRROR_DB_URL=${cfg.dbUrl}"
130
+
"MIRROR_GIT_BASEPATH=/var/lib/knotmirror/repos"
131
+
"MIRROR_KNOT_USE_SSL=true"
132
+
"MIRROR_KNOT_SSRF=true"
133
+
"MIRROR_RESYNC_PARALLELISM=12"
134
+
"MIRROR_METRICS_LISTEN=127.0.0.1:7100"
135
+
"MIRROR_ADMIN_LISTEN=${cfg.adminListenAddr}"
136
+
"MIRROR_SLURPER_CONCURRENCY=4"
137
+
];
138
+
ExecStart = "${getExe cfg.package} serve";
139
+
Restart = "always";
140
+
};
138
141
};
139
142
};
140
-
};
141
-
}
143
+
}
History
5 rounds
0 comments
boltless.me
submitted
#4
1 commit
expand
collapse
nix: add knotmirror module
Signed-off-by: Seongmin Lee <git@boltless.me>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
pull request successfully merged
boltless.me
submitted
#3
1 commit
expand
collapse
nix: add knotmirror module
Signed-off-by: Seongmin Lee <git@boltless.me>
expand 0 comments
boltless.me
submitted
#2
1 commit
expand
collapse
nix: add knotmirror module
Signed-off-by: Seongmin Lee <git@boltless.me>
expand 0 comments
boltless.me
submitted
#1
1 commit
expand
collapse
nix: add knotmirror module
Signed-off-by: Seongmin Lee <git@boltless.me>
expand 0 comments
boltless.me
submitted
#0
1 commit
expand
collapse
nix: add knotmirror module
Signed-off-by: Seongmin Lee <git@boltless.me>