support flakes in vm
alias
This commit is contained in:
parent
c07c6baeae
commit
7e7234e00a
1 changed files with 7 additions and 1 deletions
|
@ -50,8 +50,14 @@ def _vm(args):
|
|||
vm_path = Path(f"/etc/nixos/hosts/virtual-machines/{vm_name}")
|
||||
if vm_path.exists():
|
||||
c = colors.Colors
|
||||
|
||||
if (vm_path / "flake.nix").exists():
|
||||
build_vm_args.extend(["--flake", f"{vm_path}/flake.nix#nixos"])
|
||||
elif (vm_path / "default.nix").exists():
|
||||
build_vm_args.extend(["-I", f"nixos-config={vm_path}/default.nix", "--no-flake"])
|
||||
|
||||
print(f"{c.BLUE}Building virtual machine {c.YELLOW}{vm_name}{c.END}")
|
||||
run(["nixos-rebuild", "build-vm", "-I", "nixos-config=./default.nix", *build_vm_args, "--no-flake"], cwd=vm_path)
|
||||
run(["nixos-rebuild", "build-vm", *build_vm_args], cwd=vm_path)
|
||||
print(f"{c.BLUE}Starting virtual vachine {c.YELLOW}{vm_name}{c.END}")
|
||||
run(["./result/bin/run-nixos-vm"], cwd=vm_path)
|
||||
print(f"{c.BLUE}Virtual machine {c.YELLOW}{vm_name} {c.BLUE}has {c.RED}stopped.{c.END}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue