ci.nix 5.97 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 9 10 11 12 13
in
  {
    network.description = "argo-ci";
    network.enableRollback = false;

    main =
Valentin Reis's avatar
Valentin Reis committed
14
    { config, ... }:
Valentin Reis's avatar
Valentin Reis committed
15 16 17
    {
      imports = [
        ./providers/openstack-tacc.nix
Valentin Reis's avatar
Valentin Reis committed
18
        "${hydraSrc}/hydra-module.nix"
Valentin Reis's avatar
Valentin Reis committed
19 20 21 22
      ];

      networking = {
        firewall = {
Valentin Reis's avatar
Valentin Reis committed
23 24
          allowedTCPPorts=[ 22 config.services.hydra.port ];
          allowedUDPPorts=[ 22 ];
Valentin Reis's avatar
Valentin Reis committed
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
        };
      };

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

      users.extraUsers.fre = {
        isNormalUser = true;
        extraGroups= ["wheel"];
        openssh.authorizedKeys.keys = keys;
      };

      services.openssh.enable = true;
      services.openssh.passwordAuthentication = false;
      users.users.root.openssh.authorizedKeys.keys = keys ;

      systemd.services = {
         ## nova-config.nix disables these via profiles/headless.nix
         "serial-getty@ttyS0".enable = pkgs.lib.mkForce true;
         "getty@tty1".enable = pkgs.lib.mkForce true;
         ## For some reason, getty@.service is missing
         ## a dependency on the getty.target.
         "getty@tty1".wantedBy = [ "getty.target" ];
       };

       boot.kernelParams = [ "console=tty1" ];
       boot.kernelPackages = pkgs.linuxPackages_latest;
Valentin Reis's avatar
Valentin Reis committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65

      i18n.defaultLocale = "en_US.UTF-8";
      services.nixosManual.showManual = false;
      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
66 67 68
        uid = config.users.users.hydra-queue-runner.uid;
        gid = config.users.groups.hydra.gid;
        mode = "0600";
Valentin Reis's avatar
Valentin Reis committed
69 70 71 72 73 74 75
      };

      nix = {
        useChroot = true;
        nrBuildUsers = 30;
        distributedBuilds = true;
        buildMachines = [
Valentin Reis's avatar
Valentin Reis committed
76 77 78 79 80 81 82 83
          { 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
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 127 128 129 130
        ];
        extraOptions = "auto-optimise-store = true";
      };

      services.hydra = {
        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
            /run/current-system/sw/bin/hydra-create-user alice --full-name 'Alice Q. User' --email-address 'alice@example.org' --password foobar --role admin
            # 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
        '';
      };

      #users.users.hydra-www.uid = config.ids.uids.hydra-www;
      #users.users.hydra-queue-runner.uid = config.ids.uids.hydra-queue-runner;
      #users.users.hydra.uid = config.ids.uids.hydra;
      #users.groups.hydra.gid = config.ids.gids.hydra;

Valentin Reis's avatar
Valentin Reis committed
131
     };
Valentin Reis's avatar
Valentin Reis committed
132 133 134


    slave1 =
Valentin Reis's avatar
Valentin Reis committed
135
    {  ... }:
Valentin Reis's avatar
Valentin Reis committed
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
    {
      imports = [
        ./providers/openstack-tacc.nix
      ];

      networking = {
        firewall = {
          allowedTCPPorts=[ 22 ];
          allowedUDPPorts=[ 22 ];
        };
      };

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

      users.extraUsers.fre = {
        isNormalUser = true;
        extraGroups= ["wheel"];
        openssh.authorizedKeys.keys = keys;
      };

      services.openssh.enable = true;
      services.openssh.passwordAuthentication = false;
      users.users.root.openssh.authorizedKeys.keys = keys ;

      systemd.services = {
         "serial-getty@ttyS0".enable = pkgs.lib.mkForce true;
         "getty@tty1".enable = pkgs.lib.mkForce true;
         "getty@tty1".wantedBy = [ "getty.target" ];
       };

       boot.kernelParams = [ "console=tty1" ];
       boot.kernelPackages = pkgs.linuxPackages_latest;

      i18n.defaultLocale = "en_US.UTF-8";
      nix.useChroot = true;
      nix.nrBuildUsers = 30;
      services.nixosManual.showManual = false;
      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 }')))"'';
      };

Valentin Reis's avatar
Valentin Reis committed
184
      users.extraUsers.root.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
Valentin Reis's avatar
Valentin Reis committed
185
     };
Valentin Reis's avatar
Valentin Reis committed
186
   }