at 25.11-pre 16 kB view raw
1with import ../lib; 2 3{ 4 nixpkgs ? { 5 outPath = cleanSource ./..; 6 revCount = 708350; 7 shortRev = "gfedcba"; 8 }, 9 stableBranch ? false, 10 supportedSystems ? [ 11 "x86_64-linux" 12 "aarch64-linux" 13 ], 14 configuration ? { }, 15}: 16 17with import ../pkgs/top-level/release-lib.nix { inherit supportedSystems; }; 18 19let 20 21 version = fileContents ../.version; 22 versionSuffix = 23 (if stableBranch then "." else "pre") + "${toString nixpkgs.revCount}.${nixpkgs.shortRev}"; 24 25 # Run the tests for each platform. You can run a test by doing 26 # e.g. ‘nix-build release.nix -A tests.login.x86_64-linux’, 27 # or equivalently, ‘nix-build tests/login.nix’. 28 # See also nixosTests in pkgs/top-level/all-packages.nix 29 allTestsForSystem = 30 system: 31 import ./tests/all-tests.nix { 32 inherit system; 33 pkgs = import ./.. { inherit system; }; 34 callTest = config: { 35 ${system} = hydraJob config.test; 36 }; 37 } 38 // { 39 # for typechecking of the scripts and evaluation of 40 # the nodes, without running VMs. 41 allDrivers = import ./tests/all-tests.nix { 42 inherit system; 43 pkgs = import ./.. { inherit system; }; 44 callTest = config: { 45 ${system} = hydraJob config.driver; 46 }; 47 }; 48 }; 49 50 allTests = foldAttrs recursiveUpdate { } (map allTestsForSystem supportedSystems); 51 52 pkgs = import ./.. { system = "x86_64-linux"; }; 53 54 versionModule = 55 { config, ... }: 56 { 57 system.nixos.versionSuffix = versionSuffix; 58 system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev; 59 60 # At creation time we do not have state yet, so just default to latest. 61 system.stateVersion = config.system.nixos.release; 62 }; 63 64 makeModules = module: rest: [ 65 configuration 66 versionModule 67 module 68 rest 69 ]; 70 71 makeIso = 72 { 73 module, 74 type, 75 system, 76 ... 77 }: 78 79 with import ./.. { inherit system; }; 80 81 hydraJob ( 82 (import lib/eval-config.nix { 83 inherit system; 84 modules = makeModules module { }; 85 }).config.system.build.isoImage 86 ); 87 88 makeSdImage = 89 { module, system, ... }: 90 91 with import ./.. { inherit system; }; 92 93 hydraJob ( 94 (import lib/eval-config.nix { 95 inherit system; 96 modules = makeModules module { }; 97 }).config.system.build.sdImage 98 ); 99 100 makeSystemTarball = 101 { 102 module, 103 maintainers ? [ "viric" ], 104 system, 105 }: 106 107 with import ./.. { inherit system; }; 108 109 let 110 111 config = 112 (import lib/eval-config.nix { 113 inherit system; 114 modules = makeModules module { }; 115 }).config; 116 117 tarball = config.system.build.tarball; 118 119 in 120 tarball 121 // { 122 meta = { 123 description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.linux-kernel.name}"; 124 maintainers = map (x: lib.maintainers.${x}) maintainers; 125 }; 126 inherit config; 127 }; 128 129 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel); 130 131 buildFromConfig = 132 module: sel: 133 forAllSystems ( 134 system: 135 hydraJob ( 136 sel 137 (import ./lib/eval-config.nix { 138 inherit system; 139 modules = makeModules module ( 140 { ... }: 141 { 142 fileSystems."/".device = mkDefault "/dev/sda1"; 143 boot.loader.grub.device = mkDefault "/dev/sda"; 144 } 145 ); 146 }).config 147 ) 148 ); 149 150 makeNetboot = 151 { module, system, ... }: 152 let 153 configEvaled = import lib/eval-config.nix { 154 inherit system; 155 modules = makeModules module { }; 156 }; 157 build = configEvaled.config.system.build; 158 kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target; 159 in 160 configEvaled.pkgs.symlinkJoin { 161 name = "netboot"; 162 paths = [ 163 build.netbootRamdisk 164 build.kernel 165 build.netbootIpxeScript 166 ]; 167 postBuild = '' 168 mkdir -p $out/nix-support 169 echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products 170 echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products 171 echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products 172 ''; 173 preferLocalBuild = true; 174 }; 175 176in 177rec { 178 179 channel = import lib/make-channel.nix { 180 inherit 181 pkgs 182 nixpkgs 183 version 184 versionSuffix 185 ; 186 }; 187 188 manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML); 189 manual = manualHTML; # TODO(@oxij): remove eventually 190 manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub)); 191 nixos-configuration-reference-manpage = buildFromConfig ({ ... }: { }) ( 192 config: config.system.build.manual.nixos-configuration-reference-manpage 193 ); 194 options = 195 (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux; 196 197 # Build the initial ramdisk so Hydra can keep track of its size over time. 198 initialRamdisk = buildFromConfig ({ ... }: { }) (config: config.system.build.initialRamdisk); 199 200 kexec = forMatchingSystems supportedSystems ( 201 system: 202 (import lib/eval-config.nix { 203 inherit system; 204 modules = [ 205 ./modules/installer/netboot/netboot-minimal.nix 206 ]; 207 }).config.system.build.kexecTree 208 ); 209 210 netboot = forMatchingSystems supportedSystems ( 211 system: 212 makeNetboot { 213 module = ./modules/installer/netboot/netboot-minimal.nix; 214 inherit system; 215 } 216 ); 217 218 iso_minimal = forAllSystems ( 219 system: 220 makeIso { 221 module = ./modules/installer/cd-dvd/installation-cd-minimal-combined.nix; 222 type = "minimal"; 223 inherit system; 224 } 225 ); 226 227 iso_graphical = forAllSystems ( 228 system: 229 makeIso { 230 module = ./modules/installer/cd-dvd/installation-cd-graphical-combined.nix; 231 type = "graphical"; 232 inherit system; 233 } 234 ); 235 236 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] ( 237 system: 238 makeSdImage { 239 module = 240 { 241 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix; 242 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix; 243 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix; 244 } 245 .${system}; 246 inherit system; 247 } 248 ); 249 250 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] ( 251 system: 252 makeSdImage { 253 module = 254 { 255 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix; 256 } 257 .${system}; 258 type = "minimal-new-kernel"; 259 inherit system; 260 } 261 ); 262 263 sd_image_new_kernel_no_zfs = forMatchingSystems [ "aarch64-linux" ] ( 264 system: 265 makeSdImage { 266 module = 267 { 268 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-no-zfs-installer.nix; 269 } 270 .${system}; 271 type = "minimal-new-kernel-no-zfs"; 272 inherit system; 273 } 274 ); 275 276 # KVM image for proxmox in VMA format 277 proxmoxImage = forMatchingSystems [ "x86_64-linux" ] ( 278 system: 279 with import ./.. { inherit system; }; 280 281 hydraJob ( 282 (import lib/eval-config.nix { 283 inherit system; 284 modules = [ 285 ./modules/virtualisation/proxmox-image.nix 286 ]; 287 }).config.system.build.VMA 288 ) 289 ); 290 291 # LXC tarball for proxmox 292 proxmoxLXC = forMatchingSystems [ "x86_64-linux" ] ( 293 system: 294 with import ./.. { inherit system; }; 295 296 hydraJob ( 297 (import lib/eval-config.nix { 298 inherit system; 299 modules = [ 300 ./modules/virtualisation/proxmox-lxc.nix 301 ]; 302 }).config.system.build.tarball 303 ) 304 ); 305 306 # A disk image that can be imported to Amazon EC2 and registered as an AMI 307 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 308 system: 309 310 with import ./.. { inherit system; }; 311 312 hydraJob ( 313 (import lib/eval-config.nix { 314 inherit system; 315 modules = [ 316 configuration 317 versionModule 318 ./maintainers/scripts/ec2/amazon-image.nix 319 ]; 320 }).config.system.build.amazonImage 321 ) 322 323 ); 324 amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 325 system: 326 327 with import ./.. { inherit system; }; 328 329 hydraJob ( 330 (import lib/eval-config.nix { 331 inherit system; 332 modules = [ 333 configuration 334 versionModule 335 ./maintainers/scripts/ec2/amazon-image-zfs.nix 336 ]; 337 }).config.system.build.amazonImage 338 ) 339 340 ); 341 342 # An image that can be imported into incus and used for container creation 343 incusContainerImage = 344 forMatchingSystems 345 [ 346 "x86_64-linux" 347 "aarch64-linux" 348 ] 349 ( 350 system: 351 with import ./.. { inherit system; }; 352 353 hydraJob ( 354 (import lib/eval-config.nix { 355 inherit system; 356 modules = [ 357 configuration 358 versionModule 359 ./maintainers/scripts/incus/incus-container-image.nix 360 ]; 361 }).config.system.build.squashfs 362 ) 363 ); 364 365 # Metadata for the incus image 366 incusContainerMeta = 367 forMatchingSystems 368 [ 369 "x86_64-linux" 370 "aarch64-linux" 371 ] 372 ( 373 system: 374 375 with import ./.. { inherit system; }; 376 377 hydraJob ( 378 (import lib/eval-config.nix { 379 inherit system; 380 modules = [ 381 configuration 382 versionModule 383 ./maintainers/scripts/incus/incus-container-image.nix 384 ]; 385 }).config.system.build.metadata 386 ) 387 ); 388 389 # An image that can be imported into incus and used for container creation 390 incusVirtualMachineImage = 391 forMatchingSystems 392 [ 393 "x86_64-linux" 394 "aarch64-linux" 395 ] 396 ( 397 system: 398 399 with import ./.. { inherit system; }; 400 401 hydraJob ( 402 (import lib/eval-config.nix { 403 inherit system; 404 modules = [ 405 configuration 406 versionModule 407 ./maintainers/scripts/incus/incus-virtual-machine-image.nix 408 ]; 409 }).config.system.build.qemuImage 410 ) 411 ); 412 413 # Metadata for the incus image 414 incusVirtualMachineImageMeta = 415 forMatchingSystems 416 [ 417 "x86_64-linux" 418 "aarch64-linux" 419 ] 420 ( 421 system: 422 423 with import ./.. { inherit system; }; 424 425 hydraJob ( 426 (import lib/eval-config.nix { 427 inherit system; 428 modules = [ 429 configuration 430 versionModule 431 ./maintainers/scripts/incus/incus-virtual-machine-image.nix 432 ]; 433 }).config.system.build.metadata 434 ) 435 ); 436 437 # An image that can be imported into lxd and used for container creation 438 lxdContainerImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 439 system: 440 441 with import ./.. { inherit system; }; 442 443 hydraJob ( 444 (import lib/eval-config.nix { 445 inherit system; 446 modules = [ 447 configuration 448 versionModule 449 ./maintainers/scripts/lxd/lxd-container-image.nix 450 ]; 451 }).config.system.build.tarball 452 ) 453 454 ); 455 456 lxdContainerImageSquashfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 457 system: 458 459 with import ./.. { inherit system; }; 460 461 hydraJob ( 462 (import lib/eval-config.nix { 463 inherit system; 464 modules = [ 465 configuration 466 versionModule 467 ./maintainers/scripts/lxd/lxd-container-image.nix 468 ]; 469 }).config.system.build.squashfs 470 ) 471 472 ); 473 474 # Metadata for the lxd image 475 lxdContainerMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 476 system: 477 478 with import ./.. { inherit system; }; 479 480 hydraJob ( 481 (import lib/eval-config.nix { 482 inherit system; 483 modules = [ 484 configuration 485 versionModule 486 ./maintainers/scripts/lxd/lxd-container-image.nix 487 ]; 488 }).config.system.build.metadata 489 ) 490 491 ); 492 493 # An image that can be imported into lxd and used for container creation 494 lxdVirtualMachineImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 495 system: 496 497 with import ./.. { inherit system; }; 498 499 hydraJob ( 500 (import lib/eval-config.nix { 501 inherit system; 502 modules = [ 503 configuration 504 versionModule 505 ./maintainers/scripts/lxd/lxd-virtual-machine-image.nix 506 ]; 507 }).config.system.build.qemuImage 508 ) 509 510 ); 511 512 # Metadata for the lxd image 513 lxdVirtualMachineImageMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] ( 514 system: 515 516 with import ./.. { inherit system; }; 517 518 hydraJob ( 519 (import lib/eval-config.nix { 520 inherit system; 521 modules = [ 522 configuration 523 versionModule 524 ./maintainers/scripts/lxd/lxd-virtual-machine-image.nix 525 ]; 526 }).config.system.build.metadata 527 ) 528 529 ); 530 531 # Ensure that all packages used by the minimal NixOS config end up in the channel. 532 dummy = forAllSystems ( 533 system: 534 pkgs.runCommand "dummy" { 535 toplevel = 536 (import lib/eval-config.nix { 537 inherit system; 538 modules = singleton ( 539 { ... }: 540 { 541 fileSystems."/".device = mkDefault "/dev/sda1"; 542 boot.loader.grub.device = mkDefault "/dev/sda"; 543 system.stateVersion = mkDefault lib.trivial.release; 544 } 545 ); 546 }).config.system.build.toplevel; 547 preferLocalBuild = true; 548 } "mkdir $out; ln -s $toplevel $out/dummy" 549 ); 550 551 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ... 552 containerTarball = forAllSystems ( 553 system: 554 makeSystemTarball { 555 module = ./modules/virtualisation/lxc-container.nix; 556 inherit system; 557 } 558 ); 559 560 tests = allTests; 561 562 /* 563 Build a bunch of typical closures so that Hydra can keep track of 564 the evolution of closure sizes. 565 */ 566 567 closures = { 568 569 smallContainer = makeClosure ( 570 { ... }: 571 { 572 boot.isContainer = true; 573 services.openssh.enable = true; 574 } 575 ); 576 577 tinyContainer = makeClosure ( 578 { ... }: 579 { 580 boot.isContainer = true; 581 imports = [ modules/profiles/minimal.nix ]; 582 } 583 ); 584 585 ec2 = makeClosure ( 586 { ... }: 587 { 588 imports = [ modules/virtualisation/amazon-image.nix ]; 589 } 590 ); 591 592 kde = makeClosure ( 593 { ... }: 594 { 595 services.xserver.enable = true; 596 services.displayManager.sddm.enable = true; 597 services.xserver.desktopManager.plasma5.enable = true; 598 } 599 ); 600 601 xfce = makeClosure ( 602 { ... }: 603 { 604 services.xserver.enable = true; 605 services.xserver.desktopManager.xfce.enable = true; 606 } 607 ); 608 609 gnome = makeClosure ( 610 { ... }: 611 { 612 services.xserver.enable = true; 613 services.xserver.displayManager.gdm.enable = true; 614 services.xserver.desktopManager.gnome.enable = true; 615 } 616 ); 617 618 pantheon = makeClosure ( 619 { ... }: 620 { 621 services.xserver.enable = true; 622 services.xserver.desktopManager.pantheon.enable = true; 623 } 624 ); 625 626 deepin = makeClosure ( 627 { ... }: 628 { 629 services.xserver.enable = true; 630 services.xserver.displayManager.lightdm.enable = true; 631 services.xserver.desktopManager.deepin.enable = true; 632 } 633 ); 634 635 # Linux/Apache/PostgreSQL/PHP stack. 636 lapp = makeClosure ( 637 { pkgs, ... }: 638 { 639 services.httpd.enable = true; 640 services.httpd.adminAddr = "foo@example.org"; 641 services.httpd.enablePHP = true; 642 services.postgresql.enable = true; 643 services.postgresql.package = pkgs.postgresql; 644 } 645 ); 646 }; 647}