modules now working
This commit is contained in:
parent
b5ab25940a
commit
b3a5e6ce46
@ -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";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user