51 lines
1.1 KiB
Nix
51 lines
1.1 KiB
Nix
inputs: {
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
system,
|
|
...
|
|
}: let
|
|
cfg = config.testdata;
|
|
package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
inherit (lib) mkIf mkEnableOption mkOption types;
|
|
|
|
format = pkgs.formats.json {};
|
|
configFile = format.generate "config.json" cfg.settings;
|
|
in {
|
|
options.testdata = {
|
|
enable = mkEnableOption "testdata";
|
|
|
|
settings = mkOption {
|
|
type = with types; let
|
|
valueType = nullOr (oneOf [
|
|
# TODO: restrict type to actual config file structure
|
|
bool
|
|
int
|
|
float
|
|
str
|
|
path
|
|
(attrsOf valueType)
|
|
(listOf valueType)
|
|
]);
|
|
in
|
|
valueType;
|
|
default = throw "Please specify testdata.settings";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
environment.systemPackages = [package];
|
|
|
|
systemd.services.testdata = {
|
|
enable = true;
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
ExecStart = "${package}/bin/testdata --config ${configFile}";
|
|
};
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
};
|
|
};
|
|
}
|