1{ nixpkgs ? { outPath = ./..; revCount = 56789; shortRev = "gfedcba"; }
2, stableBranch ? false
3, supportedSystems ? [ "x86_64-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.cloud-init = callTest tests/cloud-init.nix {};
226 tests.containers-ipv4 = callTest tests/containers-ipv4.nix {};
227 tests.containers-ipv6 = callTest tests/containers-ipv6.nix {};
228 tests.containers-bridge = callTest tests/containers-bridge.nix {};
229 tests.containers-imperative = callTest tests/containers-imperative.nix {};
230 tests.containers-extra_veth = callTest tests/containers-extra_veth.nix {};
231 tests.containers-physical_interfaces = callTest tests/containers-physical_interfaces.nix {};
232 tests.containers-restart_networking = callTest tests/containers-restart_networking.nix {};
233 tests.containers-tmpfs = callTest tests/containers-tmpfs.nix {};
234 tests.containers-hosts = callTest tests/containers-hosts.nix {};
235 tests.containers-macvlans = callTest tests/containers-macvlans.nix {};
236 tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
237 tests.dnscrypt-proxy = callTest tests/dnscrypt-proxy.nix { system = "x86_64-linux"; };
238 tests.ecryptfs = callTest tests/ecryptfs.nix {};
239 tests.etcd = hydraJob (import tests/etcd.nix { system = "x86_64-linux"; });
240 tests.ec2-nixops = hydraJob (import tests/ec2.nix { system = "x86_64-linux"; }).boot-ec2-nixops;
241 tests.ec2-config = hydraJob (import tests/ec2.nix { system = "x86_64-linux"; }).boot-ec2-config;
242 tests.elk = callTest tests/elk.nix {};
243 tests.ferm = callTest tests/ferm.nix {};
244 tests.firefox = callTest tests/firefox.nix {};
245 tests.firewall = callTest tests/firewall.nix {};
246 tests.fleet = hydraJob (import tests/fleet.nix { system = "x86_64-linux"; });
247 #tests.gitlab = callTest tests/gitlab.nix {};
248 tests.glance = callTest tests/glance.nix {};
249 tests.gocd-agent = callTest tests/gocd-agent.nix {};
250 tests.gocd-server = callTest tests/gocd-server.nix {};
251 tests.gnome3 = callTest tests/gnome3.nix {};
252 tests.gnome3-gdm = callTest tests/gnome3-gdm.nix {};
253 tests.hardened = callTest tests/hardened.nix { };
254 tests.hibernate = callTest tests/hibernate.nix {};
255 tests.hound = callTest tests/hound.nix {};
256 tests.i3wm = callTest tests/i3wm.nix {};
257 tests.installer = callSubTests tests/installer.nix {};
258 tests.influxdb = callTest tests/influxdb.nix {};
259 tests.ipv6 = callTest tests/ipv6.nix {};
260 tests.jenkins = callTest tests/jenkins.nix {};
261 tests.plasma5 = callTest tests/plasma5.nix {};
262 tests.keymap = callSubTests tests/keymap.nix {};
263 tests.initrdNetwork = callTest tests/initrd-network.nix {};
264 tests.keystone = callTest tests/keystone.nix {};
265 tests.kubernetes = hydraJob (import tests/kubernetes.nix { system = "x86_64-linux"; });
266 tests.latestKernel.login = callTest tests/login.nix { latestKernel = true; };
267 tests.ldap = callTest tests/ldap.nix {};
268 #tests.lightdm = callTest tests/lightdm.nix {};
269 tests.login = callTest tests/login.nix {};
270 #tests.logstash = callTest tests/logstash.nix {};
271 tests.mathics = callTest tests/mathics.nix {};
272 tests.misc = callTest tests/misc.nix {};
273 tests.mongodb = callTest tests/mongodb.nix {};
274 tests.mumble = callTest tests/mumble.nix {};
275 tests.munin = callTest tests/munin.nix {};
276 tests.mysql = callTest tests/mysql.nix {};
277 tests.mysqlReplication = callTest tests/mysql-replication.nix {};
278 tests.nat.firewall = callTest tests/nat.nix { withFirewall = true; };
279 tests.nat.firewall-conntrack = callTest tests/nat.nix { withFirewall = true; withConntrackHelpers = true; };
280 tests.nat.standalone = callTest tests/nat.nix { withFirewall = false; };
281 tests.networking.networkd = callSubTests tests/networking.nix { networkd = true; };
282 tests.networking.scripted = callSubTests tests/networking.nix { networkd = false; };
283 # TODO: put in networking.nix after the test becomes more complete
284 tests.networkingProxy = callTest tests/networking-proxy.nix {};
285 tests.nfs3 = callTest tests/nfs.nix { version = 3; };
286 tests.nfs4 = callTest tests/nfs.nix { version = 4; };
287 tests.nginx = callTest tests/nginx.nix { };
288 tests.leaps = callTest tests/leaps.nix { };
289 tests.nsd = callTest tests/nsd.nix {};
290 tests.openssh = callTest tests/openssh.nix {};
291 tests.pam-oath-login = callTest tests/pam-oath-login.nix {};
292 #tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; });
293 tests.peerflix = callTest tests/peerflix.nix {};
294 tests.postgresql = callSubTests tests/postgresql.nix {};
295 tests.pgjwt = callTest tests/pgjwt.nix {};
296 tests.printing = callTest tests/printing.nix {};
297 tests.proxy = callTest tests/proxy.nix {};
298 tests.pumpio = callTest tests/pump.io.nix {};
299 # tests.quagga = callTest tests/quagga.nix {};
300 tests.quake3 = callTest tests/quake3.nix {};
301 tests.radicale = callTest tests/radicale.nix {};
302 tests.runInMachine = callTest tests/run-in-machine.nix {};
303 tests.samba = callTest tests/samba.nix {};
304 tests.sddm = callSubTests tests/sddm.nix {};
305 tests.simple = callTest tests/simple.nix {};
306 tests.slim = callTest tests/slim.nix {};
307 tests.smokeping = callTest tests/smokeping.nix {};
308 tests.snapper = callTest tests/snapper.nix {};
309 tests.taskserver = callTest tests/taskserver.nix {};
310 tests.tomcat = callTest tests/tomcat.nix {};
311 tests.udisks2 = callTest tests/udisks2.nix {};
312 tests.virtualbox = callSubTests tests/virtualbox.nix { system = "x86_64-linux"; };
313 tests.wordpress = callTest tests/wordpress.nix {};
314 tests.xfce = callTest tests/xfce.nix {};
315
316
317 /* Build a bunch of typical closures so that Hydra can keep track of
318 the evolution of closure sizes. */
319
320 closures = {
321
322 smallContainer = makeClosure ({ pkgs, ... }:
323 { boot.isContainer = true;
324 services.openssh.enable = true;
325 });
326
327 tinyContainer = makeClosure ({ pkgs, ... }:
328 { boot.isContainer = true;
329 imports = [ modules/profiles/minimal.nix ];
330 });
331
332 ec2 = makeClosure ({ pkgs, ... }:
333 { imports = [ modules/virtualisation/amazon-image.nix ];
334 });
335
336 kde = makeClosure ({ pkgs, ... }:
337 { services.xserver.enable = true;
338 services.xserver.displayManager.sddm.enable = true;
339 services.xserver.desktopManager.plasma5.enable = true;
340 });
341
342 xfce = makeClosure ({ pkgs, ... }:
343 { services.xserver.enable = true;
344 services.xserver.desktopManager.xfce.enable = true;
345 });
346
347 # Linux/Apache/PostgreSQL/PHP stack.
348 lapp = makeClosure ({ pkgs, ... }:
349 { services.httpd.enable = true;
350 services.httpd.adminAddr = "foo@example.org";
351 services.postgresql.enable = true;
352 services.postgresql.package = pkgs.postgresql93;
353 environment.systemPackages = [ pkgs.php ];
354 });
355 };
356}