mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/virtualisation/linode-image: init (#155426)
This commit is contained in:
parent
88a2353643
commit
28e90d3709
5 changed files with 157 additions and 0 deletions
66
nixos/modules/virtualisation/linode-image.nix
Normal file
66
nixos/modules/virtualisation/linode-image.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.virtualisation.linodeImage;
|
||||
defaultConfigFile = pkgs.writeText "configuration.nix" ''
|
||||
_: {
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/virtualisation/linode-image.nix>
|
||||
];
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
imports = [ ./linode-config.nix ];
|
||||
|
||||
options = {
|
||||
virtualisation.linodeImage.diskSize = mkOption {
|
||||
type = with types; either (enum (singleton "auto")) ints.positive;
|
||||
default = "auto";
|
||||
example = 1536;
|
||||
description = ''
|
||||
Size of disk image in MB.
|
||||
'';
|
||||
};
|
||||
|
||||
virtualisation.linodeImage.configFile = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
A path to a configuration file which will be placed at `/etc/nixos/configuration.nix`
|
||||
and be used when switching to a new configuration.
|
||||
If set to `null`, a default configuration is used, where the only import is
|
||||
`<nixpkgs/nixos/modules/virtualisation/linode-image.nix>`
|
||||
'';
|
||||
};
|
||||
|
||||
virtualisation.linodeImage.compressionLevel = mkOption {
|
||||
type = types.ints.between 1 9;
|
||||
default = 6;
|
||||
description = ''
|
||||
GZIP compression level of the resulting disk image (1-9).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
system.build.linodeImage = import ../../lib/make-disk-image.nix {
|
||||
name = "linode-image";
|
||||
# NOTE: Linode specifically requires images to be `gzip`-ed prior to upload
|
||||
# See: https://www.linode.com/docs/products/tools/images/guides/upload-an-image/#requirements-and-considerations
|
||||
postVM = ''
|
||||
${pkgs.gzip}/bin/gzip -${toString cfg.compressionLevel} -c -- $diskImage > \
|
||||
$out/nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.img.gz
|
||||
rm $diskImage
|
||||
'';
|
||||
format = "raw";
|
||||
partitionTableType = "none";
|
||||
configFile = if cfg.configFile == null then defaultConfigFile else cfg.configFile;
|
||||
inherit (cfg) diskSize;
|
||||
inherit config lib pkgs;
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = with maintainers; [ houstdav000 ];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue