added config file to the nix store

This commit is contained in:
Kristian Krsnik 2023-08-15 21:51:59 +02:00
parent 912b405511
commit 84f4b11b9c

View File

@ -8,6 +8,9 @@ inputs: {
cfg = config.dyn-gandi; cfg = config.dyn-gandi;
package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default; package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default;
inherit (lib) mkIf mkEnableOption mkOption types; inherit (lib) mkIf mkEnableOption mkOption types;
format = pkgs.formats.json {};
configFile = format.generate "config.json" cfg.settings;
in { in {
options.dyn-gandi = { options.dyn-gandi = {
enable = mkEnableOption "dyn-gandi"; enable = mkEnableOption "dyn-gandi";
@ -42,14 +45,14 @@ in {
environment = { environment = {
systemPackages = [package]; systemPackages = [package];
etc."dyn-gandi.json" = { # etc."dyn-gandi.json" = {
text = builtins.toJSON cfg.settings; # text = builtins.toJSON cfg.settings;
}; # };
}; };
systemd.services.dyn-gandi = mkIf (cfg.timer systemd.services.dyn-gandi = mkIf (cfg.timer
!= null) { != null) {
script = "${package}/bin/dyn_gandi"; # TODO: add config file via command line options script = "${package}/bin/dyn_gandi --config ${configFile}";
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";