From f043d47382690dfdd024d6609e1ca19769db430a Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Fri, 24 May 2024 23:31:04 +0200 Subject: [PATCH] Add VM conf --- README.md | 25 +++++++++++++++++++++++++ hosts/nixos-test/default.nix | 10 ++++++++++ 2 files changed, 35 insertions(+) diff --git a/README.md b/README.md index 0032687..983ed12 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,31 @@ nixos-rebuild switch --flake flake_path_directory#hostname nix flake update --extra-experimental-features "nix-command flakes" ``` +## Configure VM + +Configure VM +```nix +users.users..initialPassword = ""; +virtualisation.vmVariant = { + # following configuration is added only when building VM with build-vm + virtualisation = { + memorySize = ; # Use 8192MiB memory. + cores = ; + # And more here https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/virtualisation/qemu-vm.nix + }; +}; +``` + +Build +```bash +nixos-rebuild build-vm --flake .#nixos-test +``` + +Run +```bash +./result/bin/run-nixos-vm-vm +``` + ## Show changements between revisions diff --git a/hosts/nixos-test/default.nix b/hosts/nixos-test/default.nix index 4f14e7f..2c68260 100644 --- a/hosts/nixos-test/default.nix +++ b/hosts/nixos-test/default.nix @@ -30,5 +30,15 @@ }; }; + # Configure for testing in vm + users.users.florian.initialPassword = "test"; + virtualisation.vmVariant = { + # following configuration is added only when building VM with build-vm + virtualisation = { + memorySize = 8192; # Use 8192MiB memory. + cores = 8; + }; + }; + networking.hostName = "nixos-vm"; # Define your hostname. }