2024-06-25 04:04:39 +03:00
|
|
|
{ container, pkgsJobber, poetry2nixJobber, lib, config, ... }: with lib; let
|
|
|
|
cfg = config.container.module.jobber;
|
2024-06-09 23:35:53 +03:00
|
|
|
script = import ./jobber { poetry2nix = poetry2nixJobber; pkgs = pkgsJobber; };
|
|
|
|
in {
|
2024-06-25 04:04:39 +03:00
|
|
|
options = {
|
|
|
|
container.module.jobber = {
|
|
|
|
enable = mkEnableOption "Button pusher Stanley.";
|
|
|
|
address = mkOption {
|
|
|
|
default = "10.1.0.32";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
storage = mkOption {
|
|
|
|
default = "${config.container.storage}/jobber";
|
|
|
|
type = types.str;
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
|
|
|
};
|
2024-06-25 04:04:39 +03:00
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.tmpfiles.rules = container.mkContainerDir cfg [
|
|
|
|
"data"
|
|
|
|
];
|
2024-06-09 23:35:53 +03:00
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
containers.jobber = container.mkContainer cfg {
|
|
|
|
bindMounts = {
|
|
|
|
"/data" = {
|
|
|
|
hostPath = "${cfg.storage}/data";
|
|
|
|
isReadOnly = true;
|
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
|
|
|
|
2024-06-25 04:04:39 +03:00
|
|
|
enableTun = true;
|
|
|
|
|
|
|
|
config = { lib, ... }: let
|
|
|
|
packages = [ script ] ++ (with pkgsJobber; [
|
|
|
|
firefox
|
|
|
|
geckodriver
|
|
|
|
openvpn
|
|
|
|
python311
|
|
|
|
]);
|
|
|
|
in container.mkContainerConfig cfg {
|
|
|
|
networking = lib.mkForce {
|
|
|
|
nameservers = [
|
|
|
|
"10.9.0.5"
|
|
|
|
];
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
2024-06-25 04:04:39 +03:00
|
|
|
|
|
|
|
systemd.services.jobber = {
|
|
|
|
description = "My job is pushing the button.";
|
|
|
|
enable = true;
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = packages;
|
|
|
|
environment = {
|
|
|
|
PYTHONUNBUFFERED = "1";
|
|
|
|
PYTHONDONTWRITEBYTECODE = "1";
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${script}/bin/jobber -u";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|