summary refs log tree commit diff
path: root/nixos/modules/virtualisation/cloud-image.nix
blob: 0f0141abfb1664874f0a9560ffd90334a17728a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}