Skip to content

Instantly share code, notes, and snippets.

@theduke
Created September 15, 2020 16:45
Show Gist options
  • Save theduke/4d19eda2b2f3de9161de9317ded2ffe7 to your computer and use it in GitHub Desktop.
Save theduke/4d19eda2b2f3de9161de9317ded2ffe7 to your computer and use it in GitHub Desktop.
Nix VM qcow2
{ config, lib, pkgs, ... }:
{
imports =
[
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
];
system.build.qcow2 = import <nixpkgs/nixos/lib/make-disk-image.nix> {
pkgs = import <nixpkgs> { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
diskSize = 8192;
format = "qcow2";
configFile = pkgs.writeText "configuration.nix"
''
{ pkgs, lib, ... }:
{
imports = [
<nixpkgs/nixos/modules/profiles/qemu-guest.nix>
];
config = {
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
autoResize = true;
};
boot.growPartition = true;
boot.kernelParams = [ "console=ttyS0" ];
boot.loader.grub.device = "/dev/sda";
boot.loader.timeout = 0;
security.sudo.enable = false;
users.extraUsers.root.password = "";
};
}
'';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment