nixos/syndicate-server: use a static configuration
Configure the server with a configuration path that points into the Nix store rather than a file that is generated at start-up.
This commit is contained in:
parent
9b06320ec9
commit
847ed4ef13
22
flake.nix
22
flake.nix
|
@ -90,9 +90,25 @@
|
||||||
with import (nixpkgs + "/nixos/lib/testing-python.nix") {
|
with import (nixpkgs + "/nixos/lib/testing-python.nix") {
|
||||||
inherit system;
|
inherit system;
|
||||||
pkgs = pkgs';
|
pkgs = pkgs';
|
||||||
};
|
}; {
|
||||||
{
|
simple = simpleTest {
|
||||||
# nothing here
|
name = "http";
|
||||||
|
nodes.machine = { config, pkgs, ... }: {
|
||||||
|
imports = [ self.nixosModules.syndicate-server ];
|
||||||
|
|
||||||
|
nixpkgs.pkgs = pkgs';
|
||||||
|
|
||||||
|
services.syndicate.tty1 = {
|
||||||
|
enable = true;
|
||||||
|
user = "loser";
|
||||||
|
config = [ ];
|
||||||
|
};
|
||||||
|
users.users.loser.isNormalUser = true;
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
machine.wait_for_job("syndicate-tty1")
|
||||||
|
'';
|
||||||
|
};
|
||||||
}) { inherit (self.legacyPackages) x86_64-linux; };
|
}) { inherit (self.legacyPackages) x86_64-linux; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,31 +49,23 @@ with lib;
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
systemd.services = let
|
systemd.services = let
|
||||||
serverCfgs =
|
configure = name: cfg:
|
||||||
lib.attrsets.filterAttrs (_: cfg: cfg.enable) config.services.syndicate;
|
|
||||||
in builtins.listToAttrs (lib.lists.flatten (lib.attrsets.mapAttrsToList
|
|
||||||
(name: cfg:
|
|
||||||
let
|
let
|
||||||
configFileName = "syndicate-nixos-config.pr";
|
configFile = lib.pipe cfg.config [
|
||||||
runtimeConfig = "\${RUNTIME_DIRECTORY}/${configFileName}";
|
|
||||||
configFile = pkgs.writeText configFileName
|
|
||||||
(lib.strings.concatMapStrings (dir: ''
|
(lib.strings.concatMapStrings (dir: ''
|
||||||
<require-service <config-watcher "${dir}" $.>>
|
<require-service <config-watcher "${dir}" $.>>
|
||||||
'') cfg.config);
|
''))
|
||||||
|
(pkgs.writeText "syndicate-nixos-config.pr")
|
||||||
|
];
|
||||||
in [{
|
in [{
|
||||||
name = "syndicate-${name}";
|
name = "syndicate-${name}";
|
||||||
value = let
|
value = let
|
||||||
serviceConfig = let
|
serviceConfig = {
|
||||||
loadConfig =
|
|
||||||
"${pkgs.coreutils}/bin/cp ${configFile} ${runtimeConfig}";
|
|
||||||
in {
|
|
||||||
RuntimeDirectory = name;
|
RuntimeDirectory = name;
|
||||||
ExecStartPre = loadConfig;
|
|
||||||
ExecStart = "${
|
ExecStart = "${
|
||||||
lib.optionalString cfg.runInDbusSession
|
lib.optionalString cfg.runInDbusSession
|
||||||
"${pkgs.dbus}/bin/dbus-run-session "
|
"${pkgs.dbus}/bin/dbus-run-session "
|
||||||
}${cfg.package}/bin/syndicate-server --no-banner --config ${runtimeConfig}";
|
}${cfg.package}/bin/syndicate-server --no-banner --config ${configFile}";
|
||||||
ExecReload = loadConfig;
|
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -106,8 +98,14 @@ with lib;
|
||||||
WorkingDirectory = "~";
|
WorkingDirectory = "~";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}]) (lib.attrsets.filterAttrs (_: cfg: cfg.enable)
|
}];
|
||||||
config.services.syndicate)));
|
serverCfgs =
|
||||||
|
lib.attrsets.filterAttrs (_: cfg: cfg.enable) config.services.syndicate;
|
||||||
|
in lib.pipe serverCfgs [
|
||||||
|
(lib.attrsets.mapAttrsToList configure)
|
||||||
|
lib.lists.flatten
|
||||||
|
builtins.listToAttrs
|
||||||
|
];
|
||||||
|
|
||||||
systemd.targets.multi-user.wants = lib.lists.flatten
|
systemd.targets.multi-user.wants = lib.lists.flatten
|
||||||
(lib.attrsets.mapAttrsToList
|
(lib.attrsets.mapAttrsToList
|
||||||
|
|
Loading…
Reference in New Issue