diff options
author | Jon Seager <jon@sgrs.uk> | 2023-02-03 09:26:57 +0000 |
---|---|---|
committer | Jon Seager <jon@sgrs.uk> | 2023-02-04 07:44:02 +0000 |
commit | db9d730b1ecaf9db00d519d91d9572dd115c0320 (patch) | |
tree | cf7e47a5f9ebb30fedfda0f1a991d421bf870310 /pkgs/tools/virtualization | |
parent | 84bfd9416c1099758f7eccd763a25e5674546e5c (diff) |
multipass: init at 1.11.0
Diffstat (limited to 'pkgs/tools/virtualization')
-rw-r--r-- | pkgs/tools/virtualization/multipass/default.nix | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/pkgs/tools/virtualization/multipass/default.nix b/pkgs/tools/virtualization/multipass/default.nix new file mode 100644 index 0000000000000..d8d003b2064fc --- /dev/null +++ b/pkgs/tools/virtualization/multipass/default.nix @@ -0,0 +1,128 @@ +{ cmake +, dnsmasq +, fetchFromGitHub +, git +, gtest +, iproute2 +, iptables +, lib +, libapparmor +, libvirt +, libxml2 +, nixosTests +, openssl +, OVMF +, pkg-config +, qemu +, qemu-utils +, qtbase +, qtx11extras +, slang +, stdenv +, wrapQtAppsHook +, xterm +}: + +let + pname = "multipass"; + version = "1.11.0"; +in +stdenv.mkDerivation { + inherit pname version; + + src = fetchFromGitHub { + owner = "canonical"; + repo = "multipass"; + rev = "refs/tags/v${version}"; + sha256 = "sha256-2d8piIIecoSI3BfOgAVlXl5P2UYDaNlxUgHXWbnSdkg="; + fetchSubmodules = true; + }; + + preConfigure = '' + substituteInPlace ./CMakeLists.txt \ + --replace "determine_version(MULTIPASS_VERSION)" "" \ + --replace 'set(MULTIPASS_VERSION ''${MULTIPASS_VERSION})' 'set(MULTIPASS_VERSION "v${version}")' + + substituteInPlace ./src/platform/backends/qemu/linux/qemu_platform_detail_linux.cpp \ + --replace "OVMF.fd" "${OVMF.fd}/FV/OVMF.fd" \ + --replace "QEMU_EFI.fd" "${OVMF.fd}/FV/QEMU_EFI.fd" + ''; + + postPatch = '' + # Patch all of the places where Multipass expects the LXD socket to be provided by a snap + substituteInPlace ./src/network/network_access_manager.cpp \ + --replace "/var/snap/lxd/common/lxd/unix.socket" "/var/lib/lxd/unix.socket" + + substituteInPlace ./src/platform/backends/lxd/lxd_virtual_machine.cpp \ + --replace "/var/snap/lxd/common/lxd/unix.socket" "/var/lib/lxd/unix.socket" + + substituteInPlace ./src/platform/backends/lxd/lxd_request.h \ + --replace "/var/snap/lxd/common/lxd/unix.socket" "/var/lib/lxd/unix.socket" + + substituteInPlace ./tests/CMakeLists.txt \ + --replace "FetchContent_MakeAvailable(googletest)" "" + + cat >> tests/CMakeLists.txt <<'EOF' + add_library(gtest INTERFACE) + target_include_directories(gtest INTERFACE ${gtest.dev}/include) + target_link_libraries(gtest INTERFACE ${gtest}/lib/libgtest.so ''${CMAKE_THREAD_LIBS_INIT}) + add_dependencies(gtest GMock) + + add_library(gtest_main INTERFACE) + target_include_directories(gtest_main INTERFACE ${gtest.dev}/include) + target_link_libraries(gtest_main INTERFACE ${gtest}/lib/libgtest_main.so gtest) + + add_library(gmock INTERFACE) + target_include_directories(gmock INTERFACE ${gtest.dev}/include) + target_link_libraries(gmock INTERFACE ${gtest}/lib/libgmock.so gtest) + + add_library(gmock_main INTERFACE) + target_include_directories(gmock_main INTERFACE ${gtest.dev}/include) + target_link_libraries(gmock_main INTERFACE ${gtest}/lib/libgmock_main.so gmock gtest_main) + EOF + ''; + + buildInputs = [ + gtest + libapparmor + libvirt + libxml2 + openssl + qtbase + qtx11extras + ]; + + nativeBuildInputs = [ + cmake + git + pkg-config + slang + wrapQtAppsHook + ]; + + nativeCheckInputs = [ gtest ]; + + postInstall = '' + wrapProgram $out/bin/multipassd --prefix PATH : ${lib.makeBinPath [ + dnsmasq + iproute2 + iptables + OVMF.fd + qemu + qemu-utils + xterm + ]} + ''; + + passthru.tests = { + multipass = nixosTests.multipass; + }; + + meta = with lib; { + description = "Ubuntu VMs on demand for any workstation."; + homepage = "https://multipass.run"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ jnsgruk ]; + platforms = [ "x86_64-linux" ]; + }; +} |