anchor.diff:        '';
       };
   
  -    qemuPackage = mkOption {
  -      type = types.package;
  -      default = pkgs.qemu;
  -      defaultText = literalExpression "pkgs.qemu";
  -      description = ''
  -        Qemu package to use with libvirt.
  -        `pkgs.qemu` can emulate alien architectures (e.g. aarch64 on x86)
  -        `pkgs.qemu_kvm` saves disk space allowing to emulate only host architectures.
  -      '';
  -    };
  -
       extraConfig = mkOption {
         type = types.lines;
         default = "";
         description = ''
           Extra contents appended to the libvirtd configuration file,
           libvirtd.conf.
  -      '';
  -    };
  -
  -    qemuRunAsRoot = mkOption {
  -      type = types.bool;
  -      default = true;
  -      description = ''
  -        If true,  libvirtd runs qemu as root.
  -        If false, libvirtd runs qemu as unprivileged user qemu-libvirtd.
  -        Changing this option to false may cause file permission issues
  -        for existing guests. To fix these, manually change ownership
  -        of affected files in /var/lib/libvirt/qemu to qemu-libvirtd.
  -      '';
  -    };
  -
  -    qemuVerbatimConfig = mkOption {
  -      type = types.lines;
  -      default = ''
  -        namespaces = []
  -      '';
  -      description = ''
  -        Contents written to the qemu configuration file, qemu.conf.
  -        Make sure to include a proper namespace configuration when
  -        supplying custom configuration.
  -      '';
  -    };
  -
  -    qemuOvmf = mkOption {
  -      type = types.bool;
  -      default = true;
  -      description = ''
  -        Allows libvirtd to take advantage of OVMF when creating new
  -        QEMU VMs with UEFI boot.
  -      '';
  -    };
  -
  -    qemuOvmfPackage = mkOption {
  -      type = types.package;
  -      default = pkgs.OVMF;
  -      defaultText = literalExpression "pkgs.OVMF";
  -      example = literalExpression "pkgs.OVMFFull";
  -      description = ''
  -        OVMF package to use.
  -      '';
  -    };
  -    qemuSwtpm = mkOption {
  -      type = types.bool;
  -      default = false;
  -      description = ''
  -        Allows libvirtd to use swtpm to create an emulated TPM.
         '';
       };
   
  
positive.code:     };
  
      onBoot = mkOption {
        type = types.enum ["start" "ignore" ];
        default = "start";
        description = ''
          Specifies the action to be done to / on the guests when the host boots.
  
negative.code:   '';
    ovmfFilePrefix = if pkgs.stdenv.isAarch64 then "AAVMF" else "OVMF";
    qemuConfigFile = pkgs.writeText "qemu.conf" ''
      ${optionalString cfg.qemu.ovmf.enable ''
        nvram = [ "/run/libvirt/nix-ovmf/${ovmfFilePrefix}_CODE.fd:/run/libvirt/nix-ovmf/${ovmfFilePrefix}_VARS.fd" ]
      ''}
      ${optionalString (!cfg.qemu.runAsRoot) ''
        user = "qemu-libvirtd"
        group = "qemu-libvirtd"
      ''}
      ${cfg.qemu.verbatimConfig}
    '';
    dirName = "libvirt";
    subDirs = list: [ dirName ] ++ map (e: "${dirName}/${e}") list;
  
    ovmfModule = types.submodule {
      options = {
        enable = mkOption {
          type = types.bool;
          default = true;
          description = ''
            Allows libvirtd to take advantage of OVMF when creating new
            QEMU VMs with UEFI boot.
          '';
        };
  
        package = mkOption {
          type = types.package;
          default = pkgs.OVMF;
          defaultText = literalExpression "pkgs.OVMF";
          example = literalExpression "pkgs.OVMFFull";
          description = ''
            OVMF package to use.
          '';
        };
      };
    };
  
    swtpmModule = types.submodule {
      options = {
        enable = mkOption {
          type = types.bool;
          default = false;
          description = ''
            Allows libvirtd to use swtpm to create an emulated TPM.
          '';
        };
  
        package = mkOption {
          type = types.package;
          default = pkgs.swtpm;
          defaultText = literalExpression "pkgs.swtpm";
          description = ''
            swtpm package to use.
          '';
        };
      };
    };
  
    qemuModule = types.submodule {
      options = {
        package = mkOption {
          type = types.package;
          default = pkgs.qemu;
          defaultText = literalExpression "pkgs.qemu";
          description = ''
            Qemu package to use with libvirt.
            `pkgs.qemu` can emulate alien architectures (e.g. aarch64 on x86)
            `pkgs.qemu_kvm` saves disk space allowing to emulate only host architectures.
          '';
        };
  
        runAsRoot = mkOption {
          type = types.bool;
          default = true;
          description = ''
            If true,  libvirtd runs qemu as root.
            If false, libvirtd runs qemu as unprivileged user qemu-libvirtd.
            Changing this option to false may cause file permission issues
            for existing guests. To fix these, manually change ownership
            of affected files in /var/lib/libvirt/qemu to qemu-libvirtd.
          '';
        };
  
        verbatimConfig = mkOption {
          type = types.lines;
          default = ''
            namespaces = []
          '';
          description = ''
            Contents written to the qemu configuration file, qemu.conf.
            Make sure to include a proper namespace configuration when
            supplying custom configuration.
          '';
        };
  
        ovmf = mkOption {
          type = ovmfModule;
          default = { };
          description = ''
            QEMU's OVMF options.
          '';
        };
  
        swtpm = mkOption {
          type = swtpmModule;
          default = { };
          description = ''
            QEMU's swtpm options.
          '';
        };
      };
    };
  in
  {
  
    imports = [
      (mkRemovedOptionModule [ "virtualisation" "libvirtd" "enableKVM" ]
        "Set the option `virtualisation.libvirtd.qemu.package' instead.")
      (mkRenamedOptionModule
        [ "virtualisation" "libvirtd" "qemuPackage" ]
        [ "virtualisation" "libvirtd" "qemu" "package" ])
      (mkRenamedOptionModule
        [ "virtualisation" "libvirtd" "qemuRunAsRoot" ]
        [ "virtualisation" "libvirtd" "qemu" "runAsRoot" ])
      (mkRenamedOptionModule
        [ "virtualisation" "libvirtd" "qemuVerbatimConfig" ]
        [ "virtualisation" "libvirtd" "qemu" "verbatimConfig" ])
      (mkRenamedOptionModule
        [ "virtualisation" "libvirtd" "qemuOvmf" ]
        [ "virtualisation" "libvirtd" "qemu" "ovmf" "enable" ])
      (mkRenamedOptionModule
        [ "virtualisation" "libvirtd" "qemuOvmfPackage" ]
        [ "virtualisation" "libvirtd" "qemu" "ovmf" "package" ])
      (mkRenamedOptionModule
        [ "virtualisation" "libvirtd" "qemuSwtpm" ]
        [ "virtualisation" "libvirtd" "qemu" "swtpm" "enable" ])
    ];
  
    ###### interface
  