1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/packaging/nix/module.nix
Steffen Vogel d455faf000 Fix REUSE compliance
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2024-02-28 02:33:22 +01:00

59 lines
1.6 KiB
Nix

# SPDX-FileCopyrightText: 2023 OPAL-RT Germany GmbH
# SPDX-License-Identifier: Apache-2.0
{
config,
lib,
pkgs,
...
}: let
cfg = config.services.villas.node;
villasNodeCfg = pkgs.writeText "villas-node.conf" (builtins.toJSON cfg.config);
in
with lib; {
options = {
services.villas.node = {
enable = mkEnableOption (lib.mdDoc "VILLASnode is a client/server application to connect simulation equipment and software.");
package = mkPackageOption pkgs "villas" {};
config = mkOption {
type = types.attrsOf types.anything;
default = {
nodes = {};
paths = [];
idle_stop = false; # Do not stop daemon because of empty paths
};
description = lib.mdDoc ''
Contents of the VILLASnode configuration file,
{file}`villas-node.json`.
See: https://villas.fein-aachen.org/docs/node/config/
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.config != null && cfg.config != {};
message = "You must provide services.villas.node.config.";
}
];
# configuration file indirection is needed to support reloading
environment.etc."villas/node.json".source = villasNodeCfg;
systemd.services.villas-node = {
description = "VILLASnode";
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${lib.getExe cfg.package} node /etc/villas/node.json";
};
};
};
}