~ehmry/sigil

ab21e4bfa52ecaab979b80b07a15be169c8f5dfc — Emery Hemingway 3 years ago 82a18ac vbox
vbox stuff
M nixos-modules/gui/default.nix => nixos-modules/gui/default.nix +1 -1
@@ 11,7 11,7 @@ in {

  config = {

    genode.gui.enable = cfg.consoleLog.enable;
    genode.gui.enable = lib.mkDefault cfg.consoleLog.enable;

    hardware.genode.framebuffer.enable = cfg.enable;


M nixos-modules/hardware/framebuffer.nix => nixos-modules/hardware/framebuffer.nix +45 -31
@@ 11,38 11,52 @@ with lib;
    };
  };

  config = {

    genode.core.children.fb_drv =
      mkIf config.hardware.genode.framebuffer.enable {
        binary = with pkgs.genodePackages;
          {
            boot = boot_fb_drv;
            vesa = vesa_drv;
          }.${config.hardware.genode.framebuffer.driver};
        configFile = let
          binary = with pkgs.genodePackages;
            {
              boot = "${boot_fb_drv}/bin/boot_fb_drv";
              vesa = "${vesa_drv}/bin/vesa_fb_drv";
            }.${config.hardware.genode.framebuffer.driver};
        in builtins.toFile "fb_drv.dhall" ''
          let Genode = env:DHALL_GENODE

          let Init = Genode.Init

          in  λ(binary : Text) →
                Init.Child.flat
                  Init.Child.Attributes::{
                  , binary
                  , resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
                  , routes =
                    [ Init.ServiceRoute.parent "IO_MEM"
                    , Init.ServiceRoute.parent "IO_PORT"
                    ]
  config = let cfg = config.hardware.genode.framebuffer;
  in {

    hardware.genode.platform.policies = lib.optional cfg.enable
      (builtins.toFile ("ahci.platform-policy.dhall") ''
        let Genode = env:DHALL_GENODE

        in  Genode.Init.Config.Policy::{
            , service = "Platform"
            , label = Genode.Init.LabelSelector.prefix "fb_drv"
            , content =
              [ Genode.Prelude.XML.leaf
                  { name = "pci", attributes = toMap { class = "VGA" } }
              , Genode.Prelude.XML.leaf
                  { name = "pci"
                  , attributes = toMap { bus = "0", device = "0", function = "0" }
                  }
        '';
      };
              , Genode.Prelude.XML.leaf
                  { name = "pci", attributes = toMap { class = "ISABRIDGE" } }
              ]
            }
      '');

    genode.core.children.fb_drv = mkIf cfg.enable {
      binary = with pkgs.genodePackages;
        {
          boot = "${boot_fb_drv}/bin/boot_fb_drv";
          vesa = "${vesa_drv}/bin/vesa_fb_drv";
        }.${cfg.driver};
      configFile = builtins.toFile "fb_drv.dhall" ''
        let Genode = env:DHALL_GENODE

        let Init = Genode.Init

        in  λ(binary : Text) →
              Init.Child.flat
                Init.Child.Attributes::{
                , binary
                , resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
                , routes =
                  [ Init.ServiceRoute.parent "IO_MEM"
                  , Init.ServiceRoute.parent "IO_PORT"
                  ]
                }
      '';
    };

  };


M nixos-modules/qemu-vm.nix => nixos-modules/qemu-vm.nix +0 -1
@@ 274,7 274,6 @@ in {
        "-drive if=pflash,format=raw,unit=1,file=$NIX_EFI_VARS"
      ])
      (mkIf (cfg.bios != null) [ "-bios ${cfg.bios}/bios.bin" ])
      (mkIf (!cfg.graphics) [ "-nographic" ])
    ];

    system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } ''

M nixos-modules/vbox-guest.dhall => nixos-modules/vbox-guest.dhall +3 -2
@@ 391,11 391,12 @@ let vboxConfig
          }

let toVbox
    : Params → Genode.Init.Child.Type
    : Params → Text → Genode.Init.Child.Type
    = λ(params : Params) →
      λ(binary : Text) →
        Child.flat
          Child.Attributes::{
          , binary = "virtualbox5"
          , binary
          , config =
              ( Libc.toConfig
                  Libc::{

M nixos-modules/vbox-host-genode.nix => nixos-modules/vbox-host-genode.nix +24 -5
@@ 30,10 30,17 @@ in {

  config = {

    assertions = [{
      assertion = pkgs.hostPlatform.isGenode;
      message = "This module is only importable by Genode hosts";
    }];
    assertions = [
      {
        assertion = pkgs.hostPlatform.isGenode;
        message = "This module is only importable by Genode hosts";
      }
      {
        assertion = config.genode.boot.storeBackend != "memory";
        message =
          "Refusing to instantiate Vbox guests with an in-memory Nix store.";
      }
    ];

    genode.init.children = mapAttrs' (name: cfg:



@@ 59,7 66,19 @@ in {

          inherit (cfg) routeToNics;

          inputs = with pkgs.genodePackages; [ libiconv vbox5 vfs_pipe ];
          binary = "${pkgs.genodePackages.vbox5}/bin/virtualbox5";

          extraInputs = with pkgs.genodePackages; [
            libc
            libiconv
            posix
            stdcxx
            vbox5
            vfs
            vfs_import
            vfs_pipe
            zlib
          ];

          coreROMs = [ "platform_info" ];


M tests/lib/test-driver.py => tests/lib/test-driver.py +1 -1
@@ 254,7 254,7 @@ class Machine:
            net_frontend += "," + args["netFrontendArgs"]

        start_command = (
            "qemu-kvm -m 384 " + net_backend + " " + net_frontend + " $QEMU_OPTS "
            "qemu-kvm " + net_backend + " " + net_frontend + " $QEMU_OPTS "
        )

        if "hda" in args:

M tests/vbox.nix => tests/vbox.nix +6 -3
@@ 4,20 4,21 @@
    with builtins;
    all (f: any f specs) [ (spec: spec == "nova") (spec: spec == "x86") ];
  machine = { pkgs, modulesPath, ... }: {
    virtualisation.memorySize = 4096;
    genode.boot.storeBackend = "fs";
    fileSystems."/".block = {
      driver = "ahci";
      device = 0;
      partition = 1;
    };
    genode.gui.enable = true;
    genode.vbox.nixosGuests.demo = {
      # bootFormat = "vdi";
      guest = import "${modulesPath}/../lib/eval-config.nix" {
        modules = [
          ({ config, lib, pkgs, ... }: {

            imports = [
              "${modulesPath}/virtualisation/virtualbox-image.nix"
            ];
            imports = [ "${modulesPath}/virtualisation/virtualbox-image.nix" ];

            nixpkgs.system = "x86_64-linux";



@@ 33,6 34,8 @@
              uid = 1000;
            };

            virtualbox.memorySize = 128;

          })
        ];
      };