From b3a5e6ce466b41a0e3262b0bf779611eca5e2fd5 Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Sun, 13 Aug 2023 14:00:02 +0200 Subject: [PATCH] modules now working --- nix/hm-module.nix | 6 +++--- nix/module.nix | 29 ++++++++++++----------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/nix/hm-module.nix b/nix/hm-module.nix index ad13477..615493e 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -4,11 +4,11 @@ self: { pkgs, ... }: let - cfg = config.services.dyn-gandi; + cfg = config.dyn-gandi; package = self.packages.${pkgs.stdenv.hostPlatform.system}.default; inherit (lib) mkIf mkEnableOption mkOption types; in { - options.services.dyn-gandi = { + options.dyn-gandi = { enable = mkEnableOption "dyn-gandi"; timer = lib.mkOption { @@ -33,7 +33,7 @@ in { ]); in valueType; - default = throw "Please specify services.dyn-gandi.settings"; + default = throw "Please specify dyn-gandi.settings"; }; }; diff --git a/nix/module.nix b/nix/module.nix index 7c54312..a0ca3fa 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -1,15 +1,15 @@ -self: { +inputs: { config, lib, pkgs, system, ... }: let - cfg = config.services.dyn-gandi; - package = self.packages.${pkgs.stdenv.hostPlatform.system}.default; + cfg = config.dyn-gandi; + package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default; inherit (lib) mkIf mkEnableOption mkOption types; in { - options.services.dyn-gandi = { + options.dyn-gandi = { enable = mkEnableOption "dyn-gandi"; timer = lib.mkOption { @@ -34,37 +34,32 @@ in { ]); in valueType; - default = throw "Please specify services.dyn-gandi.settings"; + default = throw "Please specify dyn-gandi.settings"; }; }; config = mkIf cfg.enable { environment = { systemPackages = [package]; - }; # TODO: make this architecture independent - xdg.configFile."dyn-gandi/config.json" = { - text = builtins.toJSON cfg.settings; + etc."dyn-gandi.json" = { + text = builtins.toJSON cfg.settings; + }; }; systemd.services.dyn-gandi = mkIf (cfg.timer != null) { - Unit = { - After = ["network.target"]; - }; + script = "${package}/bin/dyn_gandi"; # TODO: add config file via command line options - Install = {WantedBy = ["default.target"];}; - - Service = { + serviceConfig = { Type = "oneshot"; - ExecStart = "${package}/bin/dyn_gandi"; # TODO: add config file via command line options }; }; systemd.timers.dyn-gandi = mkIf (cfg.timer != null) { - Install = {WantedBy = ["timers.target"];}; - Timer = { + wantedBy = ["timers.target"]; + timerConfig = { OnBootSec = "0s"; OnUnitActiveSec = "${toString cfg.timer}s"; Unit = "dyn-gandi.service";