From a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b Mon Sep 17 00:00:00 2001 From: Alexander Gall Date: Mon, 7 Aug 2017 12:27:55 +0200 Subject: [PATCH] nixos/cloud-image: add module The module creates an image for an openstack-based cloud using the cloud-init package. --- nixos/modules/virtualisation/cloud-image.nix | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 nixos/modules/virtualisation/cloud-image.nix diff --git a/nixos/modules/virtualisation/cloud-image.nix b/nixos/modules/virtualisation/cloud-image.nix new file mode 100644 index 000000000000..0f0141abfb16 --- /dev/null +++ b/nixos/modules/virtualisation/cloud-image.nix @@ -0,0 +1,44 @@ +# Usage: +# $ NIX_PATH=`pwd`:nixos-config=`pwd`/nixpkgs/nixos/modules/virtualisation/cloud-image.nix nix-build '' -A config.system.build.cloudImage + +{ config, lib, pkgs, ... }: + +with lib; + +{ + system.build.cloudImage = import ../../lib/make-disk-image.nix { + inherit pkgs lib config; + partitioned = true; + diskSize = 1 * 1024; + configFile = pkgs.writeText "configuration.nix" + '' + { config, lib, pkgs, ... }: + + with lib; + + { + imports = [ ]; + } + ''; + }; + + imports = [ ../profiles/qemu-guest.nix ]; + + fileSystems."/".device = "/dev/disk/by-label/nixos"; + + boot = { + kernelParams = [ "console=ttyS0" ]; + loader.grub.device = "/dev/vda"; + loader.timeout = 0; + }; + + networking.hostName = mkDefault ""; + + services.openssh = { + enable = true; + permitRootLogin = "without-password"; + passwordAuthentication = mkDefault false; + }; + + services.cloud-init.enable = true; +}