summary refs log tree commit diff
path: root/pkgs/tools/virtualization
diff options
context:
space:
mode:
authorPaul Meyer <49727155+katexochen@users.noreply.github.com>2023-08-22 10:17:21 +0200
committerPaul Meyer <49727155+katexochen@users.noreply.github.com>2023-09-28 14:40:53 +0200
commit8271210aaae3b6f2cc59530b147dcbebf6e56164 (patch)
tree075aa35c03e4a4b61ee4b487add986a5605dff6b /pkgs/tools/virtualization
parentc19e5ee3015637c3d40a427593baf9931455017c (diff)
downloadnixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.tar
nixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.tar.gz
nixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.tar.bz2
nixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.tar.lz
nixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.tar.xz
nixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.tar.zst
nixpkgs-8271210aaae3b6f2cc59530b147dcbebf6e56164.zip
mkosi: add qemu for starting vms
Adding the option to build mkosi with qemu support, which enables
the usage of 'mkosi qemu' to boot the previously built image as VM.
This will only work for host=target right now, further effort
is required to allow target with different arch.

Co-authored-by: Malte Poll <mp@edgeless.systems>
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
Diffstat (limited to 'pkgs/tools/virtualization')
-rw-r--r--pkgs/tools/virtualization/mkosi/default.nix27
1 files changed, 20 insertions, 7 deletions
diff --git a/pkgs/tools/virtualization/mkosi/default.nix b/pkgs/tools/virtualization/mkosi/default.nix
index 608d60387f5..79a34b15fd4 100644
--- a/pkgs/tools/virtualization/mkosi/default.nix
+++ b/pkgs/tools/virtualization/mkosi/default.nix
@@ -1,15 +1,22 @@
 { lib
 , fetchFromGitHub
+, stdenv
 , python3
+, bubblewrap
+, systemd
+
+  # Python packages
 , setuptools
 , setuptools-scm
 , wheel
 , buildPythonApplication
 , pytestCheckHook
 , pefile
-, bubblewrap
-, systemd
-, stdenv
+
+  # Optional dependencies
+, withQemu ? false
+, qemu
+, OVMF
 }:
 let
   # For systemd features used by mkosi, see
@@ -43,10 +50,14 @@ buildPythonApplication rec {
   # Fix ctypes finding library
   # https://github.com/NixOS/nixpkgs/issues/7307
   patchPhase = lib.optionalString stdenv.isLinux ''
-    substituteInPlace mkosi/run.py --replace \
-      'ctypes.util.find_library("c")' "'${stdenv.cc.libc}/lib/libc.so.6'"
-    substituteInPlace mkosi/__init__.py --replace \
-      '/usr/lib/systemd/ukify' "${systemdForMkosi}/lib/systemd/ukify"
+    substituteInPlace mkosi/run.py \
+      --replace 'ctypes.util.find_library("c")' "'${stdenv.cc.libc}/lib/libc.so.6'"
+    substituteInPlace mkosi/__init__.py \
+      --replace '/usr/lib/systemd/ukify' "${systemdForMkosi}/lib/systemd/ukify"
+  '' + lib.optionalString withQemu ''
+    substituteInPlace mkosi/qemu.py \
+      --replace '/usr/share/ovmf/x64/OVMF_VARS.fd' "${OVMF.variables}" \
+      --replace '/usr/share/ovmf/x64/OVMF_CODE.fd' "${OVMF.firmware}"
   '';
 
   nativeBuildInputs = [
@@ -62,6 +73,8 @@ buildPythonApplication rec {
   propagatedBuildInputs = [
     systemdForMkosi
     bubblewrap
+  ] ++ lib.optional withQemu [
+    qemu
   ];
 
   postInstall = ''