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 -A tests.login.x86_64-linux’, or equivalently,
19 # ‘nix-build tests/login.nix -A result’.
20 allTestsForSystem = system:
21 import ./tests/all-tests.nix {
22 inherit system;
23 pkgs = import ./.. { inherit system; };
24 callTest = t: {
25 ${system} = hydraJob t.test;
26 };
27 };
28 allTests =
29 foldAttrs recursiveUpdate {} (map allTestsForSystem supportedSystems);
30
31 pkgs = import ./.. { system = "x86_64-linux"; };
32
33
34 versionModule =
35 { system.nixos.versionSuffix = versionSuffix;
36 system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev;
37 };
38
39 makeModules = module: rest: [ configuration versionModule module rest ];
40
41 makeIso =
42 { module, type, system, ... }:
43
44 with import ./.. { inherit system; };
45
46 hydraJob ((import lib/eval-config.nix {
47 inherit system;
48 modules = makeModules module {
49 isoImage.isoBaseName = "nixos-${type}";
50 };
51 }).config.system.build.isoImage);
52
53
54 makeSdImage =
55 { module, system, ... }:
56
57 with import ./.. { inherit system; };
58
59 hydraJob ((import lib/eval-config.nix {
60 inherit system;
61 modules = makeModules module {};
62 }).config.system.build.sdImage);
63
64
65 makeSystemTarball =
66 { module, maintainers ? ["viric"], system }:
67
68 with import ./.. { inherit system; };
69
70 let
71
72 config = (import lib/eval-config.nix {
73 inherit system;
74 modules = makeModules module {};
75 }).config;
76
77 tarball = config.system.build.tarball;
78
79 in
80 tarball //
81 { meta = {
82 description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.linux-kernel.name}";
83 maintainers = map (x: lib.maintainers.${x}) maintainers;
84 };
85 inherit config;
86 };
87
88
89 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel);
90
91
92 buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix {
93 inherit system;
94 modules = makeModules module
95 ({ ... }:
96 { fileSystems."/".device = mkDefault "/dev/sda1";
97 boot.loader.grub.device = mkDefault "/dev/sda";
98 });
99 }).config));
100
101 makeNetboot = { module, system, ... }:
102 let
103 configEvaled = import lib/eval-config.nix {
104 inherit system;
105 modules = makeModules module {};
106 };
107 build = configEvaled.config.system.build;
108 kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target;
109 in
110 pkgs.symlinkJoin {
111 name = "netboot";
112 paths = [
113 build.netbootRamdisk
114 build.kernel
115 build.netbootIpxeScript
116 ];
117 postBuild = ''
118 mkdir -p $out/nix-support
119 echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products
120 echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products
121 echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products
122 '';
123 preferLocalBuild = true;
124 };
125
126in rec {
127
128 channel = import lib/make-channel.nix { inherit pkgs nixpkgs version versionSuffix; };
129
130 manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML);
131 manual = manualHTML; # TODO(@oxij): remove eventually
132 manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub));
133 manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages);
134 manualGeneratedSources = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.generatedSources);
135 options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;
136
137
138 # Build the initial ramdisk so Hydra can keep track of its size over time.
139 initialRamdisk = buildFromConfig ({ ... }: { }) (config: config.system.build.initialRamdisk);
140
141 netboot = forMatchingSystems supportedSystems (system: makeNetboot {
142 module = ./modules/installer/netboot/netboot-minimal.nix;
143 inherit system;
144 });
145
146 iso_minimal = forAllSystems (system: makeIso {
147 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix;
148 type = "minimal";
149 inherit system;
150 });
151
152 iso_plasma5 = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
153 module = ./modules/installer/cd-dvd/installation-cd-graphical-plasma5.nix;
154 type = "plasma5";
155 inherit system;
156 });
157
158 iso_gnome = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
159 module = ./modules/installer/cd-dvd/installation-cd-graphical-gnome.nix;
160 type = "gnome";
161 inherit system;
162 });
163
164 # A variant with a more recent (but possibly less stable) kernel
165 # that might support more hardware.
166 iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
167 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
168 type = "minimal-new-kernel";
169 inherit system;
170 });
171
172 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] (system: makeSdImage {
173 module = {
174 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix;
175 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix;
176 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix;
177 }.${system};
178 inherit system;
179 });
180
181 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
182 module = {
183 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix;
184 }.${system};
185 type = "minimal-new-kernel";
186 inherit system;
187 });
188
189 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
190 ova = forMatchingSystems [ "x86_64-linux" ] (system:
191
192 with import ./.. { inherit system; };
193
194 hydraJob ((import lib/eval-config.nix {
195 inherit system;
196 modules =
197 [ versionModule
198 ./modules/installer/virtualbox-demo.nix
199 ];
200 }).config.system.build.virtualBoxOVA)
201
202 );
203
204
205 # A disk image that can be imported to Amazon EC2 and registered as an AMI
206 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
207
208 with import ./.. { inherit system; };
209
210 hydraJob ((import lib/eval-config.nix {
211 inherit system;
212 modules =
213 [ configuration
214 versionModule
215 ./maintainers/scripts/ec2/amazon-image.nix
216 ];
217 }).config.system.build.amazonImage)
218
219 );
220
221
222 # Test job for https://github.com/NixOS/nixpkgs/issues/121354 to test
223 # automatic sizing without blocking the channel.
224 amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
225
226 with import ./.. { inherit system; };
227
228 hydraJob ((import lib/eval-config.nix {
229 inherit system;
230 modules =
231 [ configuration
232 versionModule
233 ./maintainers/scripts/ec2/amazon-image.nix
234 ({ ... }: { amazonImage.sizeMB = "auto"; })
235 ];
236 }).config.system.build.amazonImage)
237
238 );
239
240
241 # Ensure that all packages used by the minimal NixOS config end up in the channel.
242 dummy = forAllSystems (system: pkgs.runCommand "dummy"
243 { toplevel = (import lib/eval-config.nix {
244 inherit system;
245 modules = singleton ({ ... }:
246 { fileSystems."/".device = mkDefault "/dev/sda1";
247 boot.loader.grub.device = mkDefault "/dev/sda";
248 system.stateVersion = mkDefault "18.03";
249 });
250 }).config.system.build.toplevel;
251 preferLocalBuild = true;
252 }
253 "mkdir $out; ln -s $toplevel $out/dummy");
254
255
256 # Provide a tarball that can be unpacked into an SD card, and easily
257 # boot that system from uboot (like for the sheevaplug).
258 # The pc variant helps preparing the expression for the system tarball
259 # in a machine faster than the sheevpalug
260 /*
261 system_tarball_pc = forAllSystems (system: makeSystemTarball {
262 module = ./modules/installer/cd-dvd/system-tarball-pc.nix;
263 inherit system;
264 });
265 */
266
267 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
268 containerTarball = forAllSystems (system: makeSystemTarball {
269 module = ./modules/virtualisation/lxc-container.nix;
270 inherit system;
271 });
272
273 /*
274 system_tarball_fuloong2f =
275 assert builtins.currentSystem == "mips64-linux";
276 makeSystemTarball {
277 module = ./modules/installer/cd-dvd/system-tarball-fuloong2f.nix;
278 system = "mips64-linux";
279 };
280
281 system_tarball_sheevaplug =
282 assert builtins.currentSystem == "armv5tel-linux";
283 makeSystemTarball {
284 module = ./modules/installer/cd-dvd/system-tarball-sheevaplug.nix;
285 system = "armv5tel-linux";
286 };
287 */
288
289 tests = allTests;
290
291 /* Build a bunch of typical closures so that Hydra can keep track of
292 the evolution of closure sizes. */
293
294 closures = {
295
296 smallContainer = makeClosure ({ ... }:
297 { boot.isContainer = true;
298 services.openssh.enable = true;
299 });
300
301 tinyContainer = makeClosure ({ ... }:
302 { boot.isContainer = true;
303 imports = [ modules/profiles/minimal.nix ];
304 });
305
306 ec2 = makeClosure ({ ... }:
307 { imports = [ modules/virtualisation/amazon-image.nix ];
308 });
309
310 kde = makeClosure ({ ... }:
311 { services.xserver.enable = true;
312 services.xserver.displayManager.sddm.enable = true;
313 services.xserver.desktopManager.plasma5.enable = true;
314 });
315
316 xfce = makeClosure ({ ... }:
317 { services.xserver.enable = true;
318 services.xserver.desktopManager.xfce.enable = true;
319 });
320
321 gnome = makeClosure ({ ... }:
322 { services.xserver.enable = true;
323 services.xserver.displayManager.gdm.enable = true;
324 services.xserver.desktopManager.gnome.enable = true;
325 });
326
327 pantheon = makeClosure ({ ... }:
328 { services.xserver.enable = true;
329 services.xserver.desktopManager.pantheon.enable = true;
330 });
331
332 # Linux/Apache/PostgreSQL/PHP stack.
333 lapp = makeClosure ({ pkgs, ... }:
334 { services.httpd.enable = true;
335 services.httpd.adminAddr = "foo@example.org";
336 services.httpd.enablePHP = true;
337 services.postgresql.enable = true;
338 services.postgresql.package = pkgs.postgresql;
339 });
340 };
341}