ci.nix 4.59 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1
{
Valentin Reis's avatar
Valentin Reis committed
2
  pkgs ? import ../pin.nix {jsonpath=../nixpkgs-18.03.json;}
Valentin Reis's avatar
Valentin Reis committed
3 4 5 6
}:
let
  keys = [ (pkgs.lib.readFile keys/id_rsa_vrg.pub) ];
  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;
Valentin Reis's avatar
Valentin Reis committed
9 10 11 12 13 14
in
  {
    network.description = "argo-ci";
    network.enableRollback = false;

    main =
Valentin Reis's avatar
Valentin Reis committed
15
    { config, ... }:
Valentin Reis's avatar
Valentin Reis committed
16
    {
Valentin Reis's avatar
Valentin Reis committed
17
      require=argomodules;
18 19 20
      environment.argo.known-hosts.enable=true;
      environment.argo.provider-tacc.enable=true;
      environment.argo.root-access.enable=true;
Valentin Reis's avatar
Valentin Reis committed
21

22
      imports = [ "${hydraSrc}/hydra-module.nix" ];
Valentin Reis's avatar
Valentin Reis committed
23 24
      networking = {
        firewall = {
25
          allowedTCPPorts=[ config.services.hydra.port ];
Valentin Reis's avatar
Valentin Reis committed
26 27 28 29 30 31
        };
      };

      deployment.targetEnv = "none";
      deployment.targetHost = "129.114.111.116";

Valentin Reis's avatar
Valentin Reis committed
32 33 34 35 36 37 38 39 40 41 42 43
      i18n.defaultLocale = "en_US.UTF-8";
      services.ntp.enable = false;
      services.openssh.allowSFTP = false;

      assertions = pkgs.lib.singleton {
        assertion = pkgs.system == "x86_64-linux";
        message = "unsupported system ${pkgs.system}";
      };

      environment.etc = pkgs.lib.singleton {
        target = "nix/id_buildfarm";
        source = keys/id_buildfarm;
Valentin Reis's avatar
Valentin Reis committed
44 45 46
        uid = config.users.users.hydra-queue-runner.uid;
        gid = config.users.groups.hydra.gid;
        mode = "0600";
Valentin Reis's avatar
Valentin Reis committed
47 48 49 50 51 52 53
      };

      nix = {
        useChroot = true;
        nrBuildUsers = 30;
        distributedBuilds = true;
        buildMachines = [
Valentin Reis's avatar
Valentin Reis committed
54 55 56 57 58 59 60 61
          { hostName = "129.114.111.114";
            maxJobs = 10;
            speedFactor = 1;
            sshKey = "/etc/nix/id_buildfarm";
            sshUser = "root";
            systems = ["builtin" "x86_64-linux" "i686-linux"];
            supportedFeatures = [ "nixos-test" "benchmark" ];
          }
Valentin Reis's avatar
Valentin Reis committed
62 63 64 65 66
        ];
        extraOptions = "auto-optimise-store = true";
      };

      services.hydra = {
Valentin Reis's avatar
Valentin Reis committed
67
        useSubstitutes = true;
Valentin Reis's avatar
Valentin Reis committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
        enable = true;
        hydraURL = "http://129.114.111.116";
        notificationSender = "hydra@example.org";
        port = 8080;
        extraConfig = "binary_cache_secret_key_file = /etc/nix/hydra.example.org-1/secret";
        buildMachinesFiles = [ "/etc/nix/machines" ];
      };

      services.postgresql = {
        package = pkgs.postgresql94;
        dataDir = "/var/db/postgresql-${config.services.postgresql.package.psqlSchema}";
      };

      systemd.services.hydra-manual-setup = {
        description = "Create Admin User for Hydra";
        serviceConfig.Type = "oneshot";
        serviceConfig.RemainAfterExit = true;
        wantedBy = [ "multi-user.target" ];
        requires = [ "hydra-init.service" ];
        after = [ "hydra-init.service" ];
        environment = config.systemd.services.hydra-init.environment;
        script = ''
          if [ ! -e ~hydra/.setup-is-complete ]; then
            # create admin user
Valentin Reis's avatar
Valentin Reis committed
92 93
            /run/current-system/sw/bin/hydra-create-user fre --full-name 'Valentin Reis' --email-address 'fre@freux.fr' --password foobar --role admin
            /run/current-system/sw/bin/hydra-create-user swann --full-name 'Swann Perarnau' --email-address 'swann@anl.gov' --password swannswann --role admin
Valentin Reis's avatar
Valentin Reis committed
94 95 96 97 98 99 100 101 102 103 104
            # create signing keys
            /run/current-system/sw/bin/install -d -m 551 /etc/nix/hydra.example.org-1
            /run/current-system/sw/bin/nix-store --generate-binary-cache-key hydra.example.org-1 /etc/nix/hydra.example.org-1/secret /etc/nix/hydra.example.org-1/public
            /run/current-system/sw/bin/chown -R hydra:hydra /etc/nix/hydra.example.org-1
            /run/current-system/sw/bin/chmod 440 /etc/nix/hydra.example.org-1/secret
            /run/current-system/sw/bin/chmod 444 /etc/nix/hydra.example.org-1/public
            # done
            touch ~hydra/.setup-is-complete
          fi
        '';
      };
Valentin Reis's avatar
Valentin Reis committed
105
     };
Valentin Reis's avatar
Valentin Reis committed
106 107

    slave1 =
Valentin Reis's avatar
Valentin Reis committed
108
    { ... }:
Valentin Reis's avatar
Valentin Reis committed
109 110 111 112
    {
      deployment.targetEnv = "none";
      deployment.targetHost = "129.114.111.114";

113 114 115 116
      require=argomodules;
      environment.argo.known-hosts.enable=true;
      environment.argo.provider-tacc.enable=true;
      environment.argo.root-access.enable=true;
Valentin Reis's avatar
Valentin Reis committed
117 118 119 120 121 122 123 124 125 126 127 128 129

      i18n.defaultLocale = "en_US.UTF-8";
      nix.useChroot = true;
      nix.nrBuildUsers = 30;
      services.ntp.enable = false;
      services.openssh.allowSFTP = false;

      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 }')))"'';
      };

130
      services.openssh.enable = true;
Valentin Reis's avatar
Valentin Reis committed
131
      users.extraUsers.root.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
Valentin Reis's avatar
Valentin Reis committed
132
     };
Valentin Reis's avatar
Valentin Reis committed
133
   }