clanModules/syncthing: Fix vars usage

This fixes vars usage in the syncthing module.
Also removes some of the assumptions that were made in order for
`sysuser` to work, as we now use `userborn` for the vm functionality.
This commit is contained in:
a-kenji
2025-04-23 07:40:44 +02:00
parent f8df19a128
commit 8b2a92cda0

View File

@@ -13,8 +13,8 @@
''; '';
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
example = "BABNJY4-G2ICDLF-QQEG7DD-N3OBNGF-BCCOFK6-MV3K7QJ-2WUZHXS-7DTW4AS"; example = "BABNJY4-G2ICDLF-QQEG7DD-N3OBNGF-BCCOFK6-MV3K7QJ-2WUZHXS-7DTW4AS";
default = config.clan.core.vars.services.syncthing.files."syncthing.pub".value; default = config.clan.core.vars.generators.syncthing.files."syncthing.pub".value;
defaultText = "config.clan.core.vars.services.syncthing.files.\"syncthing.pub\".value"; defaultText = "config.clan.core.vars.generators.syncthing.files.\"syncthing.pub\".value";
}; };
introducer = lib.mkOption { introducer = lib.mkOption {
description = '' description = ''
@@ -79,7 +79,6 @@
services.syncthing = { services.syncthing = {
enable = true; enable = true;
configDir = "/var/lib/syncthing";
overrideFolders = lib.mkDefault ( overrideFolders = lib.mkDefault (
if (config.clan.syncthing.introducer == null) then true else false if (config.clan.syncthing.introducer == null) then true else false
@@ -88,17 +87,13 @@
if (config.clan.syncthing.introducer == null) then true else false if (config.clan.syncthing.introducer == null) then true else false
); );
dataDir = lib.mkDefault "/home/user/"; key = lib.mkDefault config.clan.core.vars.generators.syncthing.files."syncthing.key".path or null;
cert = lib.mkDefault config.clan.core.vars.generators.syncthing.files."syncthing.cert".path or null;
group = "syncthing";
key = lib.mkDefault config.clan.secrets.syncthing.secrets."syncthing.key".path or null;
cert = lib.mkDefault config.clan.secrets.syncthing.secrets."syncthing.cert".path or null;
settings = { settings = {
options = { options = {
urAccepted = -1; urAccepted = -1;
allowedNetworks = [ config.clan.core.networking.zerotier.subnet ]; allowedNetworks = [ ];
}; };
devices = devices =
{ } { }
@@ -176,12 +171,11 @@
set -efu pipefail set -efu pipefail
APIKEY=$(cat ${apiKey}) APIKEY=$(cat ${apiKey})
${lib.getExe pkgs.gnused} -i "s/<apikey>.*<\/apikey>/<apikey>$APIKEY<\/apikey>/" /var/lib/syncthing/config.xml ${lib.getExe pkgs.gnused} -i "s/<apikey>.*<\/apikey>/<apikey>$APIKEY<\/apikey>/" ${config.services.syncthing.configDir}/config.xml
# sudo systemctl restart syncthing.service # sudo systemctl restart syncthing.service
systemctl restart syncthing.service systemctl restart syncthing.service
''; '';
serviceConfig = { serviceConfig = {
WorkingDirectory = "/var/lib/syncthing";
BindReadOnlyPaths = [ apiKey ]; BindReadOnlyPaths = [ apiKey ];
Type = "oneshot"; Type = "oneshot";
}; };
@@ -189,9 +183,12 @@
clan.core.vars.generators.syncthing = { clan.core.vars.generators.syncthing = {
migrateFact = "syncthing"; migrateFact = "syncthing";
files."syncthing.key" = { }; files."syncthing.key".group = config.services.syncthing.group;
files."syncthing.cert" = { }; files."syncthing.key".owner = config.services.syncthing.user;
files."syncthing.api" = { }; files."syncthing.cert".group = config.services.syncthing.group;
files."syncthing.cert".owner = config.services.syncthing.user;
files."syncthing.api".group = config.services.syncthing.group;
files."syncthing.api".owner = config.services.syncthing.user;
files."syncthing.pub".secret = false; files."syncthing.pub".secret = false;
runtimeInputs = [ runtimeInputs = [
pkgs.coreutils pkgs.coreutils