Unverified Commit fb4135b6 authored by Arian van Putten's avatar Arian van Putten Committed by GitHub
Browse files

image/repart: repart.imageFile(BaseName) -> image.baseName, image.extension (#401872)

parents 93def2c1 9e6e5152
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
    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`).
      '';
@@ -29,6 +30,7 @@
    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`).
@@ -38,6 +40,7 @@
    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
+44 −31
Original line number Diff line number Diff line
@@ -88,6 +88,31 @@ in
{
  imports = [
    ./repart-verity-store.nix
    ./file-options.nix
    (lib.mkRenamedOptionModuleWith {
      sinceRelease = 2411;
      from = [
        "image"
        "repart"
        "imageFileBasename"
      ];
      to = [
        "image"
        "baseName"
      ];
    })
    (lib.mkRenamedOptionModuleWith {
      sinceRelease = 2411;
      from = [
        "image"
        "repart"
        "imageFile"
      ];
      to = [
        "image"
        "fileName"
      ];
    })
  ];

  options.image.repart = {
@@ -109,23 +134,6 @@ in
      description = "Version of the image";
    };

    imageFileBasename = lib.mkOption {
      type = lib.types.str;
      readOnly = true;
      description = ''
        Basename of the image filename without any extension (e.g. `image_1`).
      '';
    };

    imageFile = lib.mkOption {
      type = lib.types.str;
      readOnly = true;
      description = ''
        Filename of the image including all extensions (e.g `image_1.raw` or
        `image_1.raw.zst`).
      '';
    };

    compression = {
      enable = lib.mkEnableOption "Image compression";

@@ -253,7 +261,6 @@ in
  };

  config = {

    assertions = lib.mapAttrsToList (
      fileName: partitionConfig:
      let
@@ -295,10 +302,14 @@ in
      ) cfg.partitions
    );

    image.repart =
    image.baseName =
      let
        version = config.image.repart.version;
        versionInfix = if version != null then "_${version}" else "";
      in
      cfg.name + versionInfix;
    image.extension =
      let
        compressionSuffix =
          lib.optionalString cfg.compression.enable
            {
@@ -308,6 +319,11 @@ in
            }
            ."${cfg.compression.algorithm}";

      in
      "raw" + compressionSuffix;

    image.repart =
      let
        makeClosure = paths: pkgs.closureInfo { rootPaths = paths; };

        # Add the closure of the provided Nix store paths to cfg.partitions so
@@ -321,9 +337,6 @@ in
      in
      {
        name = lib.mkIf (config.system.image.id != null) (lib.mkOptionDefault config.system.image.id);
        imageFileBasename = cfg.name + versionInfix;
        imageFile = cfg.imageFileBasename + ".raw" + compressionSuffix;

        compression = {
          # Generally default to slightly faster than default compression
          # levels under the assumption that most of the building will be done
@@ -357,10 +370,10 @@ in
      in
      pkgs.callPackage ./repart-image.nix {
        systemd = cfg.package;
        imageFileBasename = config.image.baseName;
        inherit (cfg)
          name
          version
          imageFileBasename
          compression
          split
          seed