fix error response code
[tails.git] / vagrant / Vagrantfile
blobc4acdf80c0f05aed32c6bc992345cb3a0eac4543
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
4 # Tails: https://tails.net/
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 require_relative 'lib/tails_build_settings'
21 ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
23 Vagrant.configure('2') do |config|
24   config.vm.box = box_name
25   config.vm.box_url = 'http://127.0.0.1/dev/null'
26   ENV['EXPORTED_VARIABLES'] ||= ''
27   env_vars = ENV.select { |k, _| ENV['EXPORTED_VARIABLES'].split.include?(k) }
28                 .map { |k, v| "#{k}='#{v}'" }.join(' ')
29   config.vm.provision(
30     'shell',
31     inline: "sudo #{env_vars} /vagrant/provision/setup-tails-builder"
32   )
33   config.vm.synced_folder('.', '/vagrant', type: '9p', readonly: true)
34   config.vm.synced_folder('..', '/amnesia.git', type: '9p', readonly: true)
35   config.vm.provider(:libvirt) do |domain| # rubocop:disable Metrics/BlockLength
36     domain.default_prefix = config.vm.box
37     domain.driver = 'kvm'
38     domain.management_network_guest_ipv6 = 'no'
39     domain.connect_via_ssh = false
40     domain.machine_arch = 'x86_64'
41     domain.machine_type = ENV['TAILS_BUILD_MACHINE_TYPE'] || 'q35'
42     if ENV['TAILS_BUILD_CPU_MODEL']
43       domain.cpu_mode  = 'custom'
44       domain.cpu_model = ENV['TAILS_BUILD_CPU_MODEL']
45     else
46       domain.cpu_mode = 'host-passthrough'
47     end
48     domain.emulator_path = '/usr/bin/qemu-system-x86_64'
49     domain.memory = if ENV['TAILS_RAM_BUILD']
50                       VM_MEMORY_FOR_RAM_BUILDS
51                     else
52                       VM_MEMORY_FOR_DISK_BUILDS
53                     end
54     cpus = ENV['TAILS_BUILD_CPUS']
55     domain.cpus = cpus unless cpus.nil?
56     if ENV['TAILS_PROXY_TYPE'] == 'vmproxy'
57       domain.storage(
58         :file, size: '15G', allow_existing: true,
59         path: 'apt-cacher-ng-data.qcow2'
60       )
61     end
62     if ENV['TAILS_WEBSITE_CACHE'] == '1'
63       domain.storage(
64         :file, size: '3G', allow_existing: true,
65         path: 'tails-website-cache.qcow2'
66       )
67     end
68   end
69 end