Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit cf17870

Browse files
committed
keep the Makefile up-to-date with NixOS module
1 parent 104f723 commit cf17870

File tree

9 files changed

+46
-120
lines changed

9 files changed

+46
-120
lines changed

Makefile

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
src=.
22
path=${shell pwd}
3+
tags = sdnotiy
34
ldflags-mio = -X github.com/nyiyui/qrystal/mio.CommandBash=${shell which bash}
45
ldflags-mio += -X github.com/nyiyui/qrystal/mio.CommandWg=${shell which wg}
56
ldflags-mio += -X github.com/nyiyui/qrystal/mio.CommandWgQuick=${shell which wg-quick}
@@ -10,76 +11,62 @@ ldflags-runner = -X github.com/nyiyui/qrystal/runner.NodeUser=qrystal-node
1011
all: runner-mio runner-hokuto runner-node runner gen-keys cs
1112

1213
runner-mio:
13-
cd ${src} && go build -race -ldflags "${ldflags-mio}" -o ${path}/runner-mio ${src}/cmd/runner-mio
14+
cd ${src} && go build -race -tags "${tags}" -ldflags "${ldflags-mio}" -o ${path}/runner-mio ${src}/cmd/runner-mio
1415

1516
runner-hokuto:
16-
cd ${src} && go build -race -o ${path}/runner-hokuto ${src}/cmd/runner-hokuto
17+
cd ${src} && go build -race -tags "${tags}" -o ${path}/runner-hokuto ${src}/cmd/runner-hokuto
1718

1819
runner-node:
19-
cd ${src} && go build -race -ldflags "${ldflags-node}" -o ${path}/runner-node ${src}/cmd/runner-node
20+
cd ${src} && go build -race -tags "${tags}" -ldflags "${ldflags-node}" -o ${path}/runner-node ${src}/cmd/runner-node
2021

2122
runner:
22-
cd ${src} && go build -race -ldflags "${ldflags-runner}" -o ${path}/runner ${src}/cmd/runner
23+
cd ${src} && go build -race -tags "${tags}" -ldflags "${ldflags-runner}" -o ${path}/runner ${src}/cmd/runner
2324

2425
gen-keys:
25-
cd ${src} && go build -race -o ${path}/gen-keys ${src}/cmd/gen-keys
26+
cd ${src} && go build -race -tags "${tags}" -o ${path}/gen-keys ${src}/cmd/gen-keys
2627

2728
cs:
28-
cd ${src} && go build -race -o ${path}/cs ${src}/cmd/cs
29+
cd ${src} && go build -race -tags "${tags}" -o ${path}/cs ${src}/cmd/cs
2930

3031
cs-push:
31-
cd ${src} go build -race -o ${path}/cs-push ${src}/cmd/cs-push
32+
cd ${src} go build -race -tags "${tags}" -o ${path}/cs-push ${src}/cmd/cs-push
3233

3334
install-cs-push: cs-push
3435
install -m 755 -o root -g root $@ ${pkdir}/usr/bin/qrystal-cs-push
3536

3637
uninstall-cs-push:
3738
rm -f ${pkgdir}/usr/bin/qrystal-cs-push
3839

39-
pre_install:
40-
systemctl stop qrystal-runner
40+
install-cs: cs
4141
systemctl stop qrystal-cs
42-
43-
post_install:
44-
systemctl start qrystal-runner
45-
systemctl start qrystal-cs
46-
47-
install: runner-mio runner-hokuto runner-node runner gen-keys cs
42+
#
43+
mkdir -p "${pkgdir}/opt/qrystal"
44+
install -m 755 -o root -g root $@ ${pkdir}/opt/qrystal/qrystal-cs
4845
mkdir -p "${pkgdir}/usr/lib/sysusers.d"
49-
install -m 644 '${src}/config/sysusers.conf' "${pkgdir}/usr/lib/sysusers.d/qrystal.conf"
46+
install -m 644 '${src}/config/sysusers-cs.conf' "${pkgdir}/usr/lib/sysusers.d/qrystal-cs.conf"
5047
systemctl restart systemd-sysusers
51-
mkdir -p "${pkgdir}/usr/bin"
52-
install -o root -g root -m 555 ${path}/runner "${pkgdir}/usr/bin/qrystal-runner"
53-
install -o root -g root -m 555 ${path}/gen-keys "${pkgdir}/usr/bin/qrystal-gen-keys"
54-
install -o root -g root -m 555 ${path}/cs "${pkgdir}/usr/bin/qrystal-cs"
55-
mkdir -p "${pkgdir}/opt/qrystal"
56-
install -o root -g root -m 500 \
57-
${path}/runner-mio \
58-
${path}/runner-hokuto \
59-
${src}/mio/dev-add.sh \
60-
${src}/mio/dev-remove.sh \
61-
"${pkgdir}/opt/qrystal/"
62-
install -o root -g root -m 555 \
63-
${path}/runner-node \
64-
"${pkgdir}/opt/qrystal/"
48+
#
6549
mkdir -p "${pkgdir}/etc/qrystal"
6650
chown root:qrystal-node "${pkgdir}/etc/qrystal"
6751
chmod 755 "${pkgdir}/etc/qrystal"
68-
cp -n \
69-
'${src}/config/cs-config.yml' \
70-
'${src}/config/runner-config.yml' \
71-
'${src}/config/node-config.yml' \
72-
"${pkgdir}/etc/qrystal/"
52+
install '${src}/config/cs-config.yml' "${pkgdir}/etc/qrystal/"
7353
chown root:qrystal-cs "${pkgdir}/etc/qrystal/cs-config.yml"
7454
chmod 640 "${pkgdir}/etc/qrystal/cs-config.yml"
75-
chown root:qrystal-node "${pkgdir}/etc/qrystal/node-config.yml"
76-
chmod 640 "${pkgdir}/etc/qrystal/node-config.yml"
77-
chmod 600 "${pkgdir}/etc/qrystal/runner-config.yml"
55+
#
7856
mkdir -p "${pkgdir}/usr/lib/systemd/system"
79-
install '${src}/config/runner.service' "${pkgdir}/usr/lib/systemd/system/qrystal-runner.service"
8057
install '${src}/config/cs.service' "${pkgdir}/usr/lib/systemd/system/qrystal-cs.service"
8158
systemctl daemon-reload
8259

60+
uninstall-cs:
61+
systemctl stop qrystal-cs
62+
rm -f ${pkgdir}/usr/bin/qrystal-cs
63+
rm -rf "${pkgdir}/opt/qrystal/qrystal-cs" \
64+
"${pkgdir}/etc/qrystal/cs-config.yml"
65+
rmdir "${pkgdir}/opt/qrystal" \
66+
"${pkgdir}/etc/qrystal"
67+
rm -f "${pkgdir}/usr/lib/sysusers.d/qrystal-cs.conf" \
68+
"${pkgdir}/usr/lib/systemd/system/qrystal-cs.service"
69+
8370
uninstall:
8471
rm -rf "${pkgdir}/opt/qrystal" \
8572
"${pkgdir}/etc/qrystal"

config/cs-config.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
# NOTE: options not commented out are required.
1+
# NOTE: options not commented out are required. Options commented out have the default value filled in.
22
tls:
33
# path to pem-encoded tls certificate and key
44
certPath:
55
keyPath:
66
# bind address for node API (node)
77
addr: :39252
8-
# bind address for haruka API (cs-push etc)
9-
harukaAddr: :39253
8+
# bind address for ryo API (HTTP; for cs-push)
9+
ryoAddr: :39253
1010
# path to backport file
11-
backportPath: $STATE_DIRECTORY/cs-backport.yml
11+
#backportPath: $STATE_DIRECTORY/cs-backport.yml
1212
# path to db
13-
dbPath: $STATE_DIRECTORY/db
13+
#dbPath: $STATE_DIRECTORY/db
14+
1415
# tokens for node and haruka APIs
1516
tokens:
1617
- # friendly name (used in e.g. errors)
1718
name:
1819
# hash of the token (use qrystal-gen-keys)
1920
hash:
20-
# allow token to pull (bool)
21+
# Allow token to pull peers (see networks)
2122
canPull:
22-
# networks the token can pull from
23+
# Nets this token can pull from and the corresponding peer names.
2324
networks:
2425
<net name>: <peer name>
2526
# allow token to push new peer configs
2627
canPush:
2728
# can push to any peer in any net (bool)
2829
any:
29-
# can pish to the following nets (overridden by any: true)
30+
# can push to the following nets (overridden by any: true)
3031
networks:
3132
<net name>:
3233
# can push a peer with this name
@@ -44,7 +45,7 @@ central:
4445
<net name>:
4546
# PersistentKeepalive= in wg-quick config
4647
keepalive: 10s
47-
# ListenPort = in wg-quick config
48+
# ListenPort= in wg-quick config
4849
listenPort: 58120
4950
# all IP addresses (IPv4 only) in the net
5051
ips:
@@ -58,5 +59,7 @@ central:
5859
allowed-ips:
5960
- 10.123.0.1/32
6061
# peer can only see the following peers
62+
# NOTE: has to be either { only: ... } or "any"
6163
canSee:
6264
only: [ <peer name>… ]
65+
canSee: "any"

config/cs.service

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[Unit]
22
Wants=network-online.target
3-
After=network.target network-online.target
3+
After=network-online.target nss-lookup.target
44

55
[Service]
66
User=qrystal-cs
7-
ExecStart=qrystal-cs -config /etc/qrystal/cs-config.yml
8-
Environment=QRYSTAL_PROFILE=on
7+
Restart=on-failure
8+
Type=notify
9+
ExecStart=/opt/qrystal/qrystal-cs -config /etc/qrystal/cs-config.yml
910
RuntimeDirectory=qrystal-cs
1011
RuntimeDirectoryMode=0700
1112
StateDirectory=qrystal-cs

config/node-config.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

config/runner-config.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/runner.service

Lines changed: 0 additions & 19 deletions
This file was deleted.

config/sysusers-cs.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
g qrystal-cs -
2+
u qrystal-cs - "Qrystal CS"

config/sysusers.conf

Lines changed: 0 additions & 3 deletions
This file was deleted.

nixos-modules.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ args@{ self, system, nixpkgsFor, libFor, nixosLibFor, ldflags, packages, ...
275275
ryoAddr = mkOption {
276276
type = str;
277277
default = ":39253";
278-
description = "Bind address of Ryo (HTTP) API";
278+
description = "Bind address of Ryo (HTTP; for cs-push) API";
279279
};
280280
tokens = mkOption {
281281
type = listOf (submodule {
@@ -401,7 +401,7 @@ args@{ self, system, nixpkgsFor, libFor, nixosLibFor, ldflags, packages, ...
401401
group = "qrystal-cs";
402402
};
403403
systemd.services.qrystal-cs = {
404-
wantedBy = [ "network-online.target" ];
404+
wants = [ "network-online.target" ];
405405
serviceConfig = let pkg = packages.cs;
406406
in {
407407
User = "qrystal-cs";

0 commit comments

Comments
 (0)