From f2eeeae35ed3854ac5005c41a3b66a769a3cf394 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Sat, 13 Aug 2022 17:42:36 +0800 Subject: [PATCH 1/3] libkrunfw: init at 3.3.0 --- .../libraries/libkrunfw/default.nix | 49 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 51 insertions(+) create mode 100644 pkgs/development/libraries/libkrunfw/default.nix diff --git a/pkgs/development/libraries/libkrunfw/default.nix b/pkgs/development/libraries/libkrunfw/default.nix new file mode 100644 index 000000000000..10ff37460496 --- /dev/null +++ b/pkgs/development/libraries/libkrunfw/default.nix @@ -0,0 +1,49 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchurl +, flex +, bison +, bc +, elfutils +, python3 +, sevVariant ? false +}: + +assert sevVariant -> stdenv.isx86_64; +stdenv.mkDerivation rec { + pname = "libkrunfw"; + version = "3.3.0"; + + src = fetchFromGitHub { + owner = "containers"; + repo = pname; + rev = "v${version}"; + hash = "sha256-ay+E5AgJeA0i3T4JDosDawwtezDGquzAvYEWHGbPidg="; + }; + + kernelSrc = fetchurl { + url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.59.tar.xz"; + hash = "sha256-5t3GQgVzQNsGs7khwrMb/tLGETWejxRMPlz5w6wzvMs="; + }; + + preBuild = '' + substituteInPlace Makefile --replace 'curl $(KERNEL_REMOTE) -o $(KERNEL_TARBALL)' 'ln -s $(kernelSrc) $(KERNEL_TARBALL)' + ''; + + nativeBuildInputs = [ flex bison bc python3 python3.pkgs.pyelftools ]; + buildInputs = [ elfutils ]; + + makeFlags = [ "PREFIX=${placeholder "out"}" ] + ++ lib.optional sevVariant "SEV=1"; + + enableParallelBuilding = true; + + meta = with lib; { + description = "A dynamic library bundling the guest payload consumed by libkrun"; + homepage = "https://github.com/containers/libkrunfw"; + license = with licenses; [ lgpl2Only lgpl21Only ]; + maintainers = with maintainers; [ nickcao ]; + platforms = [ "x86_64-linux" "aarch64-linux" ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d3c097f739ca..534feb374694 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23877,6 +23877,8 @@ with pkgs; libcgroup = callPackage ../os-specific/linux/libcgroup { }; + libkrunfw = callPackage ../development/libraries/libkrunfw { }; + libnl = callPackage ../os-specific/linux/libnl { }; libtraceevent = callPackage ../os-specific/linux/libtraceevent {}; From 412a17da665c76f2d0818ed10976ca459bd2fcf1 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Sat, 13 Aug 2022 17:43:05 +0800 Subject: [PATCH 2/3] libkrun: init at 1.3.0 --- .../development/libraries/libkrun/default.nix | 49 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 ++ 2 files changed, 53 insertions(+) create mode 100644 pkgs/development/libraries/libkrun/default.nix diff --git a/pkgs/development/libraries/libkrun/default.nix b/pkgs/development/libraries/libkrun/default.nix new file mode 100644 index 000000000000..21be0c8437ae --- /dev/null +++ b/pkgs/development/libraries/libkrun/default.nix @@ -0,0 +1,49 @@ +{ lib +, stdenv +, fetchFromGitHub +, rustPlatform +, pkg-config +, glibc +, openssl +, libkrunfw +, sevVariant ? false +}: + +stdenv.mkDerivation rec { + pname = "libkrun"; + version = "1.3.0"; + + src = fetchFromGitHub { + owner = "containers"; + repo = pname; + rev = "v${version}"; + hash = "sha256-qVyEqiqaQ8wfZhL5u+Bsaa1yXlgHUitSj5bo7FJ5Y8c="; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + hash = "sha256-jxSzhj1iU8qY+sZEVCYTaUqpaA4egjJi9qxrapASQF0="; + }; + + nativeBuildInputs = with rustPlatform;[ + cargoSetupHook + rust.cargo + rust.rustc + ] ++ lib.optional sevVariant pkg-config; + + buildInputs = [ + glibc + glibc.static + (libkrunfw.override { inherit sevVariant; }) + ] ++ lib.optional sevVariant openssl; + + makeFlags = [ "PREFIX=${placeholder "out"}" ] + ++ lib.optional sevVariant "SEV=1"; + + meta = with lib; { + description = "A dynamic library providing Virtualization-based process isolation capabilities"; + homepage = "https://github.com/containers/libkrun"; + license = licenses.asl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 534feb374694..3827869cbc39 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23877,6 +23877,10 @@ with pkgs; libcgroup = callPackage ../os-specific/linux/libcgroup { }; + libkrun = callPackage ../development/libraries/libkrun { }; + + libkrun-sev = callPackage ../development/libraries/libkrun { sevVariant = true; }; + libkrunfw = callPackage ../development/libraries/libkrunfw { }; libnl = callPackage ../os-specific/linux/libnl { }; From 0edab34d9c41aac44c2794cebe2ad3ad64a0721c Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Sat, 13 Aug 2022 17:43:27 +0800 Subject: [PATCH 3/3] krunvm: init at 0.2.1 --- .../virtualization/krunvm/default.nix | 42 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 44 insertions(+) create mode 100644 pkgs/applications/virtualization/krunvm/default.nix diff --git a/pkgs/applications/virtualization/krunvm/default.nix b/pkgs/applications/virtualization/krunvm/default.nix new file mode 100644 index 000000000000..cd2ff0e706f4 --- /dev/null +++ b/pkgs/applications/virtualization/krunvm/default.nix @@ -0,0 +1,42 @@ +{ lib +, stdenv +, rustPlatform +, fetchFromGitHub +, asciidoctor +, libkrun +}: + +stdenv.mkDerivation rec { + pname = "krunvm"; + version = "0.2.1"; + + src = fetchFromGitHub { + owner = "containers"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-rR762L8P+7ebE0u4MVCJoXc5mmqXlDFfSas+lFBMVFQ="; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + hash = "sha256-3WiXm90XiQHpCbhlkigg/ZATQeDdUKTstN7hwcsKm4o="; + }; + + nativeBuildInputs = with rustPlatform;[ + cargoSetupHook + rust.cargo + rust.rustc + asciidoctor + ]; + + buildInputs = [ libkrun ]; + + makeFlags = [ "PREFIX=${placeholder "out"}" ]; + + meta = with lib; { + description = "A CLI-based utility for creating microVMs from OCI images"; + homepage = "https://github.com/containers/krunvm"; + license = licenses.asl20; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3827869cbc39..d5571d97707f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7857,6 +7857,8 @@ with pkgs; krunner-pass = libsForQt5.callPackage ../tools/security/krunner-pass { }; + krunvm = callPackage ../applications/virtualization/krunvm { }; + kronometer = libsForQt5.callPackage ../tools/misc/kronometer { }; krop = callPackage ../applications/graphics/krop { };