sisyphus/nixos/modules/virtualisation/virtualbox/default.nix

35 lines
976 B
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.sisyphus.virtualisation.virtualbox;
# I like to override the virtualbox package because it is frequently
# and rebuilds take quite long.
inherit (pkgs) fetchurl;
version = "7.0.10";
virtualbox-override = pkgs.virtualbox.overrideAttrs (oldAttrs: {
src = fetchurl {
url = "https://download.virtualbox.org/virtualbox/${version}/VirtualBox-${version}.tar.bz2";
sha256 = "0b1e6d8b7f87d017c7fae37f80586acff04f799ffc1d51e995954d6415dee371";
};
});
in {
options.sisyphus.virtualisation.virtualbox.enable = lib.mkEnableOption "VirtualBox";
config = lib.mkIf cfg.enable {
virtualisation.virtualbox = {
host = {
enable = true;
enableExtensionPack = true;
package = virtualbox-override;
};
guest = {
enable = true;
x11 = true;
};
};
users.extraGroups.vboxusers.members = [
"user-with-access-to-virtualbox"
];
};
}