]> Git — Sourcephile - sourcephile-nix.git/blob - shell/modules/virtualisation/virtualbox.nix
nftables: revamp to declarative configuration
[sourcephile-nix.git] / shell / modules / virtualisation / virtualbox.nix
1 { pkgs, lib, config, ... }:
2 let
3 inherit (lib) types;
4 inherit (config) virtualbox;
5 virtualbox-init = pkgs.writeShellScriptBin "virtualbox-init" ''
6 set -eu
7 TMPDIR=/tmp \
8 time ${pkgs.nix}/bin/nix build \
9 -I nixpkgs=${toString pkgs.path} \
10 --out-link .cache/nixops/virtualbox \
11 --argstr system ${virtualbox.system} \
12 -f pkgs/installer/nixops-virtualbox
13 '';
14 in
15 {
16 options.virtualbox = {
17 enable = lib.mkEnableOption "VirtualBox image for NixOps";
18 system = lib.mkOption {
19 type = types.str;
20 example = "x86_64-linux";
21 default = pkgs.stdenv.hostPlatform.system;
22 };
23 };
24 config = lib.mkIf virtualbox.enable {
25 nix-shell.buildInputs = [
26 virtualbox-init
27 ];
28 nix-shell.shellHook = ''
29 '';
30 };
31 }