diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9307d77..0000000 --- a/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -bin/* -!bin/.keep -qemu/qcow2/* -!qemu/qcow2/.keep -qemu/bin/* -!qemu/bin/.keep -share/* -!share/.keep -nix/local.nix diff --git a/README.md b/README.md index 32281e6..aa889a3 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,7 @@ Simple application VM's based on Nix package manager. Uses one **read-only** /nix directory for all appvms. So creating a new appvm (but not first) is just about one minute. -Designed primarily for full screen usage (but remote-viewer has ability to resize window dynamically without change resolution) without guest additions (because of **less attack surface**). - -It's a proof-of-concept, but you can still use it. Also there is a lot of strange things inside, don't afraid of :) +Currently optimized for full screen usage (but remote-viewer has ability to resize window dynamically without change resolution) without guest additions. ![appvm screenshot](screenshots/2018-07-05.png) @@ -19,41 +17,41 @@ It's a proof-of-concept, but you can still use it. Also there is a lot of strang $ su -c 'USE="spice virtfs" emerge qemu virt-manager' -## Add appvm to PATH +## Libvirt from user (required if you need access to shared files) - $ echo 'PATH=$PATH:$HOME/appvm/bin' >> ~/.bashrc + $ echo user = "$USER" | sudo tee -a /etc/libvirt/qemu.conf -(if you clone appvm to home directory) +## Install appvm tool + + $ go get github.com/jollheef/appvm ## Generate resolution By default uses 3840x2160. If you need to regenerate `appvm/nix/monitor.nix`: - $ appvm/appvm.sh generate-resolution 1920 1080 > appvm/nix/monitor.nix + $ $GOPATH/github.com/jollheef/appvm/generate-resolution.sh 1920 1080 > $GOPATH/github.com/jollheef/appvm/nix/monitor.nix Autodetection is a bash-spaghetti, so you need to check results. BTW it's just a X.org monitor section. -## Create VM - - $ $HOME/appvm/appvm.sh build chromium - -You can customize local settings in `nix/local.nix`. - ## Run application - $ appvm.chromium +($GOPATH/bin must be in $PATH) + + $ appvm start chromium + +You can customize local settings in `$GOPATH/github.com/jollheef/appvm/nix/local.nix`. Default hotkey to release cursor: ctrl+alt. ## Shared directory - $ ls appvm/share/chromium + $ ls appvm/chromium foo.tar.gz bar.tar.gz ## Close VM - $ pkill.... :) + $ appvm stop chromium # App description diff --git a/appvm.go b/appvm.go new file mode 100644 index 0000000..495f822 --- /dev/null +++ b/appvm.go @@ -0,0 +1,212 @@ +/** + * @author Mikhail Klementev jollheefriseup.net + * @license GNU GPLv3 + * @date July 2018 + * @brief appvm launcher + */ + +package main + +import ( + "fmt" + "log" + "net" + "os" + "os/exec" + "path/filepath" + "syscall" + "time" + + "github.com/digitalocean/go-libvirt" + "github.com/jollheef/go-system" + kingpin "gopkg.in/alecthomas/kingpin.v2" +) + +var xmlTmpl = ` + + %s + 1048576 + 1048576 + 1 + + hvm + %s/kernel + %s/initrd + loglevel=4 init=%s/init %s + + + + + + destroy + restart + destroy + + + + + + + + + + + + +