Merge pull request #214193 from jnsgruk/add-multipass-pkg
multipass: init at 1.11.0
This commit is contained in:
commit
bc0944c06f
7 changed files with 236 additions and 0 deletions
|
@ -7015,6 +7015,12 @@
|
|||
githubId = 2308444;
|
||||
name = "Joshua Gilman";
|
||||
};
|
||||
jnsgruk = {
|
||||
email = "jon@sgrs.uk";
|
||||
github = "jnsgruk";
|
||||
githubId = 668505;
|
||||
name = "Jon Seager";
|
||||
};
|
||||
jo1gi = {
|
||||
email = "joakimholm@protonmail.com";
|
||||
github = "jo1gi";
|
||||
|
|
|
@ -1365,6 +1365,7 @@
|
|||
./virtualisation/lxc.nix
|
||||
./virtualisation/lxcfs.nix
|
||||
./virtualisation/lxd.nix
|
||||
./virtualisation/multipass.nix
|
||||
./virtualisation/nixos-containers.nix
|
||||
./virtualisation/oci-containers.nix
|
||||
./virtualisation/openstack-options.nix
|
||||
|
|
61
nixos/modules/virtualisation/multipass.nix
Normal file
61
nixos/modules/virtualisation/multipass.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.virtualisation.multipass;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
virtualisation.multipass = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc ''
|
||||
Multipass, a simple manager for virtualised Ubuntu instances.
|
||||
'');
|
||||
|
||||
logLevel = lib.mkOption {
|
||||
type = lib.types.enum [ "error" "warning" "info" "debug" "trace" ];
|
||||
default = "debug";
|
||||
description = lib.mdDoc ''
|
||||
The logging verbosity of the multipassd binary.
|
||||
'';
|
||||
};
|
||||
|
||||
package = lib.mkPackageOptionMD pkgs "multipass" { };
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
systemd.services.multipass = {
|
||||
description = "Multipass orchestrates virtual Ubuntu instances.";
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
environment = {
|
||||
"XDG_DATA_HOME" = "/var/lib/multipass/data";
|
||||
"XDG_CACHE_HOME" = "/var/lib/multipass/cache";
|
||||
"XDG_CONFIG_HOME" = "/var/lib/multipass/config";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/multipassd --logger platform --verbosity ${cfg.logLevel}";
|
||||
SyslogIdentifer = "multipassd";
|
||||
Restart = "on-failure";
|
||||
TimeoutStopSec = 300;
|
||||
Type = "simple";
|
||||
|
||||
WorkingDirectory = "/var/lib/multipass";
|
||||
|
||||
StateDirectory = "multipass";
|
||||
StateDirectoryMode = "0750";
|
||||
CacheDirectory = "multipass";
|
||||
CacheDirectoryMode = "0750";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -412,6 +412,7 @@ in {
|
|||
mpd = handleTest ./mpd.nix {};
|
||||
mpv = handleTest ./mpv.nix {};
|
||||
mtp = handleTest ./mtp.nix {};
|
||||
multipass = handleTest ./multipass.nix {};
|
||||
mumble = handleTest ./mumble.nix {};
|
||||
musescore = handleTest ./musescore.nix {};
|
||||
munin = handleTest ./munin.nix {};
|
||||
|
|
37
nixos/tests/multipass.nix
Normal file
37
nixos/tests/multipass.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
multipass-image = import ../release.nix {
|
||||
configuration = {
|
||||
# Building documentation makes the test unnecessarily take a longer time:
|
||||
documentation.enable = lib.mkForce false;
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
name = "multipass";
|
||||
|
||||
meta.maintainers = [ lib.maintainers.jnsgruk ];
|
||||
|
||||
nodes.machine = { lib, ... }: {
|
||||
virtualisation = {
|
||||
cores = 1;
|
||||
memorySize = 1024;
|
||||
diskSize = 4096;
|
||||
|
||||
multipass.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("sockets.target")
|
||||
machine.wait_for_unit("multipass.service")
|
||||
machine.wait_for_file("/var/lib/multipass/data/multipassd/network/multipass_subnet")
|
||||
|
||||
# Wait for Multipass to settle
|
||||
machine.sleep(1)
|
||||
|
||||
machine.succeed("multipass list")
|
||||
'';
|
||||
})
|
128
pkgs/tools/virtualization/multipass/default.nix
Normal file
128
pkgs/tools/virtualization/multipass/default.nix
Normal file
|
@ -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" ];
|
||||
};
|
||||
}
|
|
@ -9870,6 +9870,8 @@ with pkgs;
|
|||
|
||||
mubeng = callPackage ../tools/networking/mubeng { };
|
||||
|
||||
multipass = libsForQt5.callPackage ../tools/virtualization/multipass { };
|
||||
|
||||
multitime = callPackage ../tools/misc/multitime { };
|
||||
|
||||
sta = callPackage ../tools/misc/sta {};
|
||||
|
|
Loading…
Reference in a new issue