diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..3aacb98 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,16 @@ +name: macOS + +on: [push] + +jobs: + build: + name: Build + runs-on: macOS-latest + steps: + - uses: actions/checkout@v1 + + - name: Fetch dependencies + run: go get -d ./... + + - name: Build + run: go build diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..737d67c --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,16 @@ +name: Ubuntu + +on: [push] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Fetch dependencies + run: go get -d ./... + + - name: Build + run: go build diff --git a/README.md b/README.md index acbd80f..c54f298 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ You need to **relogin** if you install virt-manager (libvirt) first time. $ appvm start chromium --verbose $ # ... long wait for first time, because we need to collect a lot of packages -You can customize local settings in `$GOPATH/code.dumpstack.io/tools/appvm/nix/local.nix`. +You can customize local settings in **~/.config/appvm/nix/local.nix**. Default hotkey to release cursor: ctrl+alt. diff --git a/appvm.go b/appvm.go index 2ec446f..d99c22f 100644 --- a/appvm.go +++ b/appvm.go @@ -106,11 +106,7 @@ func list(l *libvirt.Libvirt) { } for _, f := range files { - if f.Name() != "base.nix" && - f.Name() != "local.nix" && - f.Name() != "local.nix.template" { - fmt.Println("\t", f.Name()[0:len(f.Name())-4]) - } + fmt.Println("\t", f.Name()[0:len(f.Name())-4]) } } @@ -264,7 +260,6 @@ func stupidProgressBar() { } func start(l *libvirt.Libvirt, name string, verbose bool) { - // Currently binary-only installation is not supported, because we need *.nix configurations appvmPath := configDir // Copy templates @@ -317,7 +312,7 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Application VM", "Used memory", "Current memory", "Max memory", "New memory"}) for _, d := range domains { - if d.Name[0:5] == "appvm" { + if strings.HasPrefix(d.Name, "appvm_") { name := d.Name[6:] memoryUsedRaw, err := ioutil.ReadFile(os.Getenv("HOME") + "/appvm/" + name + "/.memory_used") diff --git a/base.nix.go b/base.nix.go index d8cdc54..f09dfb1 100644 --- a/base.nix.go +++ b/base.nix.go @@ -40,14 +40,6 @@ startup = do spawn "${pkgs.spice-vdagent}/bin/spice-vdagent" ''; - environment.systemPackages = [ pkgs.bc ]; - services.cron = { - enable = true; - systemCronJobs = [ - "* * * * * root free -m | grep Mem | awk '{print $2 \"-\" $4}' | bc > /home/user/.memory_used" - ]; - }; - systemd.services.home-user-build-xmonad = { description = "Link xmonad configuration"; serviceConfig = { @@ -89,5 +81,27 @@ startup = do }; wantedBy = ["timers.target"]; }; + + systemd.services."autoballoon" = { + serviceConfig = { + StartLimitBurst = 100; + }; + script = '' + ${pkgs.procps}/bin/free -m | grep Mem | \ + ${pkgs.gawk}/bin/awk '{print $2 "-" $4}' | \ + ${pkgs.bc}/bin/bc > /home/user/.memory_used + ''; + }; + + systemd.timers."autoballoon" = { + description = "Auto update resolution crutch"; + timerConfig = { + OnBootSec = "1s"; + OnUnitInactiveSec = "1s"; + Unit = "autoballoon.service"; + AccuracySec = "1us"; + }; + wantedBy = ["timers.target"]; + }; } `) diff --git a/xml.go b/xml.go index d6d6fbf..b2d93e5 100644 --- a/xml.go +++ b/xml.go @@ -6,7 +6,6 @@ import "fmt" // Believe me, you shouldn't. func generateXML(name, vmNixPath, reginfo, img, sharedDir string) string { - // TODO: Define XML in go return fmt.Sprintf(xmlTmpl, "appvm_"+name, vmNixPath, vmNixPath, vmNixPath, reginfo, img, sharedDir, sharedDir, sharedDir) }