This commit is contained in:
Aubrey 2025-01-26 13:15:34 -06:00
parent 08664b4309
commit 6d8767d93b
No known key found for this signature in database

View file

@ -30,49 +30,53 @@
with pkgs; { with pkgs; {
formatter = alejandra; formatter = alejandra;
defaultPackage = pkgs.callPackage ./. {}; defaultPackage = pkgs.callPackage ./. {};
nixosModules.default = { }
config, )
lib, // flake-utils.lib.eachDefaultSystemPassThrough (system: {
pkgs, nixosModules.default = {
... config,
}: { lib,
options.services.wanireminder = { pkgs,
enable = lib.mkEnableOption "wanikani reminder bot"; ...
webhook = lib.mkOption { }: {
options.services.wanireminder = {
enable = lib.mkEnableOption "wanikani reminder bot";
webhook = lib.mkOption {
type = lib.types.string;
description = "The webhook to post the messages to";
};
users =
lib.mkOption {
type = lib.types.listOf lib.types.attrs;
}
// {
name = lib.mkOption {
type = lib.types.string; type = lib.types.string;
description = "The webhook to post the messages to";
}; };
users = lib.mkOption { wktoken = lib.mkOption {
type = lib.types.listOf lib.types.attrs; type = lib.types.string;
} // { };
name = lib.mkOption { discord = lib.mkOption {
type = lib.types.string; type = lib.types.string;
};
wktoken = lib.mkOption {
type = lib.types.string;
};
discord = lib.mkOption {
type = lib.types.string;
};
}; };
}; };
config = lib.mkIf config.services.wanireminder.enable { };
systemd.services.wanireminder = { config = lib.mkIf config.services.wanireminder.enable {
wantedBy = ["multi-user.target"]; systemd.services.wanireminder = {
after = ["network.target"]; wantedBy = ["multi-user.target"];
description = "Run wanireminders"; after = ["network.target"];
serviceConfig = { description = "Run wanireminders";
WorkingDirectory = "${self.defaultPackage.${system}}"; serviceConfig = {
Type = "oneshot"; WorkingDirectory = "${self.defaultPackage.${system}}";
OnCalendar = "hourly"; Type = "oneshot";
Persistent = true; OnCalendar = "hourly";
ExecStart = let Persistent = true;
configJson = builtins.toFile "config.json" (builtins.toJSON config.services.wanireminder); ExecStart = let
in ''${self.defaultPackage.${system}}/bin/wanireminder ${configJson}''; configJson = builtins.toFile "config.json" (builtins.toJSON config.services.wanireminder);
}; in ''${self.defaultPackage.${system}}/bin/wanireminder ${configJson}'';
};
}; };
}; };
} };
); };
});
} }