summaryrefslogtreecommitdiffstats
path: root/lass/2configs/repo-sync.nix
blob: 98dbdc22730fcda7cf0255c1c7a510044578bca6 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{ config, lib, pkgs, ... }:

with import <stockholm/lib>;

let
  mirror = "git@${config.networking.hostName}:";

  defineRepo = name: announce: let
    repo = {
      public = true;
      name = mkDefault "${name}";
      cgit.desc = mkDefault "mirror for ${name}";
      cgit.section = mkDefault "mirror";
      hooks = mkIf announce (mkDefault {
        post-receive = pkgs.git-hooks.irc-announce {
          nick = config.networking.hostName;
          verbose = false;
          channel = "#xxx";
          server = "irc.r";
          branches = [ "newest" ];
        };
      });
    };
  in {
    rules = with git; [
      {
        user = with config.krebs.users; [
          config.krebs.users."${config.networking.hostName}-repo-sync"
          lass
          lass-shodan
        ];
        repo = [ repo ];
        perm = push ''refs/*'' [ non-fast-forward create delete merge ];
      }
      {
        user = attrValues config.krebs.users;
        repo = [ repo ];
        perm = fetch;
      }
    ];
    repos."${name}" = repo;
  };

  sync-retiolum = name:
    {
      krebs.repo-sync.repos.${name} = {
        branches = {
          makefu = {
            origin.url = "http://cgit.gum/${name}";
            mirror.url = "${mirror}${name}";
          };
          tv = {
            origin.url = "http://cgit.ni.r/${name}";
            mirror.url = "${mirror}${name}";
          };
          nin = {
            origin.url = "http://cgit.onondaga.r/${name}";
            mirror.url = "${mirror}${name}";
          };
          lassulus = {
            origin.url = "http://cgit.lassul.us/${name}";
            mirror.url = "${mirror}${name}";
          };
        };
        latest = {
          url = "${mirror}${name}";
          ref = "heads/newest";
        };
      };
      krebs.git = defineRepo name (config.networking.hostName == "prism");
    };

  sync-remote = name: url:
    {
      krebs.repo-sync.repos.${name} = {
        branches = {
          remote = {
            origin.url = url;
            mirror.url = "${mirror}${name}";
          };
        };
      };
      krebs.git = defineRepo name (config.networking.hostName == "prism");
    };

  sync-remote-silent = name: url:
    {
      krebs.repo-sync.repos.${name} = {
        branches = {
          remote = {
            origin.url = url;
            mirror.url = "${mirror}${name}";
          };
        };
      };
      krebs.git = defineRepo name false;
    };

in {
  krebs.repo-sync = {
    enable = true;
    unitConfig.ConditionPathExists = "!/var/run/ppp0.pid";
  };
  imports = [
    (sync-remote "array" "https://github.com/makefu/array")
    (sync-remote "email-header" "https://github.com/4z3/email-header")
    (sync-remote "mycube-flask" "https://github.com/makefu/mycube-flask")
    (sync-remote "reaktor-titlebot" "https://github.com/makefu/reaktor-titlebot")
    (sync-remote "repo-sync" "https://github.com/makefu/repo-sync")
    (sync-remote "skytraq-datalogger" "https://github.com/makefu/skytraq-datalogger")
    (sync-remote "xintmap" "https://github.com/4z3/xintmap")
    (sync-remote "realwallpaper" "https://github.com/lassulus/realwallpaper")
    (sync-remote "lassulus-blog" "https://github.com/lassulus/lassulus-blog")
    (sync-remote "painload" "https://github.com/krebscode/painload")
    (sync-remote "Reaktor" "https://github.com/krebscode/Reaktor")
    (sync-remote "nixos-wiki" "https://github.com/Mic92/nixos-wiki.wiki.git")
    (sync-retiolum "go")
    (sync-retiolum "much")
    (sync-retiolum "newsbot-js")
    (sync-retiolum "populate")
    (sync-retiolum "stockholm")
    (sync-retiolum "wai-middleware-time")
    (sync-retiolum "web-routes-wai-custom")
    (sync-retiolum "xmonad-stockholm")
  ];
}