2024-10-11 23:27:07 +03:00
|
|
|
{
|
|
|
|
container,
|
|
|
|
pkgsJobber,
|
|
|
|
poetry2nixJobber,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
__findFile,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.container.module.jobber;
|
|
|
|
script = import <package/jobber> {
|
|
|
|
poetry2nix = poetry2nixJobber;
|
|
|
|
pkgs = pkgsJobber;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
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-10-11 23:27:07 +03:00
|
|
|
config = mkIf cfg.enable {
|
2024-10-14 04:51:19 +03:00
|
|
|
systemd.tmpfiles.rules = container.mkContainerDir cfg [ "data" ];
|
2024-06-09 23:35:53 +03:00
|
|
|
|
2024-10-11 23:27:07 +03:00
|
|
|
containers.jobber = container.mkContainer cfg {
|
|
|
|
bindMounts = {
|
|
|
|
"/data" = {
|
|
|
|
hostPath = "${cfg.storage}/data";
|
|
|
|
isReadOnly = true;
|
|
|
|
};
|
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
|
2024-10-11 23:27:07 +03:00
|
|
|
enableTun = true;
|
2024-06-25 04:04:39 +03:00
|
|
|
|
2024-10-11 23:27:07 +03:00
|
|
|
config =
|
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
packages =
|
|
|
|
[ script ]
|
|
|
|
++ (with pkgsJobber; [
|
|
|
|
firefox
|
|
|
|
geckodriver
|
|
|
|
openvpn
|
|
|
|
python311
|
|
|
|
]);
|
|
|
|
in
|
|
|
|
container.mkContainerConfig cfg {
|
2024-10-14 04:51:19 +03:00
|
|
|
networking = lib.mkForce { nameservers = [ "10.30.218.2" ]; };
|
2024-06-25 04:04:39 +03:00
|
|
|
|
2024-10-11 23:27:07 +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
|
|
|
}
|