Rewrite
This commit is contained in:
@ -2,17 +2,16 @@ inputs: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
cfg = config.testdata;
|
||||
cfg = config.services.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 = {
|
||||
options.services.testdata = {
|
||||
enable = mkEnableOption "testdata";
|
||||
|
||||
settings = mkOption {
|
||||
@ -29,7 +28,17 @@ in {
|
||||
]);
|
||||
in
|
||||
valueType;
|
||||
default = throw "Please specify testdata.settings";
|
||||
default = throw "Please specify services.testdata.settings";
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
default = throw "Please specify a services.testdata.port";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.int;
|
||||
default = throw "Please specify a services.testdata.port";
|
||||
};
|
||||
};
|
||||
|
||||
@ -41,7 +50,7 @@ in {
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${package}/bin/testdata --config ${configFile}";
|
||||
ExecStart = "${package}/bin/testdata --config ${configFile} --listen ${cfg.host} --port ${builtins.toString cfg.port}";
|
||||
};
|
||||
|
||||
wantedBy = ["multi-user.target"];
|
||||
|
Reference in New Issue
Block a user