Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
c2413d0208 | |||
d9c651987b | |||
3483763938 | |||
bfc28be996 | |||
6321004848 | |||
5376e7a56f | |||
77eada72c3 | |||
9a602a2231 |
8
appvm.go
8
appvm.go
@ -163,12 +163,8 @@ func generateVM(path, name string, verbose bool) (realpath, reginfo, qcow2 strin
|
|||||||
syscall.Unlink("result")
|
syscall.Unlink("result")
|
||||||
|
|
||||||
qcow2 = os.Getenv("HOME") + "/appvm/.fake.qcow2"
|
qcow2 = os.Getenv("HOME") + "/appvm/.fake.qcow2"
|
||||||
if _, err = os.Stat(qcow2); os.IsNotExist(err) {
|
if _, e := os.Stat(qcow2); os.IsNotExist(e) {
|
||||||
system.System("qemu-img", "create", "-f", "qcow2", qcow2, "512M")
|
system.System("qemu-img", "create", "-f", "qcow2", qcow2, "40M")
|
||||||
err = os.Chmod(qcow2, 0400) // qemu run with -snapshot, we only need it for create /dev/vda
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {}, ... }:
|
||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> {};
|
|
||||||
virt-manager-without-menu = pkgs.virt-viewer.overrideAttrs(x: {
|
virt-manager-without-menu = pkgs.virt-viewer.overrideAttrs(x: {
|
||||||
patches = [
|
patches = [
|
||||||
./patches/0001-Remove-menu-bar.patch
|
./patches/0001-Remove-menu-bar.patch
|
||||||
@ -31,7 +31,7 @@ buildGoModule rec {
|
|||||||
meta = {
|
meta = {
|
||||||
description = "Nix-based app VMs";
|
description = "Nix-based app VMs";
|
||||||
homepage = "https://code.dumpstack.io/tools/${pname}";
|
homepage = "https://code.dumpstack.io/tools/${pname}";
|
||||||
maintainers = [ lib.maintainers.dump_stack ];
|
maintainers = [ lib.maintainers.dump_stack lib.maintainers.cab404 ];
|
||||||
license = lib.licenses.gpl3;
|
license = lib.licenses.gpl3;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,20 @@ Installation
|
|||||||
NixOS
|
NixOS
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
First, clone this repo. Then do this:
|
||||||
|
|
||||||
/etc/nixos/configuration.nix::
|
/etc/nixos/configuration.nix::
|
||||||
|
|
||||||
virtualisation.libvirtd = {
|
imports = [
|
||||||
|
/path/to/repo/nixos
|
||||||
|
];
|
||||||
|
|
||||||
|
virtualizatiom.appvm = {
|
||||||
enable = true;
|
enable = true;
|
||||||
qemuVerbatimConfig = ''
|
user = "${username}";
|
||||||
namespaces = []
|
|
||||||
user = "${username}"
|
|
||||||
group = "users"
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users."${username}".extraGroups = [ ... "libvirtd" ];
|
This is a temporary solution until appvm is upstreamed to nixpkgs or Nix flakes are released.
|
||||||
|
|
||||||
shell::
|
|
||||||
|
|
||||||
nix run -f https://code.dumpstack.io/tools/appvm/archive/master.tar.gz -c appvm
|
|
||||||
|
|
||||||
Ubuntu 20.04
|
Ubuntu 20.04
|
||||||
------
|
------
|
||||||
|
44
nixos/default.nix
Normal file
44
nixos/default.nix
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
params@{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.virtualisation.appvm;
|
||||||
|
appvm = import ../. params;
|
||||||
|
in with lib; {
|
||||||
|
|
||||||
|
options = {
|
||||||
|
virtualisation.appvm = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
This enables AppVMs and related virtualisation settings.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = ''
|
||||||
|
AppVM user login. Currenly only AppVMs are supported for a single user only.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
virtualisation.libvirtd = {
|
||||||
|
enable = true;
|
||||||
|
qemuVerbatimConfig = ''
|
||||||
|
namespaces = []
|
||||||
|
user = "${cfg.user}"
|
||||||
|
group = "users"
|
||||||
|
remember_owner = 0
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
users.users."${cfg.user}" = {
|
||||||
|
packages = [ appvm ];
|
||||||
|
extraGroups = [ "libvirtd" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user