maint: NixOS module writes config to the Nix store

Instead of writing the config attrset to a YAML file to a fixed path in /etc,
this makes the NixOS module write to a (content-addressed) config file in the
Nix store. We just use builtins.toJSON since YAML is a superset of JSON.
This commit is contained in:
Lucas Bergman 2024-02-20 07:58:03 -06:00
parent 668015ed17
commit 94b05b1437

View File

@ -112,11 +112,9 @@
config = let
cfg = config.services.heracles;
cfgFile = pkgs.writeText "heracles.yaml" (builtins.toJSON cfg.settings);
in
lib.mkIf cfg.enable {
environment.etc."heracles.yaml" = {
text = lib.generators.toYAML {} cfg.settings;
};
systemd.services.heracles = {
wantedBy = ["multi-user.target" "default.target"];
wants = ["network.target"];
@ -124,7 +122,7 @@
serviceConfig = {
Restart = "on-failure";
RestartSec = "30s";
ExecStart = "${pkgs.heracles}/bin/heracles --listen ${cfg.listen} --config=${config.environment.etc."heracles.yaml".target}";
ExecStart = "${pkgs.heracles}/bin/heracles --listen ${cfg.listen} --config=${cfgFile}";
};
};
};