1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

nix: Add option to configure config file location for villas-node

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
Steffen Vogel 2024-03-08 19:55:05 +01:00 committed by pipeacosta
parent 785fe651c2
commit 8c3a7aab01

View file

@ -17,6 +17,14 @@ in
package = mkPackageOption pkgs "villas" {};
configPath = mkOption {
type = types.nullOr types.path;
description = mdDoc ''
A path to a VILLASnode configuration file.
'';
default = null;
};
config = mkOption {
type = types.attrsOf types.anything;
default = {
@ -25,7 +33,7 @@ in
idle_stop = false; # Do not stop daemon because of empty paths
};
description = lib.mdDoc ''
description = mdDoc ''
Contents of the VILLASnode configuration file,
{file}`villas-node.json`.
@ -44,7 +52,9 @@ in
];
# configuration file indirection is needed to support reloading
environment.etc."villas/node.json".source = villasNodeCfg;
environment.etc."villas/node.json" = mkIf (builtins.isNull cfg.configPath) {
source = villasNodeCfg;
};
systemd.services.villas-node = {
description = "VILLASnode";
@ -52,7 +62,12 @@ in
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${lib.getExe cfg.package} node /etc/villas/node.json";
ExecStart = let
cfgPath =
if isNull cfg.configPath
then "/etc/villas/node.json"
else cfg.configPath;
in "${lib.getExe cfg.package} node ${cfgPath}";
};
};
};