Created
September 14, 2018 23:25
-
-
Save andir/88458b13c26a04752854608aacb15c8f to your computer and use it in GitHub Desktop.
nixos vm qcow2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
imports = [ | |
# configure the mountpoint of the root device | |
({ | |
fileSystems."/".device = "/dev/disk/by-label/nixos"; | |
}) | |
# configure the bootloader | |
({ | |
boot.loader.grub.extraConfig = '' | |
serial --unit=0 --speed=115200 | |
terminal_output serial console; terminal_input serial console | |
''; | |
boot.kernelParams = [ | |
"console=tty0" | |
"console=ttyS0,115200n8" | |
]; | |
boot.loader.grub.device = "/dev/sda"; | |
boot.loader.grub.version = 2; | |
}) | |
# openssh and user configuration | |
({ | |
services.openssh.enable = true; | |
users.users."root".initialPassword = "r00t"; | |
}) | |
]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {}}: | |
let | |
image = (import <nixpkgs/nixos/lib/eval-config.nix> { | |
modules = [ | |
# expression that exposes the configuration as vm image | |
({config, lib, pkgs, ...}: { | |
system.build.qcow2 = import <nixpkgs/nixos/lib/make-disk-image.nix> { | |
inherit lib config pkgs; | |
diskSize = 8192; | |
format = "qcow2-compressed"; | |
configFile = ./configuration.nix; | |
}; | |
}) | |
./configuration.nix | |
]; | |
}).config.system.build.qcow2; | |
in | |
{ | |
inherit image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment