Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 29 additions & 30 deletions pkgs/applications/virtualization/virtualbox/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@

with stdenv.lib;

let version = "4.1.18"; in

stdenv.mkDerivation {
let
version = "4.1.18";
forEachModule = action: ''
for mod in \
$sourcedir/out/linux.*/release/bin/src/vboxdrv \
$sourcedir/out/linux.*/release/bin/src/vboxpci \
$sourcedir/out/linux.*/release/bin/src/vboxnetadp \
$sourcedir/out/linux.*/release/bin/src/vboxnetflt
do
if [ "x$(basename "$mod")" != xvboxdrv -a ! -e "$mod/Module.symvers" ]
then
cp -v $sourcedir/out/linux.*/release/bin/src/vboxdrv/Module.symvers \
"$mod/Module.symvers"
fi
INSTALL_MOD_PATH="$out" INSTALL_MOD_DIR=misc \
make -C "$MODULES_BUILD_DIR" "M=$mod" DEPMOD=/do_not_use_depmod ${action}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably respect makeFlags, makeFlagsArray, buildFlags{,Array}(when building), and installFlags{,Array}(when installing)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to set DEPMOD=? Why didn't we need that before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we built kernel modules using the build system from virtualbox itself, which was generating the Makefiles for the module build.
Unfortunately this won't work with kernels that have split build and source trees.
So this is done like in their install targets for RPM based distros, using the build system from the kernel itself.

done
'';
in stdenv.mkDerivation {
name = "virtualbox-${version}-${kernel.version}";

NIX_CFLAGS_COMPILE="-I${kernel}/lib/modules/${kernel.modDirVersion}/build/include/generated";

src = fetchurl {
url = "http://download.virtualbox.org/virtualbox/${version}/VirtualBox-${version}.tar.bz2";
sha256 = "e650e4fdc23581b9edc0e5d5705cc596c76796851ebf65ccda0edb8e413fa3b7";
Expand Down Expand Up @@ -42,10 +56,11 @@ stdenv.mkDerivation {
'';

configurePhase = ''
sourcedir="$(pwd)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, the standard unpackPhase sets $sourceRoot

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it is necessary, as $sourceRoot is not an absolute path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. I wonder if that should be changed in stdenv-updates... @edolstra?

./configure --with-qt4-dir=${qt4} \
${optionalString (!javaBindings) "--disable-java"} \
${optionalString (!pythonBindings) "--disable-python"} \
--disable-pulse --disable-hardening \
--disable-pulse --disable-hardening --disable-kmods \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect what happens when you run kmk? Does it do anything else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, using --disable-kmods doesn't generate build targets for the kernel modules, as we're doing this by ourselves later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 ./configure --with-qt4-dir=${qt4} \
   ${optionalString (!javaBindings) "--disable-java"} \
   ${optionalString (!pythonBindings) "--disable-python"} \
  •  --disable-pulse --disable-hardening \
    
  •  --disable-pulse --disable-hardening --disable-kmods \
    

Well, I guess that commit is somewhat unrelated to this pull request, so I'm going to rebase/remove the commit and maybe bring it up as a separate pull request. And it's kinda useless anyway, as we might be better of to build a derivation depending on the kernel to provide a more real, out-of-tree scenario.

Personally I think that given VirtualBox size, building one main binary
and one set of modules per kernel may make sense anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting idea, @aszlig do you have any sense of if the main binary is kernel version dependent?

--with-mkisofs=${xorriso}/bin/xorrisofs
sed -e 's@PKG_CONFIG_PATH=.*@PKG_CONFIG_PATH=${libIDL}/lib/pkgconfig:${glib}/lib/pkgconfig ${libIDL}/bin/libIDL-config-2@' \
-i AutoConfig.kmk
Expand All @@ -63,51 +78,35 @@ stdenv.mkDerivation {

enableParallelBuilding = true;

preBuild = ''
buildPhase = ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does just running 'make' do? Build the modules, or is something else build too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, virtualbox is using its own build system, but uses make for their kernel modules, so in fact the buildPhase was essentially just building the kernel modules, while virtualbox itself was built earlier in preBuild

source env.sh
kmk
cd out/linux.*/release/bin/src
export KERN_DIR=${kernel}/lib/modules/*/build
${forEachModule "modules"}
'';

postBuild = ''
cd ../../../../..
'';

installPhase = ''
libexec=$out/libexec/virtualbox

# Install VirtualBox files
cd out/linux.*/release/bin
mkdir -p $libexec
cp -av * $libexec

# Install kernel module
cd src
kernelVersion=$(cd ${kernel}/lib/modules; ls)
export MODULE_DIR=$out/lib/modules/$kernelVersion/misc

# Remove root ownership stuff, since this does not work in a chroot environment
for i in `find . -name Makefile`; do
sed -i -e "s|-o root||g" \
-e "s|-g root||g" $i
done


# Install kernel modules
make install
${forEachModule "modules_install"}

# Create wrapper script
mkdir -p $out/bin
for file in VirtualBox VBoxManage VBoxSDL VBoxBalloonCtrl VBoxBFE VBoxHeadless; do
ln -s "$libexec/$file" $out/bin/$file
done

# Create and fix desktop item
mkdir -p $out/share/applications
sed -i -e "s|Icon=VBox|Icon=$libexec/VBox.png|" $libexec/virtualbox.desktop
ln -sfv $libexec/virtualbox.desktop $out/share/applications
'';

meta = {
description = "PC emulator";
homepage = http://www.virtualbox.org/;
Expand Down