nixos/repart-image: add internal option to expose finalPartitions
This commit is contained in:
parent
d7ef2defda
commit
5282cdd926
|
@ -211,6 +211,15 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
finalPartitions = lib.mkOption {
|
||||||
|
type = lib.types.attrs;
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Convenience option to access partitions with added closures.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
@ -224,6 +233,16 @@ in
|
||||||
"zstd" = ".zst";
|
"zstd" = ".zst";
|
||||||
"xz" = ".xz";
|
"xz" = ".xz";
|
||||||
}."${cfg.compression.algorithm}";
|
}."${cfg.compression.algorithm}";
|
||||||
|
|
||||||
|
makeClosure = paths: pkgs.closureInfo { rootPaths = paths; };
|
||||||
|
|
||||||
|
# Add the closure of the provided Nix store paths to cfg.partitions so
|
||||||
|
# that amend-repart-definitions.py can read it.
|
||||||
|
addClosure = _name: partitionConfig: partitionConfig // (
|
||||||
|
lib.optionalAttrs
|
||||||
|
(partitionConfig.storePaths or [ ] != [ ])
|
||||||
|
{ closure = "${makeClosure partitionConfig.storePaths}/store-paths"; }
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = lib.mkIf (config.system.image.id != null) (lib.mkOptionDefault config.system.image.id);
|
name = lib.mkIf (config.system.image.id != null) (lib.mkOptionDefault config.system.image.id);
|
||||||
|
@ -239,6 +258,8 @@ in
|
||||||
"xz" = 3;
|
"xz" = 3;
|
||||||
}."${cfg.compression.algorithm}";
|
}."${cfg.compression.algorithm}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
finalPartitions = lib.mapAttrs addClosure cfg.partitions;
|
||||||
};
|
};
|
||||||
|
|
||||||
system.build.image =
|
system.build.image =
|
||||||
|
@ -247,26 +268,15 @@ in
|
||||||
(f: f != null)
|
(f: f != null)
|
||||||
(lib.mapAttrsToList (_n: v: v.repartConfig.Format or null) cfg.partitions);
|
(lib.mapAttrsToList (_n: v: v.repartConfig.Format or null) cfg.partitions);
|
||||||
|
|
||||||
makeClosure = paths: pkgs.closureInfo { rootPaths = paths; };
|
|
||||||
|
|
||||||
# Add the closure of the provided Nix store paths to cfg.partitions so
|
|
||||||
# that amend-repart-definitions.py can read it.
|
|
||||||
addClosure = _name: partitionConfig: partitionConfig // (
|
|
||||||
lib.optionalAttrs
|
|
||||||
(partitionConfig.storePaths or [ ] != [ ])
|
|
||||||
{ closure = "${makeClosure partitionConfig.storePaths}/store-paths"; }
|
|
||||||
);
|
|
||||||
|
|
||||||
finalPartitions = lib.mapAttrs addClosure cfg.partitions;
|
|
||||||
|
|
||||||
format = pkgs.formats.ini { };
|
format = pkgs.formats.ini { };
|
||||||
|
|
||||||
definitionsDirectory = utils.systemdUtils.lib.definitions
|
definitionsDirectory = utils.systemdUtils.lib.definitions
|
||||||
"repart.d"
|
"repart.d"
|
||||||
format
|
format
|
||||||
(lib.mapAttrs (_n: v: { Partition = v.repartConfig; }) finalPartitions);
|
(lib.mapAttrs (_n: v: { Partition = v.repartConfig; }) cfg.finalPartitions);
|
||||||
|
|
||||||
partitionsJSON = pkgs.writeText "partitions.json" (builtins.toJSON finalPartitions);
|
partitionsJSON = pkgs.writeText "partitions.json" (builtins.toJSON cfg.finalPartitions);
|
||||||
|
|
||||||
mkfsEnv = mkfsOptionsToEnv cfg.mkfsOptions;
|
mkfsEnv = mkfsOptionsToEnv cfg.mkfsOptions;
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in New Issue
Block a user