1with import ../lib;
2
3{ nixpkgs ? { outPath = cleanSource ./..; revCount = 130979; shortRev = "gfedcba"; }
4, stableBranch ? false
5, supportedSystems ? [ "x86_64-linux" "aarch64-linux" ]
6, configuration ? {}
7}:
8
9with import ../pkgs/top-level/release-lib.nix { inherit supportedSystems; };
10
11let
12
13 version = fileContents ../.version;
14 versionSuffix =
15 (if stableBranch then "." else "pre") + "${toString nixpkgs.revCount}.${nixpkgs.shortRev}";
16
17 # Run the tests for each platform. You can run a test by doing
18 # e.g. ‘nix-build release.nix -A tests.login.x86_64-linux’,
19 # or equivalently, ‘nix-build tests/login.nix’.
20 # See also nixosTests in pkgs/top-level/all-packages.nix
21 allTestsForSystem = system:
22 import ./tests/all-tests.nix {
23 inherit system;
24 pkgs = import ./.. { inherit system; };
25 callTest = config: {
26 ${system} = hydraJob config.test;
27 };
28 } // {
29 # for typechecking of the scripts and evaluation of
30 # the nodes, without running VMs.
31 allDrivers =
32 import ./tests/all-tests.nix {
33 inherit system;
34 pkgs = import ./.. { inherit system; };
35 callTest = config: {
36 ${system} = hydraJob config.driver;
37 };
38 };
39 };
40
41 allTests =
42 foldAttrs recursiveUpdate {} (map allTestsForSystem supportedSystems);
43
44 pkgs = import ./.. { system = "x86_64-linux"; };
45
46
47 versionModule =
48 { system.nixos.versionSuffix = versionSuffix;
49 system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev;
50 };
51
52 makeModules = module: rest: [ configuration versionModule module rest ];
53
54 makeIso =
55 { module, type, system, ... }:
56
57 with import ./.. { inherit system; };
58
59 hydraJob ((import lib/eval-config.nix {
60 inherit system;
61 modules = makeModules module {
62 isoImage.isoBaseName = "nixos-${type}";
63 };
64 }).config.system.build.isoImage);
65
66
67 makeSdImage =
68 { module, system, ... }:
69
70 with import ./.. { inherit system; };
71
72 hydraJob ((import lib/eval-config.nix {
73 inherit system;
74 modules = makeModules module {};
75 }).config.system.build.sdImage);
76
77
78 makeSystemTarball =
79 { module, maintainers ? ["viric"], system }:
80
81 with import ./.. { inherit system; };
82
83 let
84
85 config = (import lib/eval-config.nix {
86 inherit system;
87 modules = makeModules module {};
88 }).config;
89
90 tarball = config.system.build.tarball;
91
92 in
93 tarball //
94 { meta = {
95 description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.linux-kernel.name}";
96 maintainers = map (x: lib.maintainers.${x}) maintainers;
97 };
98 inherit config;
99 };
100
101
102 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel);
103
104
105 buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix {
106 inherit system;
107 modules = makeModules module
108 ({ ... }:
109 { fileSystems."/".device = mkDefault "/dev/sda1";
110 boot.loader.grub.device = mkDefault "/dev/sda";
111 });
112 }).config));
113
114 makeNetboot = { module, system, ... }:
115 let
116 configEvaled = import lib/eval-config.nix {
117 inherit system;
118 modules = makeModules module {};
119 };
120 build = configEvaled.config.system.build;
121 kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target;
122 in
123 pkgs.symlinkJoin {
124 name = "netboot";
125 paths = [
126 build.netbootRamdisk
127 build.kernel
128 build.netbootIpxeScript
129 ];
130 postBuild = ''
131 mkdir -p $out/nix-support
132 echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products
133 echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products
134 echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products
135 '';
136 preferLocalBuild = true;
137 };
138
139in rec {
140
141 channel = import lib/make-channel.nix { inherit pkgs nixpkgs version versionSuffix; };
142
143 manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML);
144 manual = manualHTML; # TODO(@oxij): remove eventually
145 manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub));
146 manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages);
147 options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;
148
149
150 # Build the initial ramdisk so Hydra can keep track of its size over time.
151 initialRamdisk = buildFromConfig ({ ... }: { }) (config: config.system.build.initialRamdisk);
152
153 kexec = forMatchingSystems supportedSystems (system: (import lib/eval-config.nix {
154 inherit system;
155 modules = [
156 ./modules/installer/netboot/netboot-minimal.nix
157 ];
158 }).config.system.build.kexecTree);
159
160 netboot = forMatchingSystems supportedSystems (system: makeNetboot {
161 module = ./modules/installer/netboot/netboot-minimal.nix;
162 inherit system;
163 });
164
165 iso_minimal = forAllSystems (system: makeIso {
166 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix;
167 type = "minimal";
168 inherit system;
169 });
170
171 iso_plasma5 = forMatchingSystems supportedSystems (system: makeIso {
172 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma5.nix;
173 type = "plasma5";
174 inherit system;
175 });
176
177 iso_gnome = forMatchingSystems supportedSystems (system: makeIso {
178 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix;
179 type = "gnome";
180 inherit system;
181 });
182
183 # A variant with a more recent (but possibly less stable) kernel that might support more hardware.
184 # This variant keeps zfs support enabled, hoping it will build and work.
185 iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
186 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
187 type = "minimal-new-kernel";
188 inherit system;
189 });
190
191 # A variant with a more recent (but possibly less stable) kernel that might support more hardware.
192 # ZFS support disabled since it is unlikely to support the latest kernel.
193 iso_minimal_new_kernel_no_zfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
194 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix;
195 type = "minimal-new-kernel-no-zfs";
196 inherit system;
197 });
198
199 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] (system: makeSdImage {
200 module = {
201 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix;
202 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix;
203 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix;
204 }.${system};
205 inherit system;
206 });
207
208 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
209 module = {
210 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix;
211 }.${system};
212 type = "minimal-new-kernel";
213 inherit system;
214 });
215
216 sd_image_new_kernel_no_zfs = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
217 module = {
218 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-no-zfs-installer.nix;
219 }.${system};
220 type = "minimal-new-kernel-no-zfs";
221 inherit system;
222 });
223
224 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
225 ova = forMatchingSystems [ "x86_64-linux" ] (system:
226
227 with import ./.. { inherit system; };
228
229 hydraJob ((import lib/eval-config.nix {
230 inherit system;
231 modules =
232 [ versionModule
233 ./modules/installer/virtualbox-demo.nix
234 ];
235 }).config.system.build.virtualBoxOVA)
236
237 );
238
239 # KVM image for proxmox in VMA format
240 proxmoxImage = forMatchingSystems [ "x86_64-linux" ] (system:
241 with import ./.. { inherit system; };
242
243 hydraJob ((import lib/eval-config.nix {
244 inherit system;
245 modules = [
246 ./modules/virtualisation/proxmox-image.nix
247 ];
248 }).config.system.build.VMA)
249 );
250
251 # LXC tarball for proxmox
252 proxmoxLXC = forMatchingSystems [ "x86_64-linux" ] (system:
253 with import ./.. { inherit system; };
254
255 hydraJob ((import lib/eval-config.nix {
256 inherit system;
257 modules = [
258 ./modules/virtualisation/proxmox-lxc.nix
259 ];
260 }).config.system.build.tarball)
261 );
262
263 # A disk image that can be imported to Amazon EC2 and registered as an AMI
264 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
265
266 with import ./.. { inherit system; };
267
268 hydraJob ((import lib/eval-config.nix {
269 inherit system;
270 modules =
271 [ configuration
272 versionModule
273 ./maintainers/scripts/ec2/amazon-image.nix
274 ];
275 }).config.system.build.amazonImage)
276
277 );
278 amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
279
280 with import ./.. { inherit system; };
281
282 hydraJob ((import lib/eval-config.nix {
283 inherit system;
284 modules =
285 [ configuration
286 versionModule
287 ./maintainers/scripts/ec2/amazon-image-zfs.nix
288 ];
289 }).config.system.build.amazonImage)
290
291 );
292
293
294 # Test job for https://github.com/NixOS/nixpkgs/issues/121354 to test
295 # automatic sizing without blocking the channel.
296 amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
297
298 with import ./.. { inherit system; };
299
300 hydraJob ((import lib/eval-config.nix {
301 inherit system;
302 modules =
303 [ configuration
304 versionModule
305 ./maintainers/scripts/ec2/amazon-image.nix
306 ({ ... }: { amazonImage.sizeMB = "auto"; })
307 ];
308 }).config.system.build.amazonImage)
309
310 );
311
312 # An image that can be imported into lxd and used for container creation
313 lxdImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
314
315 with import ./.. { inherit system; };
316
317 hydraJob ((import lib/eval-config.nix {
318 inherit system;
319 modules =
320 [ configuration
321 versionModule
322 ./maintainers/scripts/lxd/lxd-image.nix
323 ];
324 }).config.system.build.tarball)
325
326 );
327
328 # Metadata for the lxd image
329 lxdMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
330
331 with import ./.. { inherit system; };
332
333 hydraJob ((import lib/eval-config.nix {
334 inherit system;
335 modules =
336 [ configuration
337 versionModule
338 ./maintainers/scripts/lxd/lxd-image.nix
339 ];
340 }).config.system.build.metadata)
341
342 );
343
344 # Ensure that all packages used by the minimal NixOS config end up in the channel.
345 dummy = forAllSystems (system: pkgs.runCommand "dummy"
346 { toplevel = (import lib/eval-config.nix {
347 inherit system;
348 modules = singleton ({ ... }:
349 { fileSystems."/".device = mkDefault "/dev/sda1";
350 boot.loader.grub.device = mkDefault "/dev/sda";
351 system.stateVersion = mkDefault "18.03";
352 });
353 }).config.system.build.toplevel;
354 preferLocalBuild = true;
355 }
356 "mkdir $out; ln -s $toplevel $out/dummy");
357
358
359 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
360 containerTarball = forAllSystems (system: makeSystemTarball {
361 module = ./modules/virtualisation/lxc-container.nix;
362 inherit system;
363 });
364
365 tests = allTests;
366
367 /* Build a bunch of typical closures so that Hydra can keep track of
368 the evolution of closure sizes. */
369
370 closures = {
371
372 smallContainer = makeClosure ({ ... }:
373 { boot.isContainer = true;
374 services.openssh.enable = true;
375 });
376
377 tinyContainer = makeClosure ({ ... }:
378 { boot.isContainer = true;
379 imports = [ modules/profiles/minimal.nix ];
380 });
381
382 ec2 = makeClosure ({ ... }:
383 { imports = [ modules/virtualisation/amazon-image.nix ];
384 });
385
386 kde = makeClosure ({ ... }:
387 { services.xserver.enable = true;
388 services.xserver.displayManager.sddm.enable = true;
389 services.xserver.desktopManager.plasma5.enable = true;
390 });
391
392 xfce = makeClosure ({ ... }:
393 { services.xserver.enable = true;
394 services.xserver.desktopManager.xfce.enable = true;
395 });
396
397 gnome = makeClosure ({ ... }:
398 { services.xserver.enable = true;
399 services.xserver.displayManager.gdm.enable = true;
400 services.xserver.desktopManager.gnome.enable = true;
401 });
402
403 pantheon = makeClosure ({ ... }:
404 { services.xserver.enable = true;
405 services.xserver.desktopManager.pantheon.enable = true;
406 });
407
408 deepin = makeClosure ({ ... }:
409 { services.xserver.enable = true;
410 services.xserver.displayManager.lightdm.enable = true;
411 services.xserver.desktopManager.deepin.enable = true;
412 });
413
414 # Linux/Apache/PostgreSQL/PHP stack.
415 lapp = makeClosure ({ pkgs, ... }:
416 { services.httpd.enable = true;
417 services.httpd.adminAddr = "foo@example.org";
418 services.httpd.enablePHP = true;
419 services.postgresql.enable = true;
420 services.postgresql.package = pkgs.postgresql;
421 });
422 };
423}