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