1{ nixpkgs ? { outPath = (import ../lib).cleanSource ./..; revCount = 56789; shortRev = "gfedcba"; }
2, stableBranch ? false
3, supportedSystems ? [ "x86_64-linux" "aarch64-linux" ]
4}:
5
6with import ../pkgs/top-level/release-lib.nix { inherit supportedSystems; };
7with import ../lib;
8
9let
10
11 version = fileContents ../.version;
12 versionSuffix =
13 (if stableBranch then "." else "pre") + "${toString nixpkgs.revCount}.${nixpkgs.shortRev}";
14
15 importTest = fn: args: system: import fn ({
16 inherit system;
17 } // args);
18
19 callTestOnTheseSystems = systems: fn: args: forTheseSystems systems (system: hydraJob (importTest fn args system));
20 callTest = callTestOnTheseSystems supportedSystems;
21
22 callSubTests = callSubTestsOnTheseSystems supportedSystems;
23 callSubTestsOnTheseSystems = systems: fn: args: let
24 discover = attrs: let
25 subTests = filterAttrs (const (hasAttr "test")) attrs;
26 in mapAttrs (const (t: hydraJob t.test)) subTests;
27
28 discoverForSystem = system: mapAttrs (_: test: {
29 ${system} = test;
30 }) (discover (importTest fn args system));
31
32 in foldAttrs mergeAttrs {} (map discoverForSystem (intersectLists systems supportedSystems));
33
34 pkgs = import nixpkgs { system = "x86_64-linux"; };
35
36
37 versionModule =
38 { system.nixos.versionSuffix = versionSuffix;
39 system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev;
40 };
41
42
43 makeIso =
44 { module, type, maintainers ? ["eelco"], system }:
45
46 with import nixpkgs { inherit system; };
47
48 hydraJob ((import lib/eval-config.nix {
49 inherit system;
50 modules = [ module versionModule { isoImage.isoBaseName = "nixos-${type}"; } ];
51 }).config.system.build.isoImage);
52
53
54 makeSystemTarball =
55 { module, maintainers ? ["viric"], system }:
56
57 with import nixpkgs { inherit system; };
58
59 let
60
61 config = (import lib/eval-config.nix {
62 inherit system;
63 modules = [ module versionModule ];
64 }).config;
65
66 tarball = config.system.build.tarball;
67
68 in
69 tarball //
70 { meta = {
71 description = "NixOS system tarball for ${system} - ${stdenv.platform.name}";
72 maintainers = map (x: lib.maintainers.${x}) maintainers;
73 };
74 inherit config;
75 };
76
77
78 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel);
79
80
81 buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix {
82 inherit system;
83 modules = [ module versionModule ] ++ singleton
84 ({ config, lib, ... }:
85 { fileSystems."/".device = mkDefault "/dev/sda1";
86 boot.loader.grub.device = mkDefault "/dev/sda";
87 });
88 }).config));
89
90 makeNetboot = config:
91 let
92 configEvaled = import lib/eval-config.nix config;
93 build = configEvaled.config.system.build;
94 kernelTarget = configEvaled.pkgs.stdenv.platform.kernelTarget;
95 in
96 pkgs.symlinkJoin {
97 name = "netboot";
98 paths = [
99 build.netbootRamdisk
100 build.kernel
101 build.netbootIpxeScript
102 ];
103 postBuild = ''
104 mkdir -p $out/nix-support
105 echo "file ${kernelTarget} $out/${kernelTarget}" >> $out/nix-support/hydra-build-products
106 echo "file initrd $out/initrd" >> $out/nix-support/hydra-build-products
107 echo "file ipxe $out/netboot.ipxe" >> $out/nix-support/hydra-build-products
108 '';
109 preferLocalBuild = true;
110 };
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 manualEpub = (buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manualEpub));
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 netboot = forTheseSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
127 inherit system;
128 modules = [
129 ./modules/installer/netboot/netboot-minimal.nix
130 versionModule
131 ];
132 });
133
134 iso_minimal = forAllSystems (system: makeIso {
135 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix;
136 type = "minimal";
137 inherit system;
138 });
139
140 iso_graphical = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
141 module = ./modules/installer/cd-dvd/installation-cd-graphical-kde.nix;
142 type = "graphical";
143 inherit system;
144 });
145
146 # A variant with a more recent (but possibly less stable) kernel
147 # that might support more hardware.
148 iso_minimal_new_kernel = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
149 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
150 type = "minimal-new-kernel";
151 inherit system;
152 });
153
154
155 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
156 ova = forTheseSystems [ "x86_64-linux" ] (system:
157
158 with import nixpkgs { inherit system; };
159
160 hydraJob ((import lib/eval-config.nix {
161 inherit system;
162 modules =
163 [ versionModule
164 ./modules/installer/virtualbox-demo.nix
165 ];
166 }).config.system.build.virtualBoxOVA)
167
168 );
169
170
171 # Ensure that all packages used by the minimal NixOS config end up in the channel.
172 dummy = forAllSystems (system: pkgs.runCommand "dummy"
173 { toplevel = (import lib/eval-config.nix {
174 inherit system;
175 modules = singleton ({ config, pkgs, ... }:
176 { fileSystems."/".device = mkDefault "/dev/sda1";
177 boot.loader.grub.device = mkDefault "/dev/sda";
178 });
179 }).config.system.build.toplevel;
180 preferLocalBuild = true;
181 }
182 "mkdir $out; ln -s $toplevel $out/dummy");
183
184
185 # Provide a tarball that can be unpacked into an SD card, and easily
186 # boot that system from uboot (like for the sheevaplug).
187 # The pc variant helps preparing the expression for the system tarball
188 # in a machine faster than the sheevpalug
189 /*
190 system_tarball_pc = forAllSystems (system: makeSystemTarball {
191 module = ./modules/installer/cd-dvd/system-tarball-pc.nix;
192 inherit system;
193 });
194 */
195
196 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
197 containerTarball = forAllSystems (system: makeSystemTarball {
198 module = ./modules/virtualisation/lxc-container.nix;
199 inherit system;
200 });
201
202 /*
203 system_tarball_fuloong2f =
204 assert builtins.currentSystem == "mips64-linux";
205 makeSystemTarball {
206 module = ./modules/installer/cd-dvd/system-tarball-fuloong2f.nix;
207 system = "mips64-linux";
208 };
209
210 system_tarball_sheevaplug =
211 assert builtins.currentSystem == "armv5tel-linux";
212 makeSystemTarball {
213 module = ./modules/installer/cd-dvd/system-tarball-sheevaplug.nix;
214 system = "armv5tel-linux";
215 };
216 */
217
218
219 # Run the tests for each platform. You can run a test by doing
220 # e.g. ‘nix-build -A tests.login.x86_64-linux’, or equivalently,
221 # ‘nix-build tests/login.nix -A result’.
222 tests.atd = callTest tests/atd.nix {};
223 tests.acme = callTest tests/acme.nix {};
224 tests.avahi = callTest tests/avahi.nix {};
225 tests.beegfs = callTest tests/beegfs.nix {};
226 tests.bittorrent = callTest tests/bittorrent.nix {};
227 tests.blivet = callTest tests/blivet.nix {};
228 tests.boot = callSubTests tests/boot.nix {};
229 tests.boot-stage1 = callTest tests/boot-stage1.nix {};
230 tests.borgbackup = callTest tests/borgbackup.nix {};
231 tests.buildbot = callTest tests/buildbot.nix {};
232 tests.cadvisor = callTestOnTheseSystems ["x86_64-linux"] tests/cadvisor.nix {};
233 tests.ceph = callTestOnTheseSystems ["x86_64-linux"] tests/ceph.nix {};
234 tests.chromium = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/chromium.nix {}).stable;
235 tests.cjdns = callTest tests/cjdns.nix {};
236 tests.cloud-init = callTest tests/cloud-init.nix {};
237 tests.containers-ipv4 = callTest tests/containers-ipv4.nix {};
238 tests.containers-ipv6 = callTest tests/containers-ipv6.nix {};
239 tests.containers-bridge = callTest tests/containers-bridge.nix {};
240 tests.containers-imperative = callTest tests/containers-imperative.nix {};
241 tests.containers-extra_veth = callTest tests/containers-extra_veth.nix {};
242 tests.containers-physical_interfaces = callTest tests/containers-physical_interfaces.nix {};
243 tests.containers-restart_networking = callTest tests/containers-restart_networking.nix {};
244 tests.containers-tmpfs = callTest tests/containers-tmpfs.nix {};
245 tests.containers-hosts = callTest tests/containers-hosts.nix {};
246 tests.containers-macvlans = callTest tests/containers-macvlans.nix {};
247 tests.couchdb = callTest tests/couchdb.nix {};
248 tests.docker = callTestOnTheseSystems ["x86_64-linux"] tests/docker.nix {};
249 tests.docker-tools = callTestOnTheseSystems ["x86_64-linux"] tests/docker-tools.nix {};
250 tests.docker-edge = callTestOnTheseSystems ["x86_64-linux"] tests/docker-edge.nix {};
251 tests.dovecot = callTest tests/dovecot.nix {};
252 tests.dnscrypt-proxy = callTestOnTheseSystems ["x86_64-linux"] tests/dnscrypt-proxy.nix {};
253 tests.ecryptfs = callTest tests/ecryptfs.nix {};
254 tests.etcd = callTestOnTheseSystems ["x86_64-linux"] tests/etcd.nix {};
255 tests.ec2-nixops = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/ec2.nix {}).boot-ec2-nixops;
256 tests.ec2-config = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/ec2.nix {}).boot-ec2-config;
257 tests.elk = callSubTestsOnTheseSystems ["x86_64-linux"] tests/elk.nix {};
258 tests.env = callTest tests/env.nix {};
259 tests.ferm = callTest tests/ferm.nix {};
260 tests.firefox = callTest tests/firefox.nix {};
261 tests.firewall = callTest tests/firewall.nix {};
262 tests.fleet = callTestOnTheseSystems ["x86_64-linux"] tests/fleet.nix {};
263 tests.fwupd = callTest tests/fwupd.nix {};
264 #tests.gitlab = callTest tests/gitlab.nix {};
265 tests.gitolite = callTest tests/gitolite.nix {};
266 tests.gjs = callTest tests/gjs.nix {};
267 tests.gocd-agent = callTest tests/gocd-agent.nix {};
268 tests.gocd-server = callTest tests/gocd-server.nix {};
269 tests.gnome3 = callTest tests/gnome3.nix {};
270 tests.gnome3-gdm = callTest tests/gnome3-gdm.nix {};
271 tests.grafana = callTest tests/grafana.nix {};
272 tests.graphite = callTest tests/graphite.nix {};
273 tests.hardened = callTest tests/hardened.nix { };
274 tests.hibernate = callTest tests/hibernate.nix {};
275 tests.home-assistant = callTest tests/home-assistant.nix { };
276 tests.hound = callTest tests/hound.nix {};
277 tests.hocker-fetchdocker = callTest tests/hocker-fetchdocker {};
278 tests.i3wm = callTest tests/i3wm.nix {};
279 tests.initrd-network-ssh = callTest tests/initrd-network-ssh {};
280 tests.installer = callSubTests tests/installer.nix {};
281 tests.influxdb = callTest tests/influxdb.nix {};
282 tests.ipv6 = callTest tests/ipv6.nix {};
283 tests.jenkins = callTest tests/jenkins.nix {};
284 tests.plasma5 = callTest tests/plasma5.nix {};
285 tests.plotinus = callTest tests/plotinus.nix {};
286 tests.keymap = callSubTests tests/keymap.nix {};
287 tests.initrdNetwork = callTest tests/initrd-network.nix {};
288 tests.kafka_0_9 = callTest tests/kafka_0_9.nix {};
289 tests.kafka_0_10 = callTest tests/kafka_0_10.nix {};
290 tests.kafka_0_11 = callTest tests/kafka_0_11.nix {};
291 tests.kafka_1_0 = callTest tests/kafka_1_0.nix {};
292 tests.kernel-copperhead = callTest tests/kernel-copperhead.nix {};
293 tests.kernel-latest = callTest tests/kernel-latest.nix {};
294 tests.kernel-lts = callTest tests/kernel-lts.nix {};
295 tests.kubernetes = hydraJob (import tests/kubernetes/default.nix { system = "x86_64-linux"; });
296 tests.latestKernel.login = callTest tests/login.nix { latestKernel = true; };
297 tests.ldap = callTest tests/ldap.nix {};
298 #tests.lightdm = callTest tests/lightdm.nix {};
299 tests.login = callTest tests/login.nix {};
300 #tests.logstash = callTest tests/logstash.nix {};
301 tests.mathics = callTest tests/mathics.nix {};
302 tests.matrix-synapse = callTest tests/matrix-synapse.nix {};
303 tests.mesos = callTest tests/mesos.nix {};
304 tests.misc = callTest tests/misc.nix {};
305 tests.mongodb = callTest tests/mongodb.nix {};
306 tests.mumble = callTest tests/mumble.nix {};
307 tests.munin = callTest tests/munin.nix {};
308 tests.mutableUsers = callTest tests/mutable-users.nix {};
309 tests.mysql = callTest tests/mysql.nix {};
310 tests.mysqlBackup = callTest tests/mysql-backup.nix {};
311 tests.mysqlReplication = callTest tests/mysql-replication.nix {};
312 tests.nat.firewall = callTest tests/nat.nix { withFirewall = true; };
313 tests.nat.firewall-conntrack = callTest tests/nat.nix { withFirewall = true; withConntrackHelpers = true; };
314 tests.nat.standalone = callTest tests/nat.nix { withFirewall = false; };
315 tests.netdata = callTest tests/netdata.nix { };
316 tests.networking.networkd = callSubTests tests/networking.nix { networkd = true; };
317 tests.networking.scripted = callSubTests tests/networking.nix { networkd = false; };
318 # TODO: put in networking.nix after the test becomes more complete
319 tests.networkingProxy = callTest tests/networking-proxy.nix {};
320 tests.nfs3 = callTest tests/nfs.nix { version = 3; };
321 tests.nfs4 = callTest tests/nfs.nix { version = 4; };
322 tests.nginx = callTest tests/nginx.nix { };
323 tests.nghttpx = callTest tests/nghttpx.nix { };
324 tests.nix-ssh-serve = callTest tests/nix-ssh-serve.nix { };
325 tests.novacomd = callTestOnTheseSystems ["x86_64-linux"] tests/novacomd.nix { };
326 tests.leaps = callTest tests/leaps.nix { };
327 tests.nsd = callTest tests/nsd.nix {};
328 tests.openssh = callTest tests/openssh.nix {};
329 tests.openldap = callTest tests/openldap.nix {};
330 tests.owncloud = callTest tests/owncloud.nix {};
331 tests.pam-oath-login = callTest tests/pam-oath-login.nix {};
332 #tests.panamax = callTestOnTheseSystems ["x86_64-linux"] tests/panamax.nix {};
333 tests.peerflix = callTest tests/peerflix.nix {};
334 tests.php-pcre = callTest tests/php-pcre.nix {};
335 tests.postgresql = callSubTests tests/postgresql.nix {};
336 tests.pgmanage = callTest tests/pgmanage.nix {};
337 tests.postgis = callTest tests/postgis.nix {};
338 tests.powerdns = callTest tests/powerdns.nix {};
339 #tests.pgjwt = callTest tests/pgjwt.nix {};
340 tests.predictable-interface-names = callSubTests tests/predictable-interface-names.nix {};
341 tests.printing = callTest tests/printing.nix {};
342 tests.prometheus = callTest tests/prometheus.nix {};
343 tests.proxy = callTest tests/proxy.nix {};
344 # tests.quagga = callTest tests/quagga.nix {};
345 tests.quake3 = callTest tests/quake3.nix {};
346 tests.rabbitmq = callTest tests/rabbitmq.nix {};
347 tests.radicale = callTest tests/radicale.nix {};
348 tests.rspamd = callSubTests tests/rspamd.nix {};
349 tests.runInMachine = callTest tests/run-in-machine.nix {};
350 tests.rxe = callTest tests/rxe.nix {};
351 tests.samba = callTest tests/samba.nix {};
352 tests.sddm = callSubTests tests/sddm.nix {};
353 tests.simple = callTest tests/simple.nix {};
354 tests.slim = callTest tests/slim.nix {};
355 tests.smokeping = callTest tests/smokeping.nix {};
356 tests.snapper = callTest tests/snapper.nix {};
357 tests.statsd = callTest tests/statsd.nix {};
358 tests.sudo = callTest tests/sudo.nix {};
359 tests.systemd = callTest tests/systemd.nix {};
360 tests.switchTest = callTest tests/switch-test.nix {};
361 tests.taskserver = callTest tests/taskserver.nix {};
362 tests.tomcat = callTest tests/tomcat.nix {};
363 tests.udisks2 = callTest tests/udisks2.nix {};
364 tests.vault = callTest tests/vault.nix {};
365 tests.virtualbox = callSubTestsOnTheseSystems ["x86_64-linux"] tests/virtualbox.nix {};
366 tests.wordpress = callTest tests/wordpress.nix {};
367 tests.xfce = callTest tests/xfce.nix {};
368 tests.xmonad = callTest tests/xmonad.nix {};
369 tests.xrdp = callTest tests/xrdp.nix {};
370 tests.yabar = callTest tests/yabar.nix {};
371 tests.zookeeper = callTest tests/zookeeper.nix {};
372
373 /* Build a bunch of typical closures so that Hydra can keep track of
374 the evolution of closure sizes. */
375
376 closures = {
377
378 smallContainer = makeClosure ({ pkgs, ... }:
379 { boot.isContainer = true;
380 services.openssh.enable = true;
381 });
382
383 tinyContainer = makeClosure ({ pkgs, ... }:
384 { boot.isContainer = true;
385 imports = [ modules/profiles/minimal.nix ];
386 });
387
388 ec2 = makeClosure ({ pkgs, ... }:
389 { imports = [ modules/virtualisation/amazon-image.nix ];
390 });
391
392 kde = makeClosure ({ pkgs, ... }:
393 { services.xserver.enable = true;
394 services.xserver.displayManager.sddm.enable = true;
395 services.xserver.desktopManager.plasma5.enable = true;
396 });
397
398 xfce = makeClosure ({ pkgs, ... }:
399 { services.xserver.enable = true;
400 services.xserver.desktopManager.xfce.enable = true;
401 });
402
403 # Linux/Apache/PostgreSQL/PHP stack.
404 lapp = makeClosure ({ pkgs, ... }:
405 { services.httpd.enable = true;
406 services.httpd.adminAddr = "foo@example.org";
407 services.postgresql.enable = true;
408 services.postgresql.package = pkgs.postgresql93;
409 environment.systemPackages = [ pkgs.php ];
410 });
411 };
412}