ci.nix 5.02 KB
Newer Older
Valentin Reis's avatar
stub ci    
Valentin Reis committed
1
{
2
  pkgs ? import ../pin.nix {jsonpath=../nixpkgs-unstable.json;}
Valentin Reis's avatar
stub ci    
Valentin Reis committed
3
4
}:
let
5
  keys = [ (pkgs.lib.readFile keys/id_rsa_swann.pub) (pkgs.lib.readFile keys/id_rsa_vrg.pub) ];
Valentin Reis's avatar
stub ci    
Valentin Reis committed
6
  argopkgs = import ../pkgs {};
Valentin Reis's avatar
Valentin Reis committed
7
  hydraSrc = builtins.fetchTarball https://github.com/nixos/hydra/archive/master.tar.gz;
Valentin Reis's avatar
Valentin Reis committed
8
  argomodules = import ../modules/module-list.nix;
9
  mkChameleonRunner = ip: name:
10
11
12
13
14
15
16
  { ... }:
  {
    deployment.targetEnv = "none";
    deployment.targetHost = ip;

    imports = [ ./gitlab-runner.nix];

Valentin Reis's avatar
Valentin Reis committed
17
18
19
20
21
22
23
24
25
    time.timeZone = "America/Chicago";

    deployment.keys."id_buildfarm" = {
      destDir = "/run";
      keyFile = ./keys/id_buildfarm.secret;
      user = "fre";
      group = "users";
      permissions = "600";
    };
26

Valentin Reis's avatar
Valentin Reis committed
27
28
29
30
31
32
33
    deployment.keys."gitlab.cfg" = {
      destDir = "/run";
      keyFile = ./keys/gitlab.cfg.secret;
      user = "fre";
      group = "users";
      permissions = "600";
    };
34
35
36
37
38
39
40
41
42
43
44

    require=argomodules;
    environment.argo.known-hosts.enable=true;
    environment.argo.provider-tacc.enable=true;
    environment.argo.root-access.enable=true;
    environment.argo.ssh-config.enable=true;

    environment.variables.TERM = "xterm";

    i18n.defaultLocale = "en_US.UTF-8";
    nix.useSandbox = true;
Valentin Reis's avatar
various    
Valentin Reis committed
45
    nix.nrBuildUsers = 1;
46
47
48
49
50
51
52
53
54
55
    nix.trustedUsers=["root" "fre" ];

    services.ntp.enable = false;
    services.openssh.allowSFTP = false;

    environment.systemPackages = [ pkgs.git ];

    virtualisation.docker.enable = true;

    services.gitlab-runner2.enable = true;
56
    services.gitlab-runner2.name = name;
57
58
59
60
61
62
63
64
65
66
67
68
    services.gitlab-runner2.registrationConfigFile = "/run/gitlab.cfg";
    services.gitlab-runner2.packages = [pkgs.bash pkgs.docker-machine pkgs.shadow pkgs.git];

    nix.gc = {
      automatic = true;
      dates = "05:15";
      options = ''--max-freed "$((32 * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | ${pkgs.gawk}/bin/awk '{ print $4 }')))"'';
    };
   services.openssh.enable = true;
   users.extraUsers.root.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
   users.extraUsers.fre.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
   };
Valentin Reis's avatar
stub ci    
Valentin Reis committed
69
70
71
72
73
in
  {
    network.description = "argo-ci";
    network.enableRollback = false;

74
75
76
77
    gitlab-runner-4 = mkChameleonRunner "129.114.111.114" "chameleon-129.114.111.114";
    gitlab-runner-3 = mkChameleonRunner "129.114.110.3" "chameleon-129.114.110.3";
    gitlab-runner-2 = mkChameleonRunner "129.114.111.116" "chameleon-129.114.111.116";
    gitlab-runner-1 = mkChameleonRunner "129.114.33.201" "chameleon-129.114.33.201";
Valentin Reis's avatar
Valentin Reis committed
78
    gitlab-runner-0 = mkChameleonRunner "129.114.111.64" "chameleon-129.114.111.64";
79

Valentin Reis's avatar
various    
Valentin Reis committed
80
    gitlab-runner-physical =
81
82
83
84
85
86
87
88
89
90
91
    { ... }:
    {
      deployment.targetEnv = "none";
      deployment.targetHost = "140.221.10.9";

      imports = [ ./gitlab-runner.nix];

       time.timeZone = "America/Chicago";

       deployment.keys."id_buildfarm" = {
         destDir = "/run";
Valentin Reis's avatar
Valentin Reis committed
92
         keyFile = ./keys/id_buildfarm.secret;
93
94
95
96
97
98
99
         user = "fre";
         group = "users";
         permissions = "600";
       };

       deployment.keys."gitlab.cfg" = {
         destDir = "/run";
Valentin Reis's avatar
Valentin Reis committed
100
         keyFile = ./keys/gitlab.cfg.secret;
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
127
128
129
130
131
132
         user = "fre";
         group = "users";
         permissions = "600";
       };

       systemd.services.tunnel-hydra= {
         path = [pkgs.autossh];
         enable= true;
         description = "ssh tunnel to hydra";
         after = [];
         wantedBy = [ "multi-user.target" ];
         environment.AUTOSSH_GATETIME="0";
         environment.AUTOSSH_POLL="30";
         serviceConfig = {
           User = "fre";
           Restart = "on-success";
           Type = "simple";
           ExecStart = ''
             ${pkgs.autossh}/bin/autossh -M 0 -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -T -R 2210:localhost:22 fre@argo.freux.fr -i /run/id_buildfarm
          '';
         };
       };

      require=argomodules;
      environment.argo.known-hosts.enable=true;
      environment.argo.provider-openspace.enable=true;
      environment.argo.root-access.enable=true;

      environment.variables.TERM = "xterm";

      i18n.defaultLocale = "en_US.UTF-8";
      nix.useSandbox = true;
Valentin Reis's avatar
various    
Valentin Reis committed
133
      nix.nrBuildUsers = 2;
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
      nix.trustedUsers=["root" "fre" ];

      services.ntp.enable = false;
      services.openssh.allowSFTP = false;

      environment.systemPackages = [ pkgs.git ];

      virtualisation.docker.enable = true;

      services.gitlab-runner2.enable = true;
      services.gitlab-runner2.registrationConfigFile = "/run/gitlab.cfg";
      services.gitlab-runner2.packages = [pkgs.bash pkgs.docker-machine pkgs.shadow pkgs.git];

      nix.gc = {
        automatic = true;
        dates = "05:15";
        options = ''--max-freed "$((32 * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | ${pkgs.gawk}/bin/awk '{ print $4 }')))"'';
      };
     services.openssh.enable = true;
     users.extraUsers.root.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
     users.extraUsers.fre.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
     };
   }