Merge branch 'master' of github.com:jollheef/appvm
This commit is contained in:
commit
555768d03b
16
.github/workflows/macos.yml
vendored
Normal file
16
.github/workflows/macos.yml
vendored
Normal file
@ -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
|
16
.github/workflows/ubuntu.yml
vendored
Normal file
16
.github/workflows/ubuntu.yml
vendored
Normal file
@ -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
|
@ -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.
|
||||
|
||||
|
7
appvm.go
7
appvm.go
@ -106,12 +106,8 @@ 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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func copyFile(from, to string) (err error) {
|
||||
@ -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")
|
||||
|
30
base.nix.go
30
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"];
|
||||
};
|
||||
}
|
||||
`)
|
||||
|
1
xml.go
1
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user