Skip to content

Commit b79ccc3

Browse files
refactor: separate services
1 parent 89fa84f commit b79ccc3

File tree

4 files changed

+169
-146
lines changed

4 files changed

+169
-146
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# https://github.com/zimeg/blog
2+
{ pkgs, ... }:
3+
{
4+
systemd.services = {
5+
"blog" = {
6+
documentation = [ "https://github.com/zimeg/blog" ];
7+
wants = [
8+
"network-online.target"
9+
];
10+
after = [
11+
"network-online.target"
12+
];
13+
path = [
14+
pkgs.git
15+
];
16+
serviceConfig = {
17+
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"npm run host\"";
18+
ExecStartPre = [
19+
"${pkgs.git}/bin/git pull origin main"
20+
"${pkgs.nix}/bin/nix develop --command bash -c \"npm ci --omit=dev\""
21+
"${pkgs.nix}/bin/nix develop --command bash -c \"npm run build\""
22+
];
23+
Restart = "always";
24+
RestartSec = 2;
25+
User = "root";
26+
WorkingDirectory = /srv/blog;
27+
};
28+
};
29+
"blog:preview" = {
30+
documentation = [ "https://github.com/zimeg/blog" ];
31+
wants = [
32+
"network-online.target"
33+
];
34+
after = [
35+
"network-online.target"
36+
];
37+
path = [
38+
pkgs.git
39+
];
40+
serviceConfig = {
41+
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"npm run host -- --port 3000\"";
42+
ExecStartPre = [
43+
"${pkgs.git}/bin/git fetch blog"
44+
"${pkgs.git}/bin/git checkout blog/dev"
45+
"${pkgs.git}/bin/git reset --hard blog/dev"
46+
"${pkgs.nix}/bin/nix develop --command bash -c \"npm ci --omit=dev\""
47+
"${pkgs.nix}/bin/nix develop --command bash -c \"npm run build\""
48+
];
49+
User = "root";
50+
WorkingDirectory = /srv/development;
51+
};
52+
};
53+
};
54+
}
Lines changed: 5 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,17 @@
11
# https://github.com/systemd/systemd
22
{ pkgs, ... }:
33
{
4+
imports = [
5+
./blog
6+
./quintus
7+
./slack
8+
];
49
systemd.services = {
510
nvidia-control-devices = {
611
wantedBy = [ "multi-user.target" ];
712
serviceConfig = {
813
ExecStart = "${pkgs.linuxPackages.nvidia_x11.bin}/bin/nvidia-smi";
914
};
1015
};
11-
"blog" = {
12-
documentation = [ "https://github.com/zimeg/blog" ];
13-
wants = [
14-
"network-online.target"
15-
];
16-
after = [
17-
"network-online.target"
18-
];
19-
path = [
20-
pkgs.git
21-
];
22-
serviceConfig = {
23-
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"npm run host\"";
24-
ExecStartPre = [
25-
"${pkgs.git}/bin/git pull origin main"
26-
"${pkgs.nix}/bin/nix develop --command bash -c \"npm ci --omit=dev\""
27-
"${pkgs.nix}/bin/nix develop --command bash -c \"npm run build\""
28-
];
29-
Restart = "always";
30-
RestartSec = 2;
31-
User = "root";
32-
WorkingDirectory = /srv/blog;
33-
};
34-
};
35-
"blog:preview" = {
36-
documentation = [ "https://github.com/zimeg/blog" ];
37-
wants = [
38-
"network-online.target"
39-
];
40-
after = [
41-
"network-online.target"
42-
];
43-
path = [
44-
pkgs.git
45-
];
46-
serviceConfig = {
47-
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"npm run host -- --port 3000\"";
48-
ExecStartPre = [
49-
"${pkgs.git}/bin/git fetch blog"
50-
"${pkgs.git}/bin/git checkout blog/dev"
51-
"${pkgs.git}/bin/git reset --hard blog/dev"
52-
"${pkgs.nix}/bin/nix develop --command bash -c \"npm ci --omit=dev\""
53-
"${pkgs.nix}/bin/nix develop --command bash -c \"npm run build\""
54-
];
55-
User = "root";
56-
WorkingDirectory = /srv/development;
57-
};
58-
};
59-
"slack:git" = {
60-
documentation = [ "https://github.com/zimeg/slack-sandbox" ];
61-
wants = [
62-
"network-online.target"
63-
];
64-
after = [
65-
"network-online.target"
66-
];
67-
requiredBy = [
68-
"slack:snaek.service"
69-
"slack:tails.service"
70-
];
71-
path = [
72-
pkgs.openssh
73-
];
74-
serviceConfig = {
75-
ExecStart = "${pkgs.git}/bin/git pull origin main";
76-
Restart = "on-failure";
77-
User = "root";
78-
WorkingDirectory = /srv/slack;
79-
};
80-
unitConfig = {
81-
ConditionPathExists = /srv/slack;
82-
StartLimitBurst = 12;
83-
StartLimitIntervalSec = 24;
84-
};
85-
};
86-
"slack:snaek" = {
87-
documentation = [ "https://github.com/zimeg/slack-sandbox" ];
88-
wantedBy = [ "default.target" ];
89-
wants = [
90-
"network-online.target"
91-
"ollama.service"
92-
];
93-
after = [
94-
"network-online.target"
95-
"ollama.service"
96-
];
97-
path = [
98-
pkgs.git
99-
];
100-
serviceConfig = {
101-
EnvironmentFile = /srv/slack/py.bolt.snaek/.env;
102-
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"python3 app.py\"";
103-
ExecStartPre = "${pkgs.ollama}/bin/ollama create snaek --file models/Modelfile";
104-
Restart = "always";
105-
RestartSec = 2;
106-
User = "root";
107-
WorkingDirectory = /srv/slack/py.bolt.snaek;
108-
};
109-
unitConfig = {
110-
ConditionPathExists = /srv/slack/py.bolt.snaek/.slack/hooks.json;
111-
StartLimitBurst = 12;
112-
StartLimitIntervalSec = 24;
113-
};
114-
};
115-
"slack:tails" = {
116-
documentation = [ "https://github.com/zimeg/slack-sandbox" ];
117-
wantedBy = [ "default.target" ];
118-
wants = [
119-
"network-online.target"
120-
];
121-
after = [
122-
"network-online.target"
123-
];
124-
path = [
125-
pkgs.git
126-
];
127-
serviceConfig = {
128-
EnvironmentFile = /srv/slack/js.bolt.tails/.env;
129-
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"npm run start\"";
130-
ExecStartPre = "${pkgs.nix}/bin/nix develop --command bash -c \"npm ci --omit=dev --omit=optional\"";
131-
Restart = "always";
132-
RestartSec = 2;
133-
User = "root";
134-
WorkingDirectory = /srv/slack/js.bolt.tails;
135-
};
136-
unitConfig = {
137-
ConditionPathExists = /srv/slack/js.bolt.tails/.slack/hooks.json;
138-
StartLimitBurst = 12;
139-
StartLimitIntervalSec = 24;
140-
};
141-
};
142-
"quintus" = {
143-
documentation = [ "https://github.com/zimeg/quintus" ];
144-
wants = [
145-
"network-online.target"
146-
];
147-
after = [
148-
"network-online.target"
149-
];
150-
serviceConfig = {
151-
ExecStart = "${pkgs.nix}/bin/nix run github:zimeg/quintus/selfhost --refresh";
152-
Restart = "always";
153-
RestartSec = 2;
154-
User = "root";
155-
};
156-
};
15716
};
15817
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://github.com/zimeg/quintus
2+
{ pkgs, ... }:
3+
{
4+
systemd.services = {
5+
"quintus" = {
6+
documentation = [ "https://github.com/zimeg/quintus" ];
7+
wants = [
8+
"network-online.target"
9+
];
10+
after = [
11+
"network-online.target"
12+
];
13+
serviceConfig = {
14+
ExecStart = "${pkgs.nix}/bin/nix run github:zimeg/quintus/selfhost --refresh";
15+
Restart = "always";
16+
RestartSec = 2;
17+
User = "root";
18+
};
19+
};
20+
};
21+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# https://github.com/zimeg/slack-sandbox
2+
{ pkgs, ... }:
3+
{
4+
systemd.services = {
5+
"slack:git" = {
6+
documentation = [ "https://github.com/zimeg/slack-sandbox" ];
7+
wants = [
8+
"network-online.target"
9+
];
10+
after = [
11+
"network-online.target"
12+
];
13+
requiredBy = [
14+
"slack:snaek.service"
15+
"slack:tails.service"
16+
];
17+
path = [
18+
pkgs.openssh
19+
];
20+
serviceConfig = {
21+
ExecStart = "${pkgs.git}/bin/git pull origin main";
22+
Restart = "on-failure";
23+
User = "root";
24+
WorkingDirectory = /srv/slack;
25+
};
26+
unitConfig = {
27+
ConditionPathExists = /srv/slack;
28+
StartLimitBurst = 12;
29+
StartLimitIntervalSec = 24;
30+
};
31+
};
32+
"slack:snaek" = {
33+
documentation = [ "https://github.com/zimeg/slack-sandbox" ];
34+
wantedBy = [ "default.target" ];
35+
wants = [
36+
"network-online.target"
37+
"ollama.service"
38+
];
39+
after = [
40+
"network-online.target"
41+
"ollama.service"
42+
];
43+
path = [
44+
pkgs.git
45+
];
46+
serviceConfig = {
47+
EnvironmentFile = /srv/slack/py.bolt.snaek/.env;
48+
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"python3 app.py\"";
49+
ExecStartPre = "${pkgs.ollama}/bin/ollama create snaek --file models/Modelfile";
50+
Restart = "always";
51+
RestartSec = 2;
52+
User = "root";
53+
WorkingDirectory = /srv/slack/py.bolt.snaek;
54+
};
55+
unitConfig = {
56+
ConditionPathExists = /srv/slack/py.bolt.snaek/.slack/hooks.json;
57+
StartLimitBurst = 12;
58+
StartLimitIntervalSec = 24;
59+
};
60+
};
61+
"slack:tails" = {
62+
documentation = [ "https://github.com/zimeg/slack-sandbox" ];
63+
wantedBy = [ "default.target" ];
64+
wants = [
65+
"network-online.target"
66+
];
67+
after = [
68+
"network-online.target"
69+
];
70+
path = [
71+
pkgs.git
72+
];
73+
serviceConfig = {
74+
EnvironmentFile = /srv/slack/js.bolt.tails/.env;
75+
ExecStart = "${pkgs.nix}/bin/nix develop --command bash -c \"npm run start\"";
76+
ExecStartPre = "${pkgs.nix}/bin/nix develop --command bash -c \"npm ci --omit=dev --omit=optional\"";
77+
Restart = "always";
78+
RestartSec = 2;
79+
User = "root";
80+
WorkingDirectory = /srv/slack/js.bolt.tails;
81+
};
82+
unitConfig = {
83+
ConditionPathExists = /srv/slack/js.bolt.tails/.slack/hooks.json;
84+
StartLimitBurst = 12;
85+
StartLimitIntervalSec = 24;
86+
};
87+
};
88+
};
89+
}

0 commit comments

Comments
 (0)