modules now working

This commit is contained in:
Kristian Krsnik 2023-08-13 14:00:02 +02:00
parent b5ab25940a
commit b3a5e6ce46
2 changed files with 15 additions and 20 deletions

View File

@ -4,11 +4,11 @@ self: {
pkgs, pkgs,
... ...
}: let }: let
cfg = config.services.dyn-gandi; cfg = config.dyn-gandi;
package = self.packages.${pkgs.stdenv.hostPlatform.system}.default; package = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
inherit (lib) mkIf mkEnableOption mkOption types; inherit (lib) mkIf mkEnableOption mkOption types;
in { in {
options.services.dyn-gandi = { options.dyn-gandi = {
enable = mkEnableOption "dyn-gandi"; enable = mkEnableOption "dyn-gandi";
timer = lib.mkOption { timer = lib.mkOption {
@ -33,7 +33,7 @@ in {
]); ]);
in in
valueType; valueType;
default = throw "Please specify services.dyn-gandi.settings"; default = throw "Please specify dyn-gandi.settings";
}; };
}; };

View File

@ -1,15 +1,15 @@
self: { inputs: {
config, config,
lib, lib,
pkgs, pkgs,
system, system,
... ...
}: let }: let
cfg = config.services.dyn-gandi; cfg = config.dyn-gandi;
package = 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;
in { in {
options.services.dyn-gandi = { options.dyn-gandi = {
enable = mkEnableOption "dyn-gandi"; enable = mkEnableOption "dyn-gandi";
timer = lib.mkOption { timer = lib.mkOption {
@ -34,37 +34,32 @@ in {
]); ]);
in in
valueType; valueType;
default = throw "Please specify services.dyn-gandi.settings"; default = throw "Please specify dyn-gandi.settings";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment = { environment = {
systemPackages = [package]; systemPackages = [package];
}; # TODO: make this architecture independent
xdg.configFile."dyn-gandi/config.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) {
Unit = { script = "${package}/bin/dyn_gandi"; # TODO: add config file via command line options
After = ["network.target"];
};
Install = {WantedBy = ["default.target"];}; serviceConfig = {
Service = {
Type = "oneshot"; Type = "oneshot";
ExecStart = "${package}/bin/dyn_gandi"; # TODO: add config file via command line options
}; };
}; };
systemd.timers.dyn-gandi = mkIf (cfg.timer systemd.timers.dyn-gandi = mkIf (cfg.timer
!= null) { != null) {
Install = {WantedBy = ["timers.target"];}; wantedBy = ["timers.target"];
Timer = { timerConfig = {
OnBootSec = "0s"; OnBootSec = "0s";
OnUnitActiveSec = "${toString cfg.timer}s"; OnUnitActiveSec = "${toString cfg.timer}s";
Unit = "dyn-gandi.service"; Unit = "dyn-gandi.service";