ci.nix 6.12 KB
Newer Older
Valentin Reis's avatar
stub ci  
Valentin Reis committed
1
{
Valentin Reis's avatar
ci fix  
Valentin Reis committed
2
  pkgs ? import ../pin.nix {jsonpath=../nixpkgs-18.03.json;}
Valentin Reis's avatar
stub ci  
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
stub ci  
Valentin Reis committed
9 10 11 12 13 14
in
  {
    network.description = "argo-ci";
    network.enableRollback = false;

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

Valentin Reis's avatar
Valentin Reis committed
23 24
      environment.argo.known_hosts.enable=true;

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

      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
56 57 58 59 60 61 62 63 64 65 66 67 68 69

      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
ci fix  
Valentin Reis committed
70 71 72
        uid = config.users.users.hydra-queue-runner.uid;
        gid = config.users.groups.hydra.gid;
        mode = "0600";
Valentin Reis's avatar
Valentin Reis committed
73 74 75 76 77 78 79
      };

      nix = {
        useChroot = true;
        nrBuildUsers = 30;
        distributedBuilds = true;
        buildMachines = [
Valentin Reis's avatar
ci fix  
Valentin Reis committed
80 81 82 83 84 85 86 87
          { 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
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 131 132 133 134
        ];
        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
135
     };
Valentin Reis's avatar
Valentin Reis committed
136 137 138


    slave1 =
Valentin Reis's avatar
Valentin Reis committed
139
    { ... }:
Valentin Reis's avatar
Valentin Reis committed
140
    {
Valentin Reis's avatar
Valentin Reis committed
141
      require=argomodules;
Valentin Reis's avatar
Valentin Reis committed
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 184 185 186 187 188
      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
ci fix  
Valentin Reis committed
189
      users.extraUsers.root.openssh.authorizedKeys.keys = [ (pkgs.lib.readFile ./keys/id_buildfarm.pub)];
Valentin Reis's avatar
Valentin Reis committed
190
     };
Valentin Reis's avatar
Valentin Reis committed
191
   }