2018-10-23 22:24:13 +02:00
|
|
|
{lib, config, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.auto-pr;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.auto-pr = {
|
|
|
|
enable = mkEnableOption "Cron job PR mise à jour automatique";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.services.auto-pr-bot = {
|
|
|
|
description = "Création d'un PR si mise à jour";
|
|
|
|
requires = ["network-online.target"];
|
|
|
|
environment = { HOME = "/var/lib/auto-pr-bot"; };
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
CacheDirectory = "auto-pr-bot";
|
|
|
|
StateDirectory = "auto-pr-bot";
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = with pkgs;
|
|
|
|
let env = python3Packages.python.buildEnv.override {
|
|
|
|
extraLibs = [ python3Packages.PyGithub python3Packages.pyjwt python3Packages.colorama ];
|
|
|
|
ignoreCollisions = true;
|
|
|
|
};
|
|
|
|
in "${pkgs.writeShellScriptBin "run.sh" ''
|
2019-10-22 00:33:29 +02:00
|
|
|
${env}/bin/python ${pkgs.writeScript "pr-autobot.py" "${readFile ./pr-autobot.py}"} --private-key /var/lib/auto-pr-bot/private-key.pem --app-id 19565 --installation-id 407088 --repo nyanloutre/nixpkgs --cache-dir /var/cache/auto-pr-bot --version 19.09
|
2018-10-23 22:24:13 +02:00
|
|
|
''}/bin/run.sh";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.timers.auto-pr-bot = {
|
|
|
|
description = "Timer auto PR bot";
|
|
|
|
requires = ["network-online.target"];
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
timerConfig = { OnCalendar = "daily"; Unit = "auto-pr-bot.service"; };
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|