From 94b05b143762e436e6f5342ce12d899cf5a26ba2 Mon Sep 17 00:00:00 2001 From: Lucas Bergman Date: Tue, 20 Feb 2024 07:58:03 -0600 Subject: [PATCH] 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. --- flake.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 245c5b1..86b27e7 100644 --- a/flake.nix +++ b/flake.nix @@ -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}"; }; }; };