about summary refs log tree commit diff
path: root/pkgs/tools/virtualization/multipass
diff options
context:
space:
mode:
authorJon Seager <jon@sgrs.uk>2023-06-08 18:27:47 +0100
committerJon Seager <jon@sgrs.uk>2023-06-08 18:36:49 +0100
commit3253665046f7a5ba6f68e50a3aa0c7ee762b507d (patch)
treeb466da55ae381c0cc6e2da5ec3b70a8ff54fc2d1 /pkgs/tools/virtualization/multipass
parentd56e6a4da342c5de58158bfd8c5d85383da071bf (diff)
multipass: 1.11.1 -> 1.12.0
Diffstat (limited to 'pkgs/tools/virtualization/multipass')
-rw-r--r--pkgs/tools/virtualization/multipass/cmake_no_fetch.patch32
-rw-r--r--pkgs/tools/virtualization/multipass/default.nix44
-rw-r--r--pkgs/tools/virtualization/multipass/lxd_socket_path.patch13
3 files changed, 71 insertions, 18 deletions
diff --git a/pkgs/tools/virtualization/multipass/cmake_no_fetch.patch b/pkgs/tools/virtualization/multipass/cmake_no_fetch.patch
new file mode 100644
index 0000000000000..fc1c472ef3a63
--- /dev/null
+++ b/pkgs/tools/virtualization/multipass/cmake_no_fetch.patch
@@ -0,0 +1,32 @@
+diff --git a/3rd-party/CMakeLists.txt b/3rd-party/CMakeLists.txt
+index 188ebfc6..4a34a922 100644
+--- a/3rd-party/CMakeLists.txt
++++ b/3rd-party/CMakeLists.txt
+@@ -2,12 +2,8 @@ include(FetchContent)
+ set(FETCHCONTENT_QUIET FALSE)
+ 
+ FetchContent_Declare(gRPC
+-  GIT_REPOSITORY https://github.com/CanonicalLtd/grpc.git
+-  GIT_TAG ba8e7f72
+-  GIT_SHALLOW TRUE
+-  GIT_SUBMODULES "third_party/abseil-cpp third_party/cares/cares third_party/protobuf third_party/re2 third_party/zlib"
+-  GIT_SUBMODULES_RECURSE false
+-  GIT_PROGRESS TRUE
++  DOWNLOAD_COMMAND true
++  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/grpc
+ )
+ set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
+ 
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 52bd407f..a1100112 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -28,7 +28,7 @@ FetchContent_Declare(googletest
+ )
+ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+ set(INSTALL_GTEST OFF CACHE BOOL "")
+-FetchContent_MakeAvailable(googletest)
++# FetchContent_MakeAvailable(googletest)
+ 
+ add_executable(multipass_tests
+   blueprint_test_lambdas.cpp
diff --git a/pkgs/tools/virtualization/multipass/default.nix b/pkgs/tools/virtualization/multipass/default.nix
index 6bb451aa9e853..6f489a607da8e 100644
--- a/pkgs/tools/virtualization/multipass/default.nix
+++ b/pkgs/tools/virtualization/multipass/default.nix
@@ -25,43 +25,51 @@
 
 let
   pname = "multipass";
-  version = "1.11.1";
+  version = "1.12.0";
+
+  # This is done here because a CMakeLists.txt from one of it's submodules tries
+  # to modify a file, so we grab the source for the submodule here, copy it into
+  # the source of the Multipass project which allows the modification to happen.
+  grpc_src = fetchFromGitHub {
+    owner = "CanonicalLtd";
+    repo = "grpc";
+    rev = "ba8e7f72a57b9e0b25783a4d3cea58c79379f194";
+    hash = "sha256-DS1UNLCUdbipn5w4p2aVa8LgHHhdJiAfzfEdIXNO69o=";
+    fetchSubmodules = true;
+  };
 in
-stdenv.mkDerivation {
+stdenv.mkDerivation
+{
   inherit pname version;
 
   src = fetchFromGitHub {
     owner = "canonical";
     repo = "multipass";
     rev = "refs/tags/v${version}";
-    sha256 = "sha256-AIZs+NRAn/r9EjTx9InDZzS4ycni4MZQXmC0A5rpaJk=";
+    sha256 = "sha256-CwyiLkpyTfn4734ESnHHWwiMdy3AP0BuQv6Uc1nTAuU=";
     fetchSubmodules = true;
   };
 
-  preConfigure = ''
+  patches = [
+    ./lxd_socket_path.patch
+    ./cmake_no_fetch.patch
+  ];
+
+  postPatch = ''
+    # Make sure the version is reported correctly in the compiled binary.
     substituteInPlace ./CMakeLists.txt \
       --replace "determine_version(MULTIPASS_VERSION)" "" \
       --replace 'set(MULTIPASS_VERSION ''${MULTIPASS_VERSION})' 'set(MULTIPASS_VERSION "v${version}")'
 
+    # Patch the patch of the OVMF binaries to use paths from the nix store.
     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)" ""
+    # Copy the grpc submodule we fetched into the source code.
+    cp -r --no-preserve=mode ${grpc_src} 3rd-party/grpc
 
+    # Configure CMake to use gtest from the nix store since we disabled fetching from the internet.
     cat >> tests/CMakeLists.txt <<'EOF'
       add_library(gtest INTERFACE)
       target_include_directories(gtest INTERFACE ${gtest.dev}/include)
diff --git a/pkgs/tools/virtualization/multipass/lxd_socket_path.patch b/pkgs/tools/virtualization/multipass/lxd_socket_path.patch
new file mode 100644
index 0000000000000..e23e8f72dcd7d
--- /dev/null
+++ b/pkgs/tools/virtualization/multipass/lxd_socket_path.patch
@@ -0,0 +1,13 @@
+diff --git a/src/platform/backends/lxd/lxd_request.h b/src/platform/backends/lxd/lxd_request.h
+index 4b5e8840..5e673ad7 100644
+--- a/src/platform/backends/lxd/lxd_request.h
++++ b/src/platform/backends/lxd/lxd_request.h
+@@ -27,7 +27,7 @@
+ 
+ namespace multipass
+ {
+-const QUrl lxd_socket_url{"unix:///var/snap/lxd/common/lxd/unix.socket@1.0"};
++const QUrl lxd_socket_url{"unix:///var/lib/lxd/unix.socket@1.0"};
+ const QString lxd_project_name{"multipass"};
+ 
+ class NetworkAccessManager;