summaryrefslogtreecommitdiffstats
path: root/nixos/modules/image/file-options.nix
blob: 4a6b377111a0dfe289124f0ccd58310d5719ff73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
  lib,
  config,
  pkgs,
  ...
}:
{
  options.image = {
    baseName = lib.mkOption {
      type = lib.types.str;
      default = "nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}";
      defaultText = lib.literalExpression "nixos-image-\${config.system.nixos.label}-\${pkgs.stdenv.hostPlatform.system}";
      description = ''
        Basename of the image filename without any extension (e.g. `image_1`).
      '';
    };

    extension = lib.mkOption {
      type = lib.types.str;
      description = ''
        Extension of the image filename (e.g. `raw`).
      '';
    };

    # FIXME: this should be marked readOnly, when there are no
    # mkRenamedOptionModuleWith calls with `image.fileName` as
    # as a target left anymore (i.e. 24.11). We can't do it
    # before, as some source options where writable before.
    # Those should use image.baseName and image.extension instead.
    fileName = lib.mkOption {
      type = lib.types.str;
      default = "${config.image.baseName}.${config.image.extension}";
      defaultText = lib.literalExpression "\${config.image.baseName}.\${config.image.extension}";
      description = ''
        Filename of the image including all extensions (e.g `image_1.raw` or
        `image_1.raw.zst`).
      '';
    };

    filePath = lib.mkOption {
      type = lib.types.str;
      default = config.image.fileName;
      defaultText = lib.literalExpression "config.image.fileName";
      description = ''
        Path of the image, relative to `$out` in `system.build.image`.
        While it defaults to `config.image.fileName`, it can be different for builders where
        the image is in sub directory, such as `iso`, `sd-card` or `kexec` images.
      '';
    };
  };
}