mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-23 12:43:02 +00:00
Move copy templates out
This commit is contained in:
parent
02f4eab277
commit
cb343c4506
28
appvm.go
28
appvm.go
@ -149,6 +149,23 @@ func copyFile(from, to string) (err error) {
|
|||||||
return destination.Close()
|
return destination.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func prepareTemplates(appvmPath string) (err error) {
|
||||||
|
if _, err = os.Stat(appvmPath + "/nix/local.nix"); os.IsNotExist(err) {
|
||||||
|
err = copyFile(appvmPath+"/nix/local.nix.template", appvmPath+"/nix/local.nix")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = os.Stat(appvmPath + "/nix/monitor.nix"); os.IsNotExist(err) {
|
||||||
|
err = copyFile(appvmPath+"/nix/monitor.nix.template", appvmPath+"/nix/monitor.nix")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func start(l *libvirt.Libvirt, name string) {
|
func start(l *libvirt.Libvirt, name string) {
|
||||||
// Currently binary-only installation is not supported, because we need *.nix configurations
|
// Currently binary-only installation is not supported, because we need *.nix configurations
|
||||||
gopath := os.Getenv("GOPATH")
|
gopath := os.Getenv("GOPATH")
|
||||||
@ -159,19 +176,10 @@ func start(l *libvirt.Libvirt, name string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy templates
|
// Copy templates
|
||||||
if _, err := os.Stat(appvmPath + "/nix/local.nix"); os.IsNotExist(err) {
|
err := prepareTemplates(name)
|
||||||
err = copyFile(appvmPath+"/nix/local.nix.template", appvmPath+"/nix/local.nix")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := os.Stat(appvmPath + "/nix/monitor.nix"); os.IsNotExist(err) {
|
|
||||||
err = copyFile(appvmPath+"/nix/monitor.nix.template", appvmPath+"/nix/monitor.nix")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stdout, stderr, ret, err := system.System("nix-build", "<nixpkgs/nixos>", "-A", "config.system.build.vm",
|
stdout, stderr, ret, err := system.System("nix-build", "<nixpkgs/nixos>", "-A", "config.system.build.vm",
|
||||||
"-I", "nixos-config=nix/"+name+".nix", "-I", ".")
|
"-I", "nixos-config=nix/"+name+".nix", "-I", ".")
|
||||||
|
Loading…
Reference in New Issue
Block a user