appvm/README.md

87 lines
2.4 KiB
Markdown
Raw Normal View History

2020-01-05 06:03:59 +00:00
[![Documentation Status](https://readthedocs.org/projects/appvm/badge/?version=latest)](https://appvm.readthedocs.io/en/latest/?badge=latest)
2019-08-17 15:40:14 +00:00
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R8W2UQPZ5X5JE&source=url)
[![Donate](https://img.shields.io/badge/Donate-BitCoin-green.svg)](https://blockchair.com/bitcoin/address/bc1q23fyuq7kmngrgqgp6yq9hk8a5q460f39m8nv87)
2018-07-12 21:03:28 +00:00
# Nix application VMs: security through virtualization
2018-06-29 21:59:28 +00:00
2018-07-12 21:03:28 +00:00
Simple application VMs (hypervisor-based sandbox) based on Nix package manager.
2018-06-30 21:03:16 +00:00
2018-07-01 08:21:15 +00:00
Uses one **read-only** /nix directory for all appvms. So creating a new appvm (but not first) is just about one minute.
2018-07-01 07:25:27 +00:00
2018-07-05 07:46:31 +00:00
![appvm screenshot](screenshots/2018-07-05.png)
2018-06-30 21:03:16 +00:00
## Dependencies
2018-06-30 08:39:47 +00:00
2018-07-12 07:05:53 +00:00
$ sudo apt install golang virt-manager curl git
2018-07-12 07:19:09 +00:00
$ sudo usermod -a -G libvirt $USER
$ echo 'export GOPATH=$HOME/go' >> ~/.bash_profile
$ echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bash_profile
$ echo 'source ~/.bash_profile' >> ~/.bashrc
$ source ~/.bash_profile
You need to **relogin** if you install virt-manager (libvirt) first time.
2018-06-30 08:39:47 +00:00
## Install Nix package manager
$ sudo mkdir -m 0755 /nix && sudo chown $USER /nix
$ curl https://nixos.org/nix/install | sh
$ . ~/.nix-profile/etc/profile.d/nix.sh
2018-07-11 23:34:36 +00:00
## Libvirt from user (required if you need access to shared files)
2018-07-11 23:39:30 +00:00
$ echo user = "\"$USER\"" | sudo tee -a /etc/libvirt/qemu.conf
$ sudo systemctl restart libvirtd
2018-06-30 08:39:47 +00:00
2018-07-11 23:34:36 +00:00
## Install appvm tool
2018-06-30 08:39:47 +00:00
2019-02-03 22:22:47 +00:00
$ go get code.dumpstack.io/tools/appvm
2018-06-30 21:03:16 +00:00
## Update appvm tool
2019-02-03 22:22:47 +00:00
$ go get -u code.dumpstack.io/tools/appvm
2020-01-02 15:37:32 +00:00
## Search for applications
$ appvm search chromium
2019-12-30 14:18:34 +00:00
## Generate new application
$ nix-channel --list
nix https://nixos.org/channels/nixos-unstable
$ appvm generate nix.firefox
2018-07-11 23:34:36 +00:00
## Run application
2018-06-30 21:03:16 +00:00
2020-01-02 15:17:22 +00:00
$ appvm start chromium
$ # ... long wait for first time, because we need to collect a lot of packages
2018-06-30 08:39:47 +00:00
2020-01-02 15:47:42 +00:00
## Synchronize remote repos for applications
$ appvm sync
2019-12-29 19:10:57 +00:00
You can customize local settings in **~/.config/appvm/nix/local.nix**.
2018-06-30 08:39:47 +00:00
2018-07-01 07:58:42 +00:00
Default hotkey to release cursor: ctrl+alt.
2018-06-30 21:03:16 +00:00
## Shared directory
2018-06-29 21:59:28 +00:00
2018-07-11 23:34:36 +00:00
$ ls appvm/chromium
2018-06-30 21:03:16 +00:00
foo.tar.gz
bar.tar.gz
2018-06-30 22:08:41 +00:00
## Close VM
2018-07-11 23:34:36 +00:00
$ appvm stop chromium
2018-06-30 22:10:39 +00:00
2018-07-12 20:00:57 +00:00
## Automatic ballooning
Add this command:
$ appvm autoballoon
to crontab like that:
$ crontab -l
* * * * * /home/user/dev/go/bin/appvm autoballoon