Skip to content

Latest commit

 

History

History

google_image_nixos

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

google_image_nixos

This terraform module creates a new image in the Google Cloud project using a public tarballs of a NixOS release. Those tarballs are released by the NixOS project.

Since image names are unique, only one instance per version of the module is supported per Google Cloud project.

Example

module "nixos_image_1809" {
  source = "github.com/tweag/terraform-nixos/google_image_nixos"
  nixos_version = "18.09"
}

resource "google_compute_instance" "example" {
  name         = "example"
  machine_type = "n1-standard-1"
  zone         = "us-central1-a"

  boot_disk {
    initialize_params {
      image = module.nixos_image_1809.self_link
    }
  }

  network_interface {
    network       = "default"
  }
}

Default configuration.nix

A new configuration.nix can be passed trough the userdata. Here is the default configuration to expand upon:

{ modulesPath, ... }:
{
  imports = [
    "${toString modulesPath}/virtualisation/google-compute-image.nix"
  ];
}

New NixOS releases

Run the ./update-url-map script to fetch new image releases. Please submit a PR as well!

Providers

Name Version
google n/a

Inputs

Name Description Type Default Required
gcp_project_id The ID of the project in which the resource belongs. If it is not provided, the provider project is used. string "" no
licenses A list of license URIs to apply to this image. Changing this forces a new resource to be created. list(string)
[
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"
]
no
nixos_version The NixOS version to use. Eg: 18.09 string "latest" no
url_map A map of release series to actual releases map(string)
{
"14.12": "https://nixos-cloud-images.storage.googleapis.com/nixos-14.12.471.1f09b77-x86_64-linux.raw.tar.gz",
"15.09": "https://nixos-cloud-images.storage.googleapis.com/nixos-15.09.425.7870f20-x86_64-linux.raw.tar.gz",
"16.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-16.03.847.8688c17-x86_64-linux.raw.tar.gz",
"17.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-17.03.1082.4aab5c5798-x86_64-linux.raw.tar.gz",
"18.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.03.132536.fdb5ba4cdf9-x86_64-linux.raw.tar.gz",
"18.09": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.09.1228.a4c4cbb613c-x86_64-linux.raw.tar.gz",
"20.03": "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz",
"latest": "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"
}
no

Outputs

Name Description
self_link Link to the NixOS Compute Image