Skip to content

Commit

Permalink
nixos/vm: init
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jul 3, 2024
1 parent b1ea803 commit 725876d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/flake-helpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ in
};

"nixosVMs/${hostname}" = mkApp {
drv = pkgs.writeShellScriptBin "run-${hostname}-vm" ''
env QEMU_OPTS="''${QEMU_OPTS:--cpu max -smp 4 -m 4096M -machine type=q35}" \
${config.system.build.vm}/bin/run-${hostname}-vm
'';
drv = config.system.build.vm;
exePath = "/bin/run-${hostname}-vm";
};
};
};
Expand Down
1 change: 1 addition & 0 deletions nixos/system/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ in
./cli.nix
./btrfs.nix
./smart.nix
./vm.nix
];

options.nixos.system = {
Expand Down
25 changes: 25 additions & 0 deletions nixos/system/vm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ config, lib, ... }:

let
cfg = config.nixos.system.vm;
in
{
options.nixos.system.vm = {
enable = lib.mkEnableOption "Virtual Machine config" // { default = true; };
vmConfig = lib.mkOption {
type = lib.types.attrs;
description = "Virtualisation options";
default = {
memorySize = 4096;
cores = 4;
};
};
};

config = lib.mkIf cfg.enable {
virtualisation = {
vmVariant = { virtualisation = cfg.vmConfig; };
vmVariantWithBootLoader = { virtualisation = cfg.vmConfig; };
};
};
}

0 comments on commit 725876d

Please sign in to comment.