Adding VMs to PATH: Difference between revisions
imported>Kisik21 Added "restartIfChanged" parameter to allow VMs to be not restarted on configuration change |
imported>Olafklingt m add Virtualization Category |
||
(One intermediate revision by one other user not shown) | |||
Line 7: | Line 7: | ||
but I don't use it here, because we need another kind of derivation. */ | but I don't use it here, because we need another kind of derivation. */ | ||
nixosVM = configuration: (import <nixpkgs/nixos> { inherit configuration; }).vm; | nixosVM = configuration: (import <nixpkgs/nixos> { inherit configuration; }).vm; | ||
# This is a convenience for having the machine configurations. | |||
vms = { | vms = { | ||
# You can write it inline... | |||
yuki = { config, pkgs, lib, ... }: { | yuki = { config, pkgs, lib, ... }: { | ||
services.httpd.enable = true; | services.httpd.enable = true; | ||
services.httpd.adminAddr = "webmaster@example.com"; | services.httpd.adminAddr = "webmaster@example.com"; | ||
}; | }; | ||
# Or import from another file. | |||
sakura = import VMs/sakura.nix; | sakura = import VMs/sakura.nix; | ||
}; | }; | ||
in { | in { | ||
environment.systemPackages = [ | environment.systemPackages = [ | ||
# Then just add it like this! | |||
(nixosVM vms.yuki) | (nixosVM vms.yuki) | ||
]; | ]; | ||
Line 78: | Line 78: | ||
This will make it launch a virtual machine on boot. | This will make it launch a virtual machine on boot. | ||
[[Category:Virtualization]] |