Skip to content

Commit e01260f

Browse files
committed
feat(komodo): integrate periphery service
1 parent 10a4e56 commit e01260f

File tree

2 files changed

+48
-25
lines changed

2 files changed

+48
-25
lines changed

modules/nas.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ in
3737
type = "cifs";
3838
what = "//${nasHostname}/${share}";
3939
where = "/mnt/nas/${share}";
40-
options = cifsOptions;
40+
options = if share == "encrypted" then "${cifsOptions},nofail" else cifsOptions;
4141
unitConfig = {
4242
After = "network-online.target";
4343
Requires = "network-online.target";

modules/services/komodo.nix

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ _: {
2020
useAdminBootstrap = cfg.core.initAdminUsername != null && effectiveAdminPasswordFile != null;
2121
composeFilePath = "/etc/komodo/compose.yaml";
2222
composeEnvPath = "/etc/komodo/compose.env";
23+
peripheryConfigPath = "/etc/komodo/periphery.toml";
2324
composeYamlText =
2425
let
2526
baseLines = [
@@ -52,20 +53,48 @@ _: {
5253
" volumes:"
5354
" - /var/lib/komodo/backups:/backups"
5455
];
55-
passkeyLine =
56+
corePasskeyLine =
5657
if effectivePasskeyFile != null then
5758
[
5859
" - ${effectivePasskeyFile}:${effectivePasskeyFile}:ro"
5960
]
6061
else
6162
[ ];
63+
peripheryPasskeyLine =
64+
if effectivePasskeyFile != null then
65+
[
66+
" - ${effectivePasskeyFile}:${effectivePasskeyFile}:ro"
67+
]
68+
else
69+
[ ];
70+
peripheryLines = [
71+
""
72+
" periphery:"
73+
" image: ghcr.io/moghtech/komodo-periphery:latest"
74+
" restart: unless-stopped"
75+
" ports:"
76+
" - \"8120:8120\""
77+
" group_add:"
78+
" - \"991\""
79+
" command: [\"periphery\", \"--config-path\", \"/etc/komodo/periphery.toml\"]"
80+
" environment:"
81+
" DOCKER_HOST: unix:///run/podman/podman.sock"
82+
]
83+
++ (if usePasskey then [ " PERIPHERY_PASSKEYS_FILE: ${effectivePasskeyFile}" ] else [ ])
84+
++ [
85+
" volumes:"
86+
" - /run/podman/podman.sock:/run/podman/podman.sock"
87+
" - /var/lib/komodo-periphery:/var/lib/komodo-periphery"
88+
" - ${peripheryConfigPath}:${peripheryConfigPath}:ro"
89+
]
90+
++ peripheryPasskeyLine;
6291
tailLines = [
6392
"volumes:"
6493
" komodo-mongo-data:"
6594
" komodo-mongo-config:"
6695
];
6796
in
68-
lib.concatStringsSep "\n" (baseLines ++ passkeyLine ++ tailLines) + "\n";
97+
lib.concatStringsSep "\n" (baseLines ++ corePasskeyLine ++ peripheryLines ++ tailLines) + "\n";
6998
composeEnvTemplateText =
7099
let
71100
lines = builtins.filter (line: line != null) [
@@ -84,6 +113,16 @@ _: {
84113
];
85114
in
86115
lib.concatStringsSep "\n" lines + "\n";
116+
peripheryConfigText =
117+
let
118+
lines = [
119+
"port = 8120"
120+
"bind_ip = \"0.0.0.0\""
121+
"root_directory = \"/var/lib/komodo-periphery\""
122+
"ssl_enabled = false"
123+
];
124+
in
125+
lib.concatStringsSep "\n" lines + "\n";
87126
in
88127
{
89128
options.services.komodo = {
@@ -135,24 +174,6 @@ _: {
135174
};
136175

137176
config = {
138-
services.komodo-periphery = {
139-
enable = lib.mkDefault true;
140-
ssl.enable = false;
141-
bindIp = "0.0.0.0";
142-
};
143-
144-
users.groups.docker = { };
145-
users.users.komodo-periphery.extraGroups = [ "podman" ];
146-
147-
services.komodo-periphery.environment = lib.mkMerge [
148-
(lib.mkIf usePasskey {
149-
PERIPHERY_PASSKEYS_FILE = effectivePasskeyFile;
150-
})
151-
{
152-
DOCKER_HOST = "unix:///run/podman/podman.sock";
153-
}
154-
];
155-
156177
# Disable Docker since komodo-periphery enables it by default
157178
# We use Podman with docker-compat instead (from virtualization/podman.nix)
158179
virtualisation.docker.enable = lib.mkForce false;
@@ -168,10 +189,13 @@ _: {
168189
mode = "0400";
169190
};
170191

192+
environment.etc."komodo/periphery.toml" = lib.mkIf cfg.core.enable {
193+
text = peripheryConfigText;
194+
mode = "0400";
195+
};
196+
171197
systemd = {
172198
services = {
173-
komodo-periphery.serviceConfig.SupplementaryGroups = [ "podman" ];
174-
175199
komodo-core = lib.mkIf cfg.core.enable {
176200
description = "Komodo Core - Build and Deployment Web UI";
177201
wantedBy = [ "multi-user.target" ];
@@ -211,6 +235,7 @@ _: {
211235
tmpfiles.rules = lib.mkIf cfg.core.enable [
212236
"d /var/lib/komodo 0750 root root -"
213237
"d /var/lib/komodo/backups 0750 root root -"
238+
"d /var/lib/komodo-periphery 0750 root root -"
214239
];
215240
};
216241

@@ -224,8 +249,6 @@ _: {
224249
secrets = {
225250
komodo-passkey = lib.mkIf cfg.periphery.requirePasskey {
226251
mode = "0440";
227-
owner = "komodo-periphery";
228-
group = "komodo-periphery";
229252
};
230253

231254
komodo-db-username = {

0 commit comments

Comments
 (0)