From 6505544535920466b9aa4be7cd9485312e5500ef Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 17:59:09 +0000 Subject: [PATCH 1/9] We're not store base/local configuration in nix/* anymore --- appvm.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/appvm.go b/appvm.go index d08d73f..234855c 100644 --- a/appvm.go +++ b/appvm.go @@ -87,11 +87,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]) } } From e7cc81694bd38374590241e09721af096dc38959 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 18:42:19 +0000 Subject: [PATCH 2/9] Remove outdated TODO Resolves #8 --- xml.go | 1 - 1 file changed, 1 deletion(-) 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) } From 8a93015bfea17bb3cb872e12116ac16851f45bf0 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 18:57:36 +0000 Subject: [PATCH 3/9] Update used memory each second (minute previously) Resolves #4 --- base.nix.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) 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"]; + }; } `) From 29e447435fe69e4513d95542ad7911dcf00479da Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 19:03:17 +0000 Subject: [PATCH 4/9] Refactor --- appvm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appvm.go b/appvm.go index 234855c..14f104c 100644 --- a/appvm.go +++ b/appvm.go @@ -280,7 +280,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") From 38a3ba301b8e5dbf307cbdf928ab41680ee48801 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 19:10:57 +0000 Subject: [PATCH 5/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 6b35acf67305309e8e262cc68ced8d7dd6cafe91 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 19:21:40 +0000 Subject: [PATCH 6/9] Add GitHub actions --- .github/workflows/macos.yml | 13 +++++++++++++ .github/workflows/ubuntu.yml | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/macos.yml create mode 100644 .github/workflows/ubuntu.yml diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..40e3fb7 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,13 @@ +name: macOS + +on: [push] + +jobs: + build: + name: Build + runs-on: macOS-latest + steps: + - uses: actions/checkout@v1 + + - name: Build + run: go build diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..7e98750 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,13 @@ +name: Ubuntu + +on: [push] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Build + run: go build From 718ab3a164293ac1515bb988a99c45605eec6002 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 19:24:00 +0000 Subject: [PATCH 7/9] Remove outdated comment --- appvm.go | 1 - 1 file changed, 1 deletion(-) diff --git a/appvm.go b/appvm.go index 14f104c..6fc9a9e 100644 --- a/appvm.go +++ b/appvm.go @@ -227,7 +227,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 From 84095193e5d8a1ded176dd5ba4fa163c022297ef Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 19:28:59 +0000 Subject: [PATCH 8/9] GitHub Actions: Fetch dependencies --- .github/workflows/macos.yml | 3 +++ .github/workflows/ubuntu.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 40e3fb7..425e669 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -9,5 +9,8 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Fetch dependencies + run: go get . + - name: Build run: go build diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 7e98750..be61c59 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -9,5 +9,8 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Fetch dependencies + run: go get . + - name: Build run: go build From 2d5b72219f4887229b8dd740fb8c5bb6604efe7a Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 29 Dec 2019 19:31:12 +0000 Subject: [PATCH 9/9] GitHub Actions: Fix fetch dependencies --- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 425e669..3aacb98 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - name: Fetch dependencies - run: go get . + run: go get -d ./... - name: Build run: go build diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index be61c59..737d67c 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - name: Fetch dependencies - run: go get . + run: go get -d ./... - name: Build run: go build