at 16.09-beta 13 kB view raw
1{ nixpkgs ? { outPath = ./..; revCount = 56789; shortRev = "gfedcba"; } 2, stableBranch ? false 3, supportedSystems ? [ "x86_64-linux" "i686-linux" ] 4}: 5 6with import ../lib; 7 8let 9 10 version = fileContents ../.version; 11 versionSuffix = 12 (if stableBranch then "." else "pre") + "${toString nixpkgs.revCount}.${nixpkgs.shortRev}"; 13 14 forAllSystems = genAttrs supportedSystems; 15 16 importTest = fn: args: system: import fn ({ 17 inherit system; 18 } // args); 19 20 callTest = fn: args: forAllSystems (system: hydraJob (importTest fn args system)); 21 22 callSubTests = fn: args: let 23 discover = attrs: let 24 subTests = filterAttrs (const (hasAttr "test")) attrs; 25 in mapAttrs (const (t: hydraJob t.test)) subTests; 26 27 discoverForSystem = system: mapAttrs (_: test: { 28 ${system} = test; 29 }) (discover (importTest fn args system)); 30 31 # If the test is only for a particular system, use only the specified 32 # system instead of generating attributes for all available systems. 33 in if args ? system then discover (import fn args) 34 else foldAttrs mergeAttrs {} (map discoverForSystem supportedSystems); 35 36 pkgs = import nixpkgs { system = "x86_64-linux"; }; 37 38 39 versionModule = 40 { system.nixosVersionSuffix = versionSuffix; 41 system.nixosRevision = nixpkgs.rev or nixpkgs.shortRev; 42 }; 43 44 45 makeIso = 46 { module, type, maintainers ? ["eelco"], system }: 47 48 with import nixpkgs { inherit system; }; 49 50 hydraJob ((import lib/eval-config.nix { 51 inherit system; 52 modules = [ module versionModule { isoImage.isoBaseName = "nixos-${type}"; } ]; 53 }).config.system.build.isoImage); 54 55 56 makeSystemTarball = 57 { module, maintainers ? ["viric"], system }: 58 59 with import nixpkgs { inherit system; }; 60 61 let 62 63 config = (import lib/eval-config.nix { 64 inherit system; 65 modules = [ module versionModule ]; 66 }).config; 67 68 tarball = config.system.build.tarball; 69 70 in 71 tarball // 72 { meta = { 73 description = "NixOS system tarball for ${system} - ${stdenv.platform.name}"; 74 maintainers = map (x: lib.maintainers.${x}) maintainers; 75 }; 76 inherit config; 77 }; 78 79 80 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel); 81 82 83 buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix { 84 inherit system; 85 modules = [ module versionModule ] ++ singleton 86 ({ config, lib, ... }: 87 { fileSystems."/".device = mkDefault "/dev/sda1"; 88 boot.loader.grub.device = mkDefault "/dev/sda"; 89 }); 90 }).config)); 91 92 93in rec { 94 95 channel = import lib/make-channel.nix { inherit pkgs nixpkgs version versionSuffix; }; 96 97 manual = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manual); 98 manualEpub = (buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manualEpub)); 99 manpages = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manpages); 100 options = (buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux; 101 102 103 # Build the initial ramdisk so Hydra can keep track of its size over time. 104 initialRamdisk = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.initialRamdisk); 105 106 netboot.x86_64-linux = let build = (import lib/eval-config.nix { 107 system = "x86_64-linux"; 108 modules = [ 109 ./modules/installer/netboot/netboot-minimal.nix 110 versionModule 111 ]; 112 }).config.system.build; 113 in 114 pkgs.symlinkJoin { 115 name="netboot"; 116 paths=[ 117 build.netbootRamdisk 118 build.kernel 119 build.netbootIpxeScript 120 ]; 121 postBuild = '' 122 mkdir -p $out/nix-support 123 echo "file bzImage $out/bzImage" >> $out/nix-support/hydra-build-products 124 echo "file initrd $out/initrd" >> $out/nix-support/hydra-build-products 125 echo "file ipxe $out/netboot.ipxe" >> $out/nix-support/hydra-build-products 126 ''; 127 }; 128 129 iso_minimal = forAllSystems (system: makeIso { 130 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix; 131 type = "minimal"; 132 inherit system; 133 }); 134 135 iso_graphical = genAttrs [ "x86_64-linux" ] (system: makeIso { 136 module = ./modules/installer/cd-dvd/installation-cd-graphical-kde.nix; 137 type = "graphical"; 138 inherit system; 139 }); 140 141 # A variant with a more recent (but possibly less stable) kernel 142 # that might support more hardware. 143 iso_minimal_new_kernel = genAttrs [ "x86_64-linux" ] (system: makeIso { 144 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix; 145 type = "minimal-new-kernel"; 146 inherit system; 147 }); 148 149 150 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF). 151 ova = genAttrs [ "x86_64-linux" ] (system: 152 153 with import nixpkgs { inherit system; }; 154 155 hydraJob ((import lib/eval-config.nix { 156 inherit system; 157 modules = 158 [ versionModule 159 ./modules/installer/virtualbox-demo.nix 160 ]; 161 }).config.system.build.virtualBoxOVA) 162 163 ); 164 165 166 # Ensure that all packages used by the minimal NixOS config end up in the channel. 167 dummy = forAllSystems (system: pkgs.runCommand "dummy" 168 { toplevel = (import lib/eval-config.nix { 169 inherit system; 170 modules = singleton ({ config, pkgs, ... }: 171 { fileSystems."/".device = mkDefault "/dev/sda1"; 172 boot.loader.grub.device = mkDefault "/dev/sda"; 173 }); 174 }).config.system.build.toplevel; 175 preferLocalBuild = true; 176 } 177 "mkdir $out; ln -s $toplevel $out/dummy"); 178 179 180 # Provide a tarball that can be unpacked into an SD card, and easily 181 # boot that system from uboot (like for the sheevaplug). 182 # The pc variant helps preparing the expression for the system tarball 183 # in a machine faster than the sheevpalug 184 /* 185 system_tarball_pc = forAllSystems (system: makeSystemTarball { 186 module = ./modules/installer/cd-dvd/system-tarball-pc.nix; 187 inherit system; 188 }); 189 */ 190 191 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ... 192 containerTarball = forAllSystems (system: makeSystemTarball { 193 module = ./modules/virtualisation/lxc-container.nix; 194 inherit system; 195 }); 196 197 /* 198 system_tarball_fuloong2f = 199 assert builtins.currentSystem == "mips64-linux"; 200 makeSystemTarball { 201 module = ./modules/installer/cd-dvd/system-tarball-fuloong2f.nix; 202 system = "mips64-linux"; 203 }; 204 205 system_tarball_sheevaplug = 206 assert builtins.currentSystem == "armv5tel-linux"; 207 makeSystemTarball { 208 module = ./modules/installer/cd-dvd/system-tarball-sheevaplug.nix; 209 system = "armv5tel-linux"; 210 }; 211 */ 212 213 214 # Run the tests for each platform. You can run a test by doing 215 # e.g. ‘nix-build -A tests.login.x86_64-linux’, or equivalently, 216 # ‘nix-build tests/login.nix -A result’. 217 tests.avahi = callTest tests/avahi.nix {}; 218 tests.bittorrent = callTest tests/bittorrent.nix {}; 219 tests.blivet = callTest tests/blivet.nix {}; 220 tests.boot = callSubTests tests/boot.nix {}; 221 tests.boot-stage1 = callTest tests/boot-stage1.nix {}; 222 tests.cadvisor = hydraJob (import tests/cadvisor.nix { system = "x86_64-linux"; }); 223 tests.chromium = (callSubTests tests/chromium.nix { system = "x86_64-linux"; }).stable; 224 tests.cjdns = callTest tests/cjdns.nix {}; 225 tests.containers-ipv4 = callTest tests/containers-ipv4.nix {}; 226 tests.containers-ipv6 = callTest tests/containers-ipv6.nix {}; 227 tests.containers-bridge = callTest tests/containers-bridge.nix {}; 228 tests.containers-imperative = callTest tests/containers-imperative.nix {}; 229 tests.containers-extra_veth = callTest tests/containers-extra_veth.nix {}; 230 tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; }); 231 tests.dockerRegistry = hydraJob (import tests/docker-registry.nix { system = "x86_64-linux"; }); 232 tests.dnscrypt-proxy = callTest tests/dnscrypt-proxy.nix { system = "x86_64-linux"; }; 233 tests.ecryptfs = callTest tests/ecryptfs.nix {}; 234 tests.etcd = hydraJob (import tests/etcd.nix { system = "x86_64-linux"; }); 235 tests.ec2-nixops = hydraJob (import tests/ec2.nix { system = "x86_64-linux"; }).boot-ec2-nixops; 236 tests.ec2-config = hydraJob (import tests/ec2.nix { system = "x86_64-linux"; }).boot-ec2-config; 237 tests.firefox = callTest tests/firefox.nix {}; 238 tests.firewall = callTest tests/firewall.nix {}; 239 tests.fleet = hydraJob (import tests/fleet.nix { system = "x86_64-linux"; }); 240 #tests.gitlab = callTest tests/gitlab.nix {}; 241 tests.gocd-agent = callTest tests/gocd-agent.nix {}; 242 tests.gocd-server = callTest tests/gocd-server.nix {}; 243 tests.gnome3 = callTest tests/gnome3.nix {}; 244 tests.gnome3-gdm = callTest tests/gnome3-gdm.nix {}; 245 tests.grsecurity = callTest tests/grsecurity.nix {}; 246 tests.hibernate = callTest tests/hibernate.nix {}; 247 tests.i3wm = callTest tests/i3wm.nix {}; 248 tests.installer = callSubTests tests/installer.nix {}; 249 tests.influxdb = callTest tests/influxdb.nix {}; 250 tests.ipv6 = callTest tests/ipv6.nix {}; 251 tests.jenkins = callTest tests/jenkins.nix {}; 252 tests.kde4 = callTest tests/kde4.nix {}; 253 tests.keymap = callSubTests tests/keymap.nix {}; 254 tests.initrdNetwork = callTest tests/initrd-network.nix {}; 255 tests.kubernetes = hydraJob (import tests/kubernetes.nix { system = "x86_64-linux"; }); 256 tests.latestKernel.login = callTest tests/login.nix { latestKernel = true; }; 257 #tests.lightdm = callTest tests/lightdm.nix {}; 258 tests.login = callTest tests/login.nix {}; 259 #tests.logstash = callTest tests/logstash.nix {}; 260 tests.mathics = callTest tests/mathics.nix {}; 261 tests.misc = callTest tests/misc.nix {}; 262 tests.mumble = callTest tests/mumble.nix {}; 263 tests.munin = callTest tests/munin.nix {}; 264 tests.mysql = callTest tests/mysql.nix {}; 265 tests.mysqlReplication = callTest tests/mysql-replication.nix {}; 266 tests.nat.firewall = callTest tests/nat.nix { withFirewall = true; }; 267 tests.nat.standalone = callTest tests/nat.nix { withFirewall = false; }; 268 tests.networking.networkd = callSubTests tests/networking.nix { networkd = true; }; 269 tests.networking.scripted = callSubTests tests/networking.nix { networkd = false; }; 270 # TODO: put in networking.nix after the test becomes more complete 271 tests.networkingProxy = callTest tests/networking-proxy.nix {}; 272 tests.nfs3 = callTest tests/nfs.nix { version = 3; }; 273 tests.nfs4 = callTest tests/nfs.nix { version = 4; }; 274 tests.nsd = callTest tests/nsd.nix {}; 275 tests.openssh = callTest tests/openssh.nix {}; 276 tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; }); 277 tests.peerflix = callTest tests/peerflix.nix {}; 278 tests.postgresql = callTest tests/postgresql.nix {}; 279 tests.printing = callTest tests/printing.nix {}; 280 tests.proxy = callTest tests/proxy.nix {}; 281 tests.pumpio = callTest tests/pump.io.nix {}; 282 tests.quake3 = callTest tests/quake3.nix {}; 283 tests.runInMachine = callTest tests/run-in-machine.nix {}; 284 tests.sddm = callTest tests/sddm.nix {}; 285 tests.sddm-kde5 = callTest tests/sddm-kde5.nix {}; 286 tests.simple = callTest tests/simple.nix {}; 287 tests.smokeping = callTest tests/smokeping.nix {}; 288 tests.taskserver = callTest tests/taskserver.nix {}; 289 tests.tomcat = callTest tests/tomcat.nix {}; 290 tests.udisks2 = callTest tests/udisks2.nix {}; 291 tests.virtualbox = callSubTests tests/virtualbox.nix { system = "x86_64-linux"; }; 292 tests.xfce = callTest tests/xfce.nix {}; 293 294 295 /* Build a bunch of typical closures so that Hydra can keep track of 296 the evolution of closure sizes. */ 297 298 closures = { 299 300 smallContainer = makeClosure ({ pkgs, ... }: 301 { boot.isContainer = true; 302 services.openssh.enable = true; 303 }); 304 305 tinyContainer = makeClosure ({ pkgs, ... }: 306 { boot.isContainer = true; 307 imports = [ modules/profiles/minimal.nix ]; 308 }); 309 310 ec2 = makeClosure ({ pkgs, ... }: 311 { imports = [ modules/virtualisation/amazon-image.nix ]; 312 }); 313 314 kde = makeClosure ({ pkgs, ... }: 315 { services.xserver.enable = true; 316 services.xserver.displayManager.kdm.enable = true; 317 services.xserver.desktopManager.kde4.enable = true; 318 }); 319 320 xfce = makeClosure ({ pkgs, ... }: 321 { services.xserver.enable = true; 322 services.xserver.desktopManager.xfce.enable = true; 323 }); 324 325 # Linux/Apache/PostgreSQL/PHP stack. 326 lapp = makeClosure ({ pkgs, ... }: 327 { services.httpd.enable = true; 328 services.httpd.adminAddr = "foo@example.org"; 329 services.postgresql.enable = true; 330 services.postgresql.package = pkgs.postgresql93; 331 environment.systemPackages = [ pkgs.php ]; 332 }); 333 }; 334}