Created
August 17, 2020 07:58
-
-
Save flokli/734a1224e931af4b52561c436ca09ce1 to your computer and use it in GitHub Desktop.
build NixOS qcow image for serial testing
This file contains 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
# stolen from https://gist.github.com/tarnacious/f9674436fff0efeb4bb6585c79a3b9ff | |
{ config, lib, pkgs, ... }: | |
with lib; | |
{ | |
imports = | |
[ | |
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix> | |
./configuration.nix | |
]; | |
system.build.qcow2 = import <nixpkgs/nixos/lib/make-disk-image.nix> { | |
inherit lib config; | |
pkgs = import <nixpkgs> { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package | |
diskSize = 8192; | |
format = "qcow2"; | |
configFile = pkgs.writeText "configuration.nix" | |
'' | |
{ | |
imports = [ <./machine-config.nix> ]; | |
} | |
''; | |
}; | |
} |
This file contains 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
{ config, pkgs, ... }: | |
{ | |
imports = | |
[ | |
<nixpkgs/nixos/modules/profiles/qemu-guest.nix> | |
]; | |
boot.loader.grub.enable = true; | |
boot.loader.grub.version = 2; | |
boot.loader.grub.device = "/dev/vda"; | |
boot.kernelPackages = pkgs.linuxPackages_latest; | |
boot.loader.timeout = 30; | |
fileSystems."/" = { | |
device = "/dev/disk/by-label/nixos"; | |
fsType = "ext4"; | |
autoResize = true; | |
}; | |
boot.loader.grub.extraConfig = '' | |
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 | |
terminal_input --append serial | |
terminal_output --append serial | |
''; | |
boot.kernelParams = [ "console=ttyS0,115200" ]; | |
networking.hostName = "console-kaputt-vm"; | |
networking.useDHCP = false; | |
networking.useNetworkd = false; | |
networking.interfaces.enp1s0.useDHCP = true; | |
i18n.defaultLocale = "en_US.UTF-8"; | |
console = { | |
font = "Lat2-Terminus16"; | |
keyMap = "de"; | |
}; | |
time.timeZone = "Europe/Berlin"; | |
environment.systemPackages = with pkgs; [ | |
vim | |
w3m | |
wget | |
]; | |
programs.less.enable = true; | |
programs.ssh.startAgent = true; | |
programs.vim.defaultEditor = true; | |
services.openssh.enable = true; | |
sound.enable = false; | |
hardware.pulseaudio.enable = false; | |
users.users.jane = { | |
isNormalUser = true; | |
extraGroups = [ "wheel" ]; | |
initialPassword = "supersecret"; | |
}; | |
system.stateVersion = "20.03"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment