diff options
author | Vincent Bernat <vincent@bernat.ch> | 2018-08-05 20:38:34 +0200 |
---|---|---|
committer | Vincent Bernat <vincent@bernat.ch> | 2018-11-17 20:40:11 +0100 |
commit | 15f98b7192f7f0cde166d0b0a400cffefa5399ff (patch) | |
tree | 3dfb9c8972588c0f46a10f3ad7fde8af8c95b09d /nixos | |
parent | 31adf332170f37cb47aa3b80560a35b4ffc97dc8 (diff) | |
download | nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.tar nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.tar.gz nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.tar.bz2 nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.tar.lz nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.tar.xz nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.tar.zst nixpkgs-15f98b7192f7f0cde166d0b0a400cffefa5399ff.zip |
nixos/cloudstack-image: initial import
Cloudstack images are simply using cloud-init. They are not headless as a user usually have access to a console. Otherwise, the difference with Openstack are mostly handled by cloud-init. This is still some minor issues. Notably, there is no non-root user. Other cloud images usually come with a user named after the distribution and with sudo. Would it make sense for NixOS? Cloudstack gives the user the ability to change the password. Cloud-init support for this is imperfect and the set-passwords module should be declared as `- [set-passwords, always]` for this to work. I don't know if there is an easy way to "patch" default cloud-init configuration. However, without a non-root user, this is of no use. Similarly, hostname is usually set through cloud-init using `set_hostname` and `update_hostname` modules. While the patch to declare nixos to cloud-init contains some code to set hostname, the previously mentioned modules are not enabled.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/maintainers/scripts/cloudstack/cloudstack-image.nix | 23 | ||||
-rw-r--r-- | nixos/modules/virtualisation/cloudstack-config.nix | 40 |
2 files changed, 63 insertions, 0 deletions
diff --git a/nixos/maintainers/scripts/cloudstack/cloudstack-image.nix b/nixos/maintainers/scripts/cloudstack/cloudstack-image.nix new file mode 100644 index 00000000000..37b46db059c --- /dev/null +++ b/nixos/maintainers/scripts/cloudstack/cloudstack-image.nix @@ -0,0 +1,23 @@ +# nix-build '<nixpkgs/nixos>' -A config.system.build.cloudstackImage --arg configuration "{ imports = [ ./nixos/maintainers/scripts/cloudstack/cloudstack-image.nix ]; }" + +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = + [ ../../../modules/virtualisation/cloudstack-config.nix ]; + + system.build.cloudstackImage = import ../../../lib/make-disk-image.nix { + inherit lib config pkgs; + diskSize = 8192; + format = "qcow2"; + configFile = pkgs.writeText "configuration.nix" + '' + { + imports = [ <nixpkgs/nixos/modules/virtualisation/cloudstack-config.nix> ]; + } + ''; + }; + +} diff --git a/nixos/modules/virtualisation/cloudstack-config.nix b/nixos/modules/virtualisation/cloudstack-config.nix new file mode 100644 index 00000000000..81c54567627 --- /dev/null +++ b/nixos/modules/virtualisation/cloudstack-config.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ + ../profiles/qemu-guest.nix + ]; + + config = { + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + autoResize = true; + }; + + boot.growPartition = true; + boot.kernelParams = [ "console=tty0" ]; + boot.loader.grub.device = "/dev/vda"; + boot.loader.timeout = 0; + + # Allow root logins + services.openssh = { + enable = true; + permitRootLogin = "prohibit-password"; + }; + + # Cloud-init configuration. + services.cloud-init.enable = true; + # Wget is needed for setting password. This is of little use as + # root password login is disabled above. + environment.systemPackages = [ pkgs.wget ]; + # Only enable CloudStack datasource for faster boot speed. + environment.etc."cloud/cloud.cfg.d/99_cloudstack.cfg".text = '' + datasource: + CloudStack: {} + None: {} + datasource_list: ["CloudStack"] + ''; + }; +} |