From e4937ed7c2bc6bf0aecf125cb214cf403d2c3c39 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Mon, 30 Mar 2026 13:16:06 +0200 Subject: [PATCH] crun: enable libkrun support when applicable This patch makes `crun` build with `libkrun` support when applicable, so that `podman` can be used with `--runtime krun` to run containers as `libkrun`-managed microvms out of the box. --- pkgs/by-name/cr/crun/package.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkgs/by-name/cr/crun/package.nix b/pkgs/by-name/cr/crun/package.nix index fa878d0e9395..e6106da772a2 100644 --- a/pkgs/by-name/cr/crun/package.nix +++ b/pkgs/by-name/cr/crun/package.nix @@ -6,6 +6,8 @@ go-md2man, pkg-config, libcap, + libkrun, + libkrun-sev, libseccomp, python3, systemdMinimal, @@ -13,6 +15,8 @@ nixosTests, criu, versionCheckHook, + withLibkrun ? lib.meta.availableOn stdenv.hostPlatform libkrun, + withLibkrunSEV ? false, }: let @@ -70,6 +74,16 @@ stdenv.mkDerivation (finalAttrs: { libseccomp systemdMinimal yajl + ] + ++ lib.optionals withLibkrun [ + libkrun + ] + ++ lib.optionals withLibkrunSEV [ + libkrun-sev + ]; + + configureFlags = lib.optionals withLibkrun [ + "--with-libkrun" ]; enableParallelBuilding = true; @@ -88,6 +102,14 @@ stdenv.mkDerivation (finalAttrs: { ${lib.concatMapStringsSep "\n" ( e: "substituteInPlace Makefile.am --replace-fail 'tests/${e}' ''" ) disabledTests} + '' + + lib.optionalString withLibkrun '' + substituteInPlace src/libcrun/handlers/krun.c \ + --replace-fail '"libkrun.so.1"' '"${libkrun}/lib/libkrun.so.1"' + '' + + lib.optionalString withLibkrunSEV '' + substituteInPlace src/libcrun/handlers/krun.c \ + --replace-fail '"libkrun-sev.so.1"' '"${libkrun-sev}/lib/libkrun-sev.so.1"' ''; doCheck = true;