nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

image/images: Adapt remaining images to system.build.image & normalized filenames, (#359345)

authored by

Thiago Kenji Okada and committed by
GitHub
6e6188af c86acd82

+232 -65
+22 -14
nixos/maintainers/scripts/ec2/amazon-image.nix
··· 20 20 imports = [ 21 21 ../../../modules/virtualisation/amazon-image.nix 22 22 ../../../modules/virtualisation/disk-size-option.nix 23 + ../../../modules/image/file-options.nix 23 24 (lib.mkRenamedOptionModuleWith { 24 25 sinceRelease = 2411; 25 26 from = [ ··· 30 29 to = [ 31 30 "virtualisation" 32 31 "diskSize" 32 + ]; 33 + }) 34 + (lib.mkRenamedOptionModuleWith { 35 + sinceRelease = 2505; 36 + from = [ 37 + "amazonImage" 38 + "name" 39 + ]; 40 + to = [ 41 + "image" 42 + "baseName" 33 43 ]; 34 44 }) 35 45 ]; ··· 56 44 [ "nvme_core.io_timeout=${timeout}" ]; 57 45 58 46 options.amazonImage = { 59 - name = mkOption { 60 - type = types.str; 61 - description = "The name of the generated derivation"; 62 - default = "nixos-amazon-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}"; 63 - }; 64 - 65 47 contents = mkOption { 66 48 example = literalExpression '' 67 49 [ { source = pkgs.memtest86 + "/memtest.bin"; ··· 86 80 config.virtualisation.diskSize = lib.mkOverride 1490 (3 * 1024); 87 81 config.virtualisation.diskSizeAutoSupported = !config.ec2.zfs.enable; 88 82 83 + config.system.nixos.tags = [ "amazon" ]; 84 + config.system.build.image = config.system.build.amazonImage; 85 + config.image.extension = cfg.format; 86 + 89 87 config.system.build.amazonImage = 90 88 let 91 89 configFile = pkgs.writeText "configuration.nix" '' ··· 112 102 configFile 113 103 pkgs 114 104 ; 115 - inherit (cfg) contents format name; 105 + inherit (cfg) contents format; 106 + name = config.image.baseName; 116 107 117 108 includeChannel = true; 118 109 ··· 129 118 130 119 postVM = '' 131 120 extension=''${rootDiskImage##*.} 132 - friendlyName=$out/${cfg.name} 121 + friendlyName=$out/${config.image.baseName} 133 122 rootDisk="$friendlyName.root.$extension" 134 123 bootDisk="$friendlyName.boot.$extension" 135 124 mv "$rootDiskImage" "$rootDisk" ··· 167 156 pkgs 168 157 ; 169 158 170 - inherit (cfg) contents format name; 159 + inherit (cfg) contents format; 160 + inherit (config.image) baseName; 161 + name = config.image.baseName; 171 162 172 163 fsType = "ext4"; 173 164 partitionTableType = if config.ec2.efi then "efi" else "legacy+gpt"; ··· 177 164 inherit (config.virtualisation) diskSize; 178 165 179 166 postVM = '' 180 - extension=''${diskImage##*.} 181 - friendlyName=$out/${cfg.name}.$extension 182 - mv "$diskImage" "$friendlyName" 183 - diskImage=$friendlyName 184 - 185 167 mkdir -p $out/nix-support 186 168 echo "file ${cfg.format} $diskImage" >> $out/nix-support/hydra-build-products 187 169
+22 -8
nixos/maintainers/scripts/openstack/openstack-image-zfs.nix
··· 16 16 imports = [ 17 17 ../../../modules/virtualisation/openstack-config.nix 18 18 ../../../modules/virtualisation/disk-size-option.nix 19 + ../../../modules/image/file-options.nix 19 20 (lib.mkRenamedOptionModuleWith { 20 21 sinceRelease = 2411; 21 22 from = [ ··· 28 27 "diskSize" 29 28 ]; 30 29 }) 30 + (lib.mkRenamedOptionModuleWith { 31 + sinceRelease = 2505; 32 + from = [ 33 + "openstackImage" 34 + "name" 35 + ]; 36 + to = [ 37 + "image" 38 + "baseName" 39 + ]; 40 + }) 41 + 31 42 ] ++ (lib.optional copyChannel ../../../modules/installer/cd-dvd/channel.nix); 32 43 33 44 options.openstackImage = { 34 - name = mkOption { 35 - type = types.str; 36 - description = "The name of the generated derivation"; 37 - default = "nixos-openstack-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}"; 38 - }; 39 - 40 45 ramMB = mkOption { 41 46 type = types.int; 42 47 default = (3 * 1024); ··· 79 72 virtualisation.diskSize = lib.mkOverride 1490 (8 * 1024); 80 73 virtualisation.diskSizeAutoSupported = false; 81 74 75 + image.extension = cfg.format; 76 + system.nixos.tags = [ 77 + "openstack" 78 + "zfs" 79 + ]; 80 + system.build.image = config.system.build.openstackImage; 82 81 system.build.openstackImage = import ../../../lib/make-single-disk-zfs-image.nix { 83 82 inherit lib config; 84 - inherit (cfg) contents format name; 83 + inherit (cfg) contents format; 84 + name = config.image.baseName; 85 85 pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package 86 86 87 87 configFile = pkgs.writeText "configuration.nix" '' ··· 112 98 113 99 postVM = '' 114 100 extension=''${rootDiskImage##*.} 115 - friendlyName=$out/${cfg.name} 101 + friendlyName=$out/${config.image.baseName} 116 102 rootDisk="$friendlyName.root.$extension" 117 103 mv "$rootDiskImage" "$rootDisk" 118 104
+7 -2
nixos/maintainers/scripts/openstack/openstack-image.nix
··· 3 3 { config, lib, pkgs, ... }: 4 4 let 5 5 copyChannel = true; 6 + format = "qcow2"; 6 7 in 7 8 { 8 9 imports = [ 9 10 ../../../modules/virtualisation/openstack-config.nix 11 + ../../../modules/image/file-options.nix 10 12 ] ++ (lib.optional copyChannel ../../../modules/installer/cd-dvd/channel.nix); 11 13 12 14 documentation.enable = copyChannel; 13 15 16 + image.extension = format; 17 + system.nixos.tags = [ "openstack" ]; 18 + system.build.image = config.system.build.openstackImage; 14 19 system.build.openstackImage = import ../../../lib/make-disk-image.nix { 15 - inherit lib config copyChannel; 20 + inherit lib config copyChannel format; 21 + inherit (config.image) baseName; 16 22 additionalSpace = "1024M"; 17 23 pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package 18 - format = "qcow2"; 19 24 configFile = pkgs.writeText "configuration.nix" 20 25 '' 21 26 {
+35
nixos/modules/image/images.nix
··· 9 9 inherit (lib) types; 10 10 11 11 imageModules = { 12 + amazon = [ ../../maintainers/scripts/ec2/amazon-image.nix ]; 12 13 azure = [ ../virtualisation/azure-image.nix ]; 13 14 digital-ocean = [ ../virtualisation/digital-ocean-image.nix ]; 14 15 google-compute = [ ../virtualisation/google-compute-image.nix ]; ··· 18 17 lxc = [ ../virtualisation/lxc-container.nix ]; 19 18 lxc-metadata = [ ../virtualisation/lxc-image-metadata.nix ]; 20 19 oci = [ ../virtualisation/oci-image.nix ]; 20 + openstack = [ ../../maintainers/scripts/openstack/openstack-image.nix ]; 21 + openstack-zfs = [ ../../maintainers/scripts/openstack/openstack-image-zfs.nix ]; 21 22 proxmox = [ ../virtualisation/proxmox-image.nix ]; 23 + proxmox-lxc = [ ../virtualisation/proxmox-lxc.nix ]; 24 + qemu-efi = [ ../virtualisation/disk-image.nix ]; 25 + qemu = [ 26 + ../virtualisation/disk-image.nix 27 + { 28 + image.efiSupport = false; 29 + } 30 + ]; 31 + raw-efi = [ 32 + ../virtualisation/disk-image.nix 33 + { 34 + image.format = "raw"; 35 + } 36 + ]; 37 + raw = [ 38 + ../virtualisation/disk-image.nix 39 + { 40 + image.format = "raw"; 41 + image.efiSupport = false; 42 + } 43 + ]; 22 44 kubevirt = [ ../virtualisation/kubevirt.nix ]; 23 45 vagrant-virtualbox = [ ../virtualisation/vagrant-virtualbox-image.nix ]; 24 46 virtualbox = [ ../virtualisation/virtualbox-image.nix ]; 25 47 vmware = [ ../virtualisation/vmware-image.nix ]; 48 + iso = [ ../installer/cd-dvd/iso-image.nix ]; 49 + iso-installer = [ ../installer/cd-dvd/installation-cd-base.nix ]; 50 + sd-card = [ 51 + ( 52 + let 53 + module = ../. + "/installer/sd-card/sd-image-${pkgs.targetPlatform.linuxArch}.nix"; 54 + in 55 + if builtins.pathExists module then module else throw "The module ${module} does not exist." 56 + ) 57 + ]; 58 + kexec = [ ../installer/netboot/netboot-minimal.nix ]; 26 59 }; 27 60 imageConfigs = lib.mapAttrs ( 28 61 name: modules:
-3
nixos/modules/installer/cd-dvd/installation-cd-base.nix
··· 15 15 # Adds terminus_font for people with HiDPI displays 16 16 console.packages = options.console.packages.default ++ [ pkgs.terminus_font ]; 17 17 18 - # ISO naming. 19 - isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.iso"; 20 - 21 18 # EFI booting 22 19 isoImage.makeEfiBootable = true; 23 20
+31 -17
nixos/modules/installer/cd-dvd/iso-image.nix
··· 476 476 in 477 477 478 478 { 479 + imports = [ 480 + (lib.mkRenamedOptionModuleWith { 481 + sinceRelease = 2505; 482 + from = [ 483 + "isoImage" 484 + "isoBaseName" 485 + ]; 486 + to = [ 487 + "image" 488 + "baseName" 489 + ]; 490 + }) 491 + (lib.mkRenamedOptionModuleWith { 492 + sinceRelease = 2505; 493 + from = [ 494 + "isoImage" 495 + "isoName" 496 + ]; 497 + to = [ 498 + "image" 499 + "fileName" 500 + ]; 501 + }) 502 + ../../image/file-options.nix 503 + ]; 504 + 479 505 options = { 480 - 481 - isoImage.isoName = lib.mkOption { 482 - default = "${config.isoImage.isoBaseName}.iso"; 483 - type = lib.types.str; 484 - description = '' 485 - Name of the generated ISO image file. 486 - ''; 487 - }; 488 - 489 - isoImage.isoBaseName = lib.mkOption { 490 - default = config.system.nixos.distroId; 491 - type = lib.types.str; 492 - description = '' 493 - Prefix of the name of the generated ISO image file. 494 - ''; 495 - }; 496 506 497 507 isoImage.compressImage = lib.mkOption { 498 508 default = false; ··· 868 858 boot.loader.timeout = 10; 869 859 870 860 # Create the ISO image. 861 + image.extension = if config.isoImage.compressImage then "iso.zst" else "iso"; 862 + image.filePath = "iso/${config.image.fileName}"; 863 + system.build.image = config.system.build.isoImage; 871 864 system.build.isoImage = pkgs.callPackage ../../../lib/make-iso9660-image.nix ({ 872 - inherit (config.isoImage) isoName compressImage volumeID contents; 865 + inherit (config.isoImage) compressImage volumeID contents; 866 + isoName = "${config.image.baseName}.iso"; 873 867 bootable = config.isoImage.makeBiosBootable; 874 868 bootImage = "/isolinux/isolinux.bin"; 875 869 syslinux = if config.isoImage.makeBiosBootable then pkgs.syslinux else null;
+20 -1
nixos/modules/installer/netboot/netboot.nix
··· 1 1 # This module creates netboot media containing the given NixOS 2 2 # configuration. 3 3 4 - { config, lib, pkgs, ... }: 4 + { config, lib, pkgs, modulesPath, ... }: 5 5 6 6 with lib; 7 7 8 8 { 9 + imports = [ 10 + ../../image/file-options.nix 11 + ]; 12 + 9 13 options = { 10 14 11 15 netboot.squashfsCompression = mkOption { ··· 132 128 path = config.system.build.kexecScript; 133 129 } 134 130 ]; 131 + 132 + image.extension = "tar.xz"; 133 + image.filePath = "tarball/${config.image.fileName}"; 134 + system.nixos.tags = [ "kexec" ]; 135 + system.build.image = config.system.build.kexecTarball; 136 + system.build.kexecTarball = pkgs.callPackage "${toString modulesPath}/../lib/make-system-tarball.nix" { 137 + fileName = config.image.baseName; 138 + storeContents = [ 139 + { 140 + object = config.system.build.kexecScript; 141 + symlink = "/kexec_nixos"; 142 + } 143 + ]; 144 + contents = []; 145 + }; 135 146 136 147 boot.loader.timeout = 10; 137 148
+31 -17
nixos/modules/installer/sd-card/sd-image.nix
··· 29 29 imports = [ 30 30 (mkRemovedOptionModule [ "sdImage" "bootPartitionID" ] "The FAT partition for SD image now only holds the Raspberry Pi firmware files. Use firmwarePartitionID to configure that partition's ID.") 31 31 (mkRemovedOptionModule [ "sdImage" "bootSize" ] "The boot files for SD image have been moved to the main ext4 partition. The FAT partition now only holds the Raspberry Pi firmware files. Changing its size may not be required.") 32 + (lib.mkRenamedOptionModuleWith { 33 + sinceRelease = 2505; 34 + from = [ 35 + "sdImage" 36 + "imageBaseName" 37 + ]; 38 + to = [ 39 + "image" 40 + "baseName" 41 + ]; 42 + }) 43 + (lib.mkRenamedOptionModuleWith { 44 + sinceRelease = 2505; 45 + from = [ 46 + "sdImage" 47 + "imageName" 48 + ]; 49 + to = [ 50 + "image" 51 + "fileName" 52 + ]; 53 + }) 54 + ../../profiles/all-hardware.nix 55 + ../../image/file-options.nix 32 56 ]; 33 57 34 58 options.sdImage = { 35 - imageName = mkOption { 36 - default = "${config.sdImage.imageBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.img"; 37 - description = '' 38 - Name of the generated image file. 39 - ''; 40 - }; 41 - 42 - imageBaseName = mkOption { 43 - default = "nixos-sd-image"; 44 - description = '' 45 - Prefix of the name of the generated image file. 46 - ''; 47 - }; 48 - 49 59 storePaths = mkOption { 50 60 type = with types; listOf package; 51 61 example = literalExpression "[ pkgs.stdenv ]"; ··· 190 180 191 181 sdImage.storePaths = [ config.system.build.toplevel ]; 192 182 183 + image.extension = if config.sdImage.compressImage then "img.zst" else "img"; 184 + image.filePath = "sd-card/${config.image.fileName}"; 185 + system.nixos.tags = [ "sd-card" ]; 186 + system.build.image = config.system.build.sdImage; 193 187 system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs, 194 188 mtools, libfaketime, util-linux, zstd }: stdenv.mkDerivation { 195 - name = config.sdImage.imageName; 189 + name = config.image.fileName; 196 190 197 191 nativeBuildInputs = [ dosfstools e2fsprogs libfaketime mtools util-linux ] 198 192 ++ lib.optional config.sdImage.compressImage zstd; 199 193 200 - inherit (config.sdImage) imageName compressImage; 194 + inherit (config.sdImage) compressImage; 201 195 202 196 buildCommand = '' 203 197 mkdir -p $out/nix-support $out/sd-image 204 - export img=$out/sd-image/${config.sdImage.imageName} 198 + export img=$out/sd-image/${config.image.baseName}.img 205 199 206 200 echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system 207 201 if test -n "$compressImage"; then
+61
nixos/modules/virtualisation/disk-image.nix
··· 1 + { 2 + config, 3 + lib, 4 + pkgs, 5 + ... 6 + }: 7 + let 8 + cfg = config.image; 9 + in 10 + { 11 + imports = [ 12 + ./disk-size-option.nix 13 + ../image/file-options.nix 14 + ]; 15 + 16 + options.image = { 17 + format = lib.mkOption { 18 + description = "Format of the disk image to generate: raw or qcow2"; 19 + type = lib.types.enum [ 20 + "raw" 21 + "qcow2" 22 + ]; 23 + default = "qcow2"; 24 + }; 25 + efiSupport = lib.mkOption { 26 + description = "Whether the disk image should support EFI boot or legacy boot"; 27 + type = lib.types.bool; 28 + default = true; 29 + }; 30 + }; 31 + 32 + config = { 33 + boot.loader.grub = lib.mkIf (!cfg.efiSupport) { 34 + enable = lib.mkOptionDefault true; 35 + devices = lib.mkDefault [ "/dev/vda" ]; 36 + }; 37 + boot.loader.systemd-boot.enable = lib.mkDefault cfg.efiSupport; 38 + boot.growPartition = lib.mkDefault true; 39 + 40 + fileSystems = { 41 + "/" = { 42 + device = "/dev/disk/by-label/nixos"; 43 + autoResize = true; 44 + fsType = "ext4"; 45 + }; 46 + "/boot" = lib.mkIf (cfg.efiSupport) { 47 + device = "/dev/disk/by-label/ESP"; 48 + fsType = "vfat"; 49 + }; 50 + }; 51 + 52 + system.nixos.tags = [ cfg.format ] ++ lib.optionals cfg.efiSupport [ "efi" ]; 53 + image.extension = cfg.format; 54 + system.build.image = import ../../lib/make-disk-image.nix { 55 + inherit lib config pkgs; 56 + inherit (config.virtualisation) diskSize; 57 + inherit (cfg) baseName format; 58 + partitionTableType = if cfg.efiSupport then "efi" else "legacy"; 59 + }; 60 + }; 61 + }
+1 -1
nixos/release.nix
··· 62 62 hydraJob ((import lib/eval-config.nix { 63 63 inherit system; 64 64 modules = makeModules module { 65 - isoImage.isoBaseName = "nixos-${type}"; 65 + image.baseName = "nixos-${type}"; 66 66 }; 67 67 }).config.system.build.isoImage); 68 68
+1 -1
nixos/tests/ec2.nix
··· 55 55 } 56 56 ]; 57 57 }).config; 58 - image = "${imageCfg.system.build.amazonImage}/${imageCfg.amazonImage.name}.qcow2"; 58 + image = "${imageCfg.system.build.amazonImage}/${imageCfg.image.imageFile}"; 59 59 60 60 sshKeys = import ./ssh-keys.nix pkgs; 61 61 snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
+1 -1
pkgs/desktops/gnome/installer.nix
··· 7 7 8 8 config = (import ../../../../nixos/lib/eval-config.nix { 9 9 inherit system; 10 - modules = [ module { isoImage.isoBaseName = isoBaseName; } ] ++ extraModules; 10 + modules = [ module { image.baseName = isoBaseName; } ] ++ extraModules; 11 11 }).config; 12 12 13 13 in