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 manualGeneratedSources = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.generatedSources);
148 options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;
149
150
151 # Build the initial ramdisk so Hydra can keep track of its size over time.
152 initialRamdisk = buildFromConfig ({ ... }: { }) (config: config.system.build.initialRamdisk);
153
154 kexec = forMatchingSystems supportedSystems (system: (import lib/eval-config.nix {
155 inherit system;
156 modules = [
157 ./modules/installer/netboot/netboot-minimal.nix
158 ];
159 }).config.system.build.kexecTree);
160
161 netboot = forMatchingSystems supportedSystems (system: makeNetboot {
162 module = ./modules/installer/netboot/netboot-minimal.nix;
163 inherit system;
164 });
165
166 iso_minimal = forAllSystems (system: makeIso {
167 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix;
168 type = "minimal";
169 inherit system;
170 });
171
172 iso_plasma5 = forMatchingSystems supportedSystems (system: makeIso {
173 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma5.nix;
174 type = "plasma5";
175 inherit system;
176 });
177
178 iso_gnome = forMatchingSystems supportedSystems (system: makeIso {
179 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix;
180 type = "gnome";
181 inherit system;
182 });
183
184 # A variant with a more recent (but possibly less stable) kernel
185 # that might support more hardware.
186 iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
187 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
188 type = "minimal-new-kernel";
189 inherit system;
190 });
191
192 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] (system: makeSdImage {
193 module = {
194 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix;
195 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix;
196 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix;
197 }.${system};
198 inherit system;
199 });
200
201 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
202 module = {
203 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix;
204 }.${system};
205 type = "minimal-new-kernel";
206 inherit system;
207 });
208
209 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
210 ova = forMatchingSystems [ "x86_64-linux" ] (system:
211
212 with import ./.. { inherit system; };
213
214 hydraJob ((import lib/eval-config.nix {
215 inherit system;
216 modules =
217 [ versionModule
218 ./modules/installer/virtualbox-demo.nix
219 ];
220 }).config.system.build.virtualBoxOVA)
221
222 );
223
224 # KVM image for proxmox in VMA format
225 proxmoxImage = forMatchingSystems [ "x86_64-linux" ] (system:
226 with import ./.. { inherit system; };
227
228 hydraJob ((import lib/eval-config.nix {
229 inherit system;
230 modules = [
231 ./modules/virtualisation/proxmox-image.nix
232 ];
233 }).config.system.build.VMA)
234 );
235
236 # LXC tarball for proxmox
237 proxmoxLXC = forMatchingSystems [ "x86_64-linux" ] (system:
238 with import ./.. { inherit system; };
239
240 hydraJob ((import lib/eval-config.nix {
241 inherit system;
242 modules = [
243 ./modules/virtualisation/proxmox-lxc.nix
244 ];
245 }).config.system.build.tarball)
246 );
247
248 # A disk image that can be imported to Amazon EC2 and registered as an AMI
249 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
250
251 with import ./.. { inherit system; };
252
253 hydraJob ((import lib/eval-config.nix {
254 inherit system;
255 modules =
256 [ configuration
257 versionModule
258 ./maintainers/scripts/ec2/amazon-image.nix
259 ];
260 }).config.system.build.amazonImage)
261
262 );
263 amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
264
265 with import ./.. { inherit system; };
266
267 hydraJob ((import lib/eval-config.nix {
268 inherit system;
269 modules =
270 [ configuration
271 versionModule
272 ./maintainers/scripts/ec2/amazon-image-zfs.nix
273 ];
274 }).config.system.build.amazonImage)
275
276 );
277
278
279 # Test job for https://github.com/NixOS/nixpkgs/issues/121354 to test
280 # automatic sizing without blocking the channel.
281 amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
282
283 with import ./.. { inherit system; };
284
285 hydraJob ((import lib/eval-config.nix {
286 inherit system;
287 modules =
288 [ configuration
289 versionModule
290 ./maintainers/scripts/ec2/amazon-image.nix
291 ({ ... }: { amazonImage.sizeMB = "auto"; })
292 ];
293 }).config.system.build.amazonImage)
294
295 );
296
297 # An image that can be imported into lxd and used for container creation
298 lxdImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
299
300 with import ./.. { inherit system; };
301
302 hydraJob ((import lib/eval-config.nix {
303 inherit system;
304 modules =
305 [ configuration
306 versionModule
307 ./maintainers/scripts/lxd/lxd-image.nix
308 ];
309 }).config.system.build.tarball)
310
311 );
312
313 # Metadata for the lxd image
314 lxdMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
315
316 with import ./.. { inherit system; };
317
318 hydraJob ((import lib/eval-config.nix {
319 inherit system;
320 modules =
321 [ configuration
322 versionModule
323 ./maintainers/scripts/lxd/lxd-image.nix
324 ];
325 }).config.system.build.metadata)
326
327 );
328
329 # Ensure that all packages used by the minimal NixOS config end up in the channel.
330 dummy = forAllSystems (system: pkgs.runCommand "dummy"
331 { toplevel = (import lib/eval-config.nix {
332 inherit system;
333 modules = singleton ({ ... }:
334 { fileSystems."/".device = mkDefault "/dev/sda1";
335 boot.loader.grub.device = mkDefault "/dev/sda";
336 system.stateVersion = mkDefault "18.03";
337 });
338 }).config.system.build.toplevel;
339 preferLocalBuild = true;
340 }
341 "mkdir $out; ln -s $toplevel $out/dummy");
342
343
344 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
345 containerTarball = forAllSystems (system: makeSystemTarball {
346 module = ./modules/virtualisation/lxc-container.nix;
347 inherit system;
348 });
349
350 tests = allTests;
351
352 /* Build a bunch of typical closures so that Hydra can keep track of
353 the evolution of closure sizes. */
354
355 closures = {
356
357 smallContainer = makeClosure ({ ... }:
358 { boot.isContainer = true;
359 services.openssh.enable = true;
360 });
361
362 tinyContainer = makeClosure ({ ... }:
363 { boot.isContainer = true;
364 imports = [ modules/profiles/minimal.nix ];
365 });
366
367 ec2 = makeClosure ({ ... }:
368 { imports = [ modules/virtualisation/amazon-image.nix ];
369 });
370
371 kde = makeClosure ({ ... }:
372 { services.xserver.enable = true;
373 services.xserver.displayManager.sddm.enable = true;
374 services.xserver.desktopManager.plasma5.enable = true;
375 });
376
377 xfce = makeClosure ({ ... }:
378 { services.xserver.enable = true;
379 services.xserver.desktopManager.xfce.enable = true;
380 });
381
382 gnome = makeClosure ({ ... }:
383 { services.xserver.enable = true;
384 services.xserver.displayManager.gdm.enable = true;
385 services.xserver.desktopManager.gnome.enable = true;
386 });
387
388 pantheon = makeClosure ({ ... }:
389 { services.xserver.enable = true;
390 services.xserver.desktopManager.pantheon.enable = true;
391 });
392
393 # Linux/Apache/PostgreSQL/PHP stack.
394 lapp = makeClosure ({ pkgs, ... }:
395 { services.httpd.enable = true;
396 services.httpd.adminAddr = "foo@example.org";
397 services.httpd.enablePHP = true;
398 services.postgresql.enable = true;
399 services.postgresql.package = pkgs.postgresql;
400 });
401 };
402}