image/images: init (#359328)

authored by Jörg Thalheim and committed by GitHub 43f6a895 41961a54

+105
+48
nixos/modules/image/file-options.nix
··· 1 + { 2 + lib, 3 + config, 4 + pkgs, 5 + ... 6 + }: 7 + { 8 + options.image = { 9 + baseName = lib.mkOption { 10 + type = lib.types.str; 11 + default = "nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}"; 12 + description = '' 13 + Basename of the image filename without any extension (e.g. `image_1`). 14 + ''; 15 + }; 16 + 17 + extension = lib.mkOption { 18 + type = lib.types.str; 19 + description = '' 20 + Extension of the image filename (e.g. `raw`). 21 + ''; 22 + }; 23 + 24 + # FIXME: this should be marked readOnly, when there are no 25 + # mkRenamedOptionModuleWith calls with `image.fileName` as 26 + # as a target left anymore (i.e. 24.11). We can't do it 27 + # before, as some source options where writable before. 28 + # Those should use image.baseName and image.extension instead. 29 + fileName = lib.mkOption { 30 + type = lib.types.str; 31 + default = "${config.image.baseName}.${config.image.extension}"; 32 + description = '' 33 + Filename of the image including all extensions (e.g `image_1.raw` or 34 + `image_1.raw.zst`). 35 + ''; 36 + }; 37 + 38 + filePath = lib.mkOption { 39 + type = lib.types.str; 40 + default = config.image.fileName; 41 + description = '' 42 + Path of the image, relative to `$out` in `system.build.image`. 43 + While it defaults to `config.image.fileName`, it can be different for builders where 44 + the image is in sub directory, such as `iso`, `sd-card` or `kexec` images. 45 + ''; 46 + }; 47 + }; 48 + }
+56
nixos/modules/image/images.nix
··· 1 + { 2 + config, 3 + lib, 4 + pkgs, 5 + extendModules, 6 + ... 7 + }: 8 + let 9 + inherit (lib) types; 10 + 11 + imageModules = { }; 12 + imageConfigs = lib.mapAttrs ( 13 + name: modules: 14 + extendModules { 15 + inherit modules; 16 + } 17 + ) config.image.modules; 18 + in 19 + { 20 + options = { 21 + system.build = { 22 + images = lib.mkOption { 23 + type = types.lazyAttrsOf types.raw; 24 + readOnly = true; 25 + description = '' 26 + Different target images generated for this NixOS configuration. 27 + ''; 28 + }; 29 + }; 30 + image.modules = lib.mkOption { 31 + type = types.attrsOf (types.listOf types.deferredModule); 32 + description = '' 33 + image-specific NixOS Modules used for `system.build.images`. 34 + ''; 35 + }; 36 + }; 37 + 38 + config.image.modules = lib.mkIf (!config.system.build ? image) imageModules; 39 + config.system.build.images = lib.mkIf (!config.system.build ? image) ( 40 + lib.mapAttrs ( 41 + name: nixos: 42 + let 43 + inherit (nixos) config; 44 + inherit (config.image) filePath; 45 + builder = 46 + config.system.build.image 47 + or (throw "Module for `system.build.images.${name}` misses required `system.build.image` option."); 48 + in 49 + lib.recursiveUpdate builder { 50 + passthru = { 51 + inherit config filePath; 52 + }; 53 + } 54 + ) imageConfigs 55 + ); 56 + }
+1
nixos/modules/module-list.nix
··· 125 125 ./i18n/input-method/kime.nix 126 126 ./i18n/input-method/nabi.nix 127 127 ./i18n/input-method/uim.nix 128 + ./image/images.nix 128 129 ./installer/tools/tools.nix 129 130 ./misc/assertions.nix 130 131 ./misc/crashdump.nix