~ehmry/sigil

1bcb6e7256dccee9bf268bb11219a0f37f66b423 — Emery Hemingway 3 years ago 96582c4 hybrid
pass nixosConfiguration to vbox guests
2 files changed, 10 insertions(+), 29 deletions(-)

M nixos-modules/file-systems.nix
M nixos-modules/guest-vbox-linux.nix
M nixos-modules/file-systems.nix => nixos-modules/file-systems.nix +1 -1
@@ 2,7 2,7 @@
with lib; {

  options.fileSystems = lib.mkOption {
    type = types.attrsOf (types.submodule ({ name, config, ... }: {
    type = types.attrsOf (types.submodule ({ name, ... }: {
      options.block = {

        device = lib.mkOption { type = types.int; };

M nixos-modules/guest-vbox-linux.nix => nixos-modules/guest-vbox-linux.nix +9 -28
@@ 6,9 6,15 @@ in {

  options.genode.vbox.guests = mkOption {
    default = { };
    type = types.attrsOf (types.submodule ({ config, options, name, ... }: {
    type = types.attrsOf (types.submodule ({ name, ... }: {
      options = {

        nixosConfiguration = mkOption {
          type = types.attrsOf types.anything;
          example = literalExample "nixpkgs.lib.nixosSystem { … }";
          description = "NixOS configuration.";
        };

        bootFormat = mkOption {
          default = "iso";
          type = types.enum [ "iso" "vdi" ];


@@ 32,30 38,6 @@ in {
          '';
        };

        config = mkOption {
          description = ''
            A specification of the desired configuration of this
            guest VM, as a NixOS module.
          '';
          default = { };
          type = mkOptionType {
            name = "Toplevel NixOS config";
            merge = loc: defs:
              (import "${modulesPath}/../lib/eval-config.nix" {
                system = "x86_64-linux";
                modules = {
                  iso = [ "${modulesPath}/installer/cd-dvd/iso-image.nix" ];
                  vdi = [
                    "${modulesPath}/virtualisation/virtualbox-image.nix"
                    { virtualbox.memorySize = cfg.guests.${name}.memorySize; }
                  ];
                }.${config.bootFormat} ++ [{ system.nixos.tags = [ name ]; }]
                  ++ (map (x: x.value) defs);
                prefix = [ "guests" name ];
              }).config;
          };
        };

      };
    }));
  };


@@ 83,9 65,8 @@ in {
            filename = "nixos.vdi";
            drv = import "${modulesPath}/../lib/make-disk-image.nix" {
              inherit lib;
              inherit (cfg.config.nixpkgs) pkgs;
              inherit (cfg) config;
              diskSize = config.virtualbox.baseImageSize;
              inherit (cfg.nixosConfiguration) config;
              inherit (cfg.nixosConfiguration.config.nixpkgs) pkgs;
              partitionTableType = "legacy";
              name = "nixos-${pkgs.stdenv.hostPlatform.system}.vdi";
              format = "vdi";