summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAlexander Gall <alexander.gall@gmail.com>2017-08-07 12:27:55 +0200
committerAlexander Gall <alexander.gall@gmail.com>2017-08-07 13:03:02 +0200
commita0a4bea2a6a5ccf4c367e7f71df824c44b2d547b (patch)
treeaca1c06939dc099461ec1fbf0f020e9e274fb8f5 /nixos
parentf152749c9940cda448153aa4d36dcaea538af8b1 (diff)
downloadnixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.tar
nixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.tar.gz
nixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.tar.bz2
nixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.tar.lz
nixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.tar.xz
nixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.tar.zst
nixpkgs-a0a4bea2a6a5ccf4c367e7f71df824c44b2d547b.zip
nixos/cloud-image: add module
The module creates an image for an openstack-based cloud using the
cloud-init package.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/cloud-image.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/cloud-image.nix b/nixos/modules/virtualisation/cloud-image.nix
new file mode 100644
index 00000000000..0f0141abfb1
--- /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 '<nixpkgs/nixos>' -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 = [ <nixpkgs/nixos/modules/virtualisation/cloud-image.nix> ];
+        }
+      '';
+  };
+
+  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;
+}