virtualisation/digital-ocean: use system.build.image

This commit is contained in:
phaer 2024-11-15 00:34:15 +01:00
parent 41db5209c7
commit 77fce1dc58

View File

@ -14,6 +14,7 @@ in
imports = [
./digital-ocean-config.nix
./disk-size-option.nix
../image/file-options.nix
(lib.mkRenamedOptionModuleWith {
sinceRelease = 2411;
from = [
@ -57,32 +58,53 @@ in
};
#### implementation
config = {
system.build.digitalOceanImage = import ../../lib/make-disk-image.nix {
name = "digital-ocean-image";
config =
let
format = "qcow2";
postVM =
let
compress =
{
"gzip" = "${pkgs.gzip}/bin/gzip";
"bzip2" = "${pkgs.bzip2}/bin/bzip2";
}
.${cfg.compressionMethod};
in
''
${compress} $diskImage
'';
configFile =
if cfg.configFile == null then
config.virtualisation.digitalOcean.defaultConfigFile
else
cfg.configFile;
inherit (config.virtualisation) diskSize;
inherit config lib pkgs;
};
in
{
image.extension = lib.concatStringsSep "." [
format
(
{
"gzip" = "gz";
"bzip2" = "bz2";
}
.${cfg.compressionMethod}
)
];
system.nixos.tags = [ "digital-ocean" ];
system.build.image = config.system.build.digitalOceanImage;
system.build.digitalOceanImage = import ../../lib/make-disk-image.nix {
name = "digital-ocean-image";
inherit (config.image) baseName;
inherit (config.virtualisation) diskSize;
inherit
config
lib
pkgs
format
;
postVM =
let
compress =
{
"gzip" = "${pkgs.gzip}/bin/gzip";
"bzip2" = "${pkgs.bzip2}/bin/bzip2";
}
.${cfg.compressionMethod};
in
''
${compress} $diskImage
'';
configFile =
if cfg.configFile == null then
config.virtualisation.digitalOcean.defaultConfigFile
else
cfg.configFile;
};
};
};
meta.maintainers = with maintainers; [
arianvp