Unverified Commit d442cbb8 authored by Nick Cao's avatar Nick Cao
Browse files
parent 766cbeb0
Loading
Loading
Loading
Loading
+30 −17
Original line number Diff line number Diff line
@@ -14,21 +14,31 @@
  libkrunfw,
  rustc,
  withBlk ? false,
  withNet ? false,
  withGpu ? false,
  withSound ? false,
  withNet ? false,
  sevVariant ? false,
  withTimesync ? false,
  variant ? null,
}:

assert lib.elem variant [
  null
  "sev"
  "tdx"
];

let
  libkrunfw' = (libkrunfw.override { inherit variant; });
in
stdenv.mkDerivation (finalAttrs: {
  pname = "libkrun";
  version = "1.11.2";
  pname = "libkrun" + lib.optionalString (variant != null) "-${variant}";
  version = "1.15.1";

  src = fetchFromGitHub {
    owner = "containers";
    repo = "libkrun";
    tag = "v${finalAttrs.version}";
    hash = "sha256-B11f7uG/oODwkME2rauCFbVysxUtUrUmd6RKeuBdnUU=";
    hash = "sha256-VhlFyYJ/TH12I3dUq0JTus60rQEJq5H4Pm1puCnJV5A=";
  };

  outputs = [
@@ -38,15 +48,14 @@ stdenv.mkDerivation (finalAttrs: {

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit (finalAttrs) src;
    hash = "sha256-bcHy8AfO9nzSZKoFlEpPKvwupt3eMb+A2rHDaUzO3/U=";
    hash = "sha256-dK3V7HCCvTqmQhB5Op2zmBPa9FO3h9gednU9tpQk+1U=";
  };

  # Make sure libkrunfw can be found by dlopen()
  # FIXME: This wasn't needed previously. What changed?
  env.RUSTFLAGS = toString (
    map (flag: "-C link-arg=" + flag) [
      "-Wl,--push-state,--no-as-needed"
      (if sevVariant then "-lkrunfw-sev" else "-lkrunfw")
      ("-lkrunfw" + lib.optionalString (variant != null) "-${variant}")
      "-Wl,--pop-state"
    ]
  );
@@ -57,10 +66,10 @@ stdenv.mkDerivation (finalAttrs: {
    cargo
    rustc
  ]
  ++ lib.optional (sevVariant || withGpu) pkg-config;
  ++ lib.optional (variant == "sev" || variant == "tdx" || withGpu) pkg-config;

  buildInputs = [
    (libkrunfw.override { variant = if sevVariant then "sev" else null; })
    libkrunfw'
    glibc
    glibc.static
  ]
@@ -70,16 +79,18 @@ stdenv.mkDerivation (finalAttrs: {
    virglrenderer
  ]
  ++ lib.optional withSound pipewire
  ++ lib.optional sevVariant openssl;
  ++ lib.optional (variant == "sev" || variant == "tdx") openssl;

  makeFlags = [
    "PREFIX=${placeholder "out"}"
  ]
  ++ lib.optional withBlk "BLK=1"
  ++ lib.optional withNet "NET=1"
  ++ lib.optional withGpu "GPU=1"
  ++ lib.optional withSound "SND=1"
  ++ lib.optional withNet "NET=1"
  ++ lib.optional sevVariant "SEV=1";
  ++ lib.optional withTimesync "TIMESYNC=1"
  ++ lib.optional (variant == "sev") "SEV=1"
  ++ lib.optional (variant == "tdx") "TDX=1";

  postInstall = ''
    mkdir -p $dev/lib/pkgconfig
@@ -87,15 +98,17 @@ stdenv.mkDerivation (finalAttrs: {
    mv $out/include $dev/
  '';

  meta = with lib; {
  env.OPENSSL_NO_VENDOR = true;

  meta = {
    description = "Dynamic library providing Virtualization-based process isolation capabilities";
    homepage = "https://github.com/containers/libkrun";
    license = licenses.asl20;
    maintainers = with maintainers; [
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      nickcao
      RossComputerGuy
      nrabulinski
    ];
    platforms = libkrunfw.meta.platforms;
    platforms = libkrunfw'.meta.platforms;
  };
})
+2 −1
Original line number Diff line number Diff line
@@ -10515,7 +10515,8 @@ with pkgs;

  jool-cli = callPackage ../os-specific/linux/jool/cli.nix { };

  libkrun-sev = libkrun.override { sevVariant = true; };
  libkrun-sev = libkrun.override { variant = "sev"; };
  libkrun-tdx = libkrun.override { variant = "tdx"; };

  linthesia = callPackage ../games/linthesia/default.nix { };