self: { config, lib, pkgs, ... }: let cfg = config.services.dyn-gandi; inherit (lib) mkIf mkEnableOption mkOption types; in { options.services.dyn-gandi = { enable = mkEnableOption "dyn-gandi"; timer = lib.mkOption { type = lib.types.int; default = 0; description = lib.mdDoc '' The time intervall in seconds the script should be repeated. 0 disables automatic starts. ''; }; settings = mkOption { type = with types; let valueType = nullOr (oneOf [ bool int float str path (attrsOf valueType) (listOf valueType) ]); in valueType; default = {api = {"example.com" = ["@" "www"];};}; example = { General = { disabledTrayIcon = true; showStartupLaunchMessage = false; }; }; description = ''''; }; }; config = mkIf cfg.enable { home.packages = [self.packages.x86_64-linux.default]; xdg.configFile."dyn-gandi/config.json" = { text = builtins.toJSON cfg.settings; }; systemd.user.services.dyn-gandi = mkIf cfg.timer != 0 { Unit = { Description = "DNS Updater tool for Gandi.net"; After = ["graphical-session-pre.target"]; PartOf = ["graphical-session.target"]; }; }; systemd.user.timers.dyn-gandi = { wantedBy = ["timers.target"]; timerConfig = { OnBootSec = "0s"; OnUnitActiveSec = "${cfg.timer}s"; Unit = "dyn-gandi.service"; }; }; }; }