From a5833358655a18de98b626d46c1f4a3acb225eca Mon Sep 17 00:00:00 2001 From: msm-code Date: Sun, 5 Apr 2020 13:30:48 +0000 Subject: [PATCH] Allow VMs with hostname other than default (#19) The VM runner created by nix is called `./run--vm`. So far, the code hardcoded it as `./result/bin/run-nixos-vm`, but for the users that want to change VM hostname it may be problematic. --- appvm.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/appvm.go b/appvm.go index 574de04..9c30e67 100644 --- a/appvm.go +++ b/appvm.go @@ -133,8 +133,13 @@ func generateVM(path, name string, verbose bool) (realpath, reginfo, qcow2 strin return } - bytes, err := ioutil.ReadFile("result/bin/run-nixos-vm") - if err != nil { + matches, err := filepath.Glob("result/bin/run-*-vm") + if err != nil || len(matches) != 1 { + return + } + + bytes, err := ioutil.ReadFile(matches[0]) + if err != nil || len(matches) != 1 { return }