summaryrefslogtreecommitdiff
path: root/modules/flake/ci.nix
blob: a8dd0c8a0f238dce16a369bd409bf69d29ad8a09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
  config,
  inputs,
  myLib,
  self,
  withSystem,
  ...
}: let
  mkUpdateEffect = herculesCI: inputs: pullRequestTitle: let
    cfg = config.hercules-ci.flake-update;
  in
    withSystem cfg.effect.system ({hci-effects, ...}:
      hci-effects.flakeUpdate {
        gitRemote = herculesCI.config.repo.remoteHttpUrl;
        user = "x-access-token";
        autoMergeMethod = "rebase";
        commitSummary = pullRequestTitle;
        inherit pullRequestTitle inputs;
        inherit (cfg) updateBranch forgeType createPullRequest pullRequestBody;
      });
in {
  imports = [
    inputs.hercules-ci-effects.flakeModule
  ];

  herculesCI = {lib, ...} @ herculesCI: let
    inherit (lib) mkForce;
    ciSystems = [
      "x86_64-linux"
      "aarch64-linux"
    ];
  in {
    inherit ciSystems;

    onPush = {
      default = {
        outputs = with (myLib.ci ciSystems);
          mkForce {
            apps = mkCompatibleApps self.apps;
            checks = mkCompatible self.checks;
            devShells = mkCompatible self.devShells;
            formatter = mkCompatibleFormatters self.formatter;
            # disabled to save storage
            #homeConfigurations = mkCompatibleHM self.homeConfigurations;
            hosts = mkCompatibleCfg' self.nixosConfigurations;
          };
      };
    };

    onSchedule = let
      mkUpdateEffect' = mkUpdateEffect herculesCI;
    in {
      nixpkgs-update = {
        when = {
          hour = [0];
          minute = 0;
        };

        outputs = {
          effects.nixpkgs-update = mkUpdateEffect' ["nixpkgs" "nixpkgs-stable"] "flake: update nixpkgs inputs";
        };
      };

      flake-update = mkForce {
        when = {
          dayOfMonth = [1 8 15 22 29];
          hour = [0];
          minute = 0;
        };

        outputs = {
          effects.flake-update = mkUpdateEffect' [] "flake: update all inputs";
        };
      };
    };
  };
}