3 { config, pkgs, lib, ... }:
18 documentation.man.enable = false;
19 documentation.nixos.enable = false;
21 users.extraUsers.vagrant.extraGroups = [ "vboxsf" ];
23 # generate the box v1 format which is much easier to generate
24 # https://www.vagrantup.com/docs/boxes/format.html
25 image.extension = lib.mkOverride 999 "${config.image.baseName}.box";
26 system.nixos.tags = [ "vagrant"];
27 system.build.image = lib.mkOverride 999 config.system.build.vagrantVirtualbox;
28 system.build.vagrantVirtualbox = pkgs.runCommand
35 # 1. create that metadata.json file
36 echo '{"provider":"virtualbox"}' > metadata.json
38 # 2. create a default Vagrantfile config
39 cat <<VAGRANTFILE > Vagrantfile
40 Vagrant.configure("2") do |config|
41 config.vm.base_mac = "0800275F0936"
45 # 3. add the exported VM files
46 tar xvf ${config.system.build.virtualBoxOVA}/*.ova
48 # 4. move the ovf to the fixed location
51 # 5. generate OVF manifest file
55 checksum=$(sha256sum $fname | cut -d' ' -f 1)
56 echo "SHA256($fname)= $checksum" >> box.mf
59 # 6. compress everything back together
60 tar --owner=0 --group=0 --sort=name --numeric-owner -czf $out .