10 cfg = config.virtualisation.googleComputeImage;
11 defaultConfigFile = pkgs.writeText "configuration.nix" ''
15 <nixpkgs/nixos/modules/virtualisation/google-compute-image.nix>
23 ./google-compute-config.nix
24 ./disk-size-option.nix
25 ../image/file-options.nix
26 (lib.mkRenamedOptionModuleWith {
41 virtualisation.googleComputeImage.configFile = mkOption {
42 type = with types; nullOr str;
45 A path to a configuration file which will be placed at `/etc/nixos/configuration.nix`
46 and be used when switching to a new configuration.
47 If set to `null`, a default configuration is used, where the only import is
48 `<nixpkgs/nixos/modules/virtualisation/google-compute-image.nix>`.
52 virtualisation.googleComputeImage.compressionLevel = mkOption {
56 GZIP compression level of the resulting disk image (1-9).
59 virtualisation.googleComputeImage.efi = mkEnableOption "EFI booting";
64 boot.initrd.availableKernelModules = [ "nvme" ];
65 boot.loader.grub = mkIf cfg.efi {
66 device = mkForce "nodev";
68 efiInstallAsRemovable = true;
71 fileSystems."/boot" = mkIf cfg.efi {
72 device = "/dev/disk/by-label/ESP";
76 system.nixos.tags = [ "google-compute" ];
77 image.extension = "raw.tar.gz";
78 system.build.image = config.system.build.googleComputeImage;
79 system.build.googleComputeImage = import ../../lib/make-disk-image.nix {
80 name = "google-compute-image";
81 inherit (config.image) baseName;
91 tar -Sc $diskImage | gzip -${toString cfg.compressionLevel} > \
92 ${config.image.fileName}
97 configFile = if cfg.configFile == null then defaultConfigFile else cfg.configFile;
98 partitionTableType = if cfg.efi then "efi" else "legacy";
99 inherit (config.virtualisation) diskSize;
100 inherit config lib pkgs;