nix/container/Jobber.nix

80 lines
1.5 KiB
Nix
Raw Normal View History

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