Allow VMs with hostname other than default (#19)

The VM runner created by nix is called `./run-<hostname>-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.
This commit is contained in:
msm-code 2020-04-05 13:30:48 +00:00 committed by GitHub
parent aaede60c4d
commit a583335865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}