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