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") {
|
||||
inherit system;
|
||||
pkgs = pkgs';
|
||||
};
|
||||
{
|
||||
# nothing here
|
||||
}; {
|
||||
simple = simpleTest {
|
||||
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; };
|
||||
};
|
||||
}
|
||||
|
|
|
@ -49,31 +49,23 @@ with lib;
|
|||
config = {
|
||||
|
||||
systemd.services = let
|
||||
serverCfgs =
|
||||
lib.attrsets.filterAttrs (_: cfg: cfg.enable) config.services.syndicate;
|
||||
in builtins.listToAttrs (lib.lists.flatten (lib.attrsets.mapAttrsToList
|
||||
(name: cfg:
|
||||
configure = name: cfg:
|
||||
let
|
||||
configFileName = "syndicate-nixos-config.pr";
|
||||
runtimeConfig = "\${RUNTIME_DIRECTORY}/${configFileName}";
|
||||
configFile = pkgs.writeText configFileName
|
||||
configFile = lib.pipe cfg.config [
|
||||
(lib.strings.concatMapStrings (dir: ''
|
||||
<require-service <config-watcher "${dir}" $.>>
|
||||
'') cfg.config);
|
||||
''))
|
||||
(pkgs.writeText "syndicate-nixos-config.pr")
|
||||
];
|
||||
in [{
|
||||
name = "syndicate-${name}";
|
||||
value = let
|
||||
serviceConfig = let
|
||||
loadConfig =
|
||||
"${pkgs.coreutils}/bin/cp ${configFile} ${runtimeConfig}";
|
||||
in {
|
||||
serviceConfig = {
|
||||
RuntimeDirectory = name;
|
||||
ExecStartPre = loadConfig;
|
||||
ExecStart = "${
|
||||
lib.optionalString cfg.runInDbusSession
|
||||
"${pkgs.dbus}/bin/dbus-run-session "
|
||||
}${cfg.package}/bin/syndicate-server --no-banner --config ${runtimeConfig}";
|
||||
ExecReload = loadConfig;
|
||||
}${cfg.package}/bin/syndicate-server --no-banner --config ${configFile}";
|
||||
User = cfg.user;
|
||||
};
|
||||
in {
|
||||
|
@ -106,8 +98,14 @@ with lib;
|
|||
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
|
||||
(lib.attrsets.mapAttrsToList
|
||||
|
|
Loading…
Reference in New Issue