NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.16k stars 14.19k forks source link

Virtualbox `VBoxManage unattended` broken on missing template file (Packaging problem) #112036

Open kidmose opened 3 years ago

kidmose commented 3 years ago

Describe the bug Virtualbox has a feature for unattended installation of gues OSs (VBoxManage unattended) which fails to find a template file.

To Reproduce Steps to reproduce the behavior:

  1. Install virtualbox 6.1.16r140961 coming from https://channels.nixos.org/nixos-20.09 with this in configuration.nix:

    { config, pkgs, ... }:
    {
      nixpkgs.config.allowUnfree = true; # for Extension Pack
    
      virtualisation.virtualbox.host = {
        enable = true;
        enableExtensionPack = true;
      };
    }
  2. Create a virtual machine (e.g. following https://blogs.oracle.com/scoter/oracle-vm-virtualbox-52:-unattended-guest-os-install )
  3. VBoxManage unattended install $VM --iso=/u01/Software/en_windows_10_pro_10240_x64_dvd.iso --user=scoter --full-user-name="Mr. Coter" --password secret --time-zone=UTC
  4. Observe error:
    user@desktop:~]$ VBoxManage unattended install $VM --iso=Downloads/Win10_20H2_v2_English_x64.iso --user=john --full-user-name="John Doe" --password secret --time-zone=UTC
    VBoxManage: info: Preparing unattended installation of Windows10_64 in machine 'Win10-autoinstall' (3f5c243b-bb48-4da8-ac13-5a9d0b811ee9).
    VBoxManage: error: Failed to open '/nix/store/648lq57pjghhazynjxd4cxcc1fn773ys-virtualbox-6.1.16/share/virtualbox/UnattendedTemplates/win_nt6_unattended.xml' (VERR_FILE_NOT_FOUND)
    VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component UnattendedWrap, interface IUnattended, callee nsISupports
    VBoxManage: error: Context: "Prepare()" at line 1856 of file VBoxManageMisc.cpp

Expected behavior I expected VBoxManage unattended to proceed with installing the operating system, and to not produce the above error.

Additional context I have the file mentioned as missing in the error message, sitting in my nix store here:

nix/store/648lq57pjghhazynjxd4cxcc1fn773ys-virtualbox-6.1.16/libexec/virtualbox/UnattendedTemplates/win_nt6_unattended.xml

Note the libexec vs. the share.

I'd be happy to try to fix it. As my first contribution, I expect a bit of mentoring would greatly increase the chance of it getting into master. Can I expect that someone has the time and interest to do that?

Notify maintainers @sander

Metadata Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.94, NixOS, 20.09.2947.2b9daa020d4 (Nightingale)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.10`
 - channels(kidmose): `""`
 - channels(root): `"nixos-20.09.2947.2b9daa020d4"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

snicket2100 commented 1 year ago

This is still a problem as of 2e4c842b4f9a9e3b9ed75f97e052829f4e29ca13.

The following overlay works around it btw:

  nixpkgs.overlays = [
    (self: super:
    {
      virtualbox = pkgs.virtualbox.overrideDerivation (oldAttrs: {
        postFixup = ''
          ln -s ../../libexec/virtualbox/UnattendedTemplates $out/share/virtualbox/UnattendedTemplates
        '';
      });
    })
  ];