Skip to content

Commit

Permalink
microsoft.kata-{agent,image}: inherit src/version from kata-runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Jul 5, 2024
1 parent 7c50fcd commit 31f02d2
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 66 deletions.
56 changes: 26 additions & 30 deletions packages/by-name/microsoft/kata-agent/package.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
# Copyright 2024 Edgeless Systems GmbH
# SPDX-License-Identifier: AGPL-3.0-only

{ lib
, rustPlatform
, fetchFromGitHub
, cmake
, pkg-config
, protobuf
, withSeccomp ? true
, libseccomp
, lvm2
, openssl
, withAgentPolicy ? true
, withStandardOCIRuntime ? false
{
lib,
rustPlatform,
microsoft,
cmake,
pkg-config,
protobuf,
withSeccomp ? true,
libseccomp,
lvm2,
openssl,
withAgentPolicy ? true,
withStandardOCIRuntime ? false,
}:

rustPlatform.buildRustPackage rec {
pname = "kata-agent";
version = "3.2.0.azl1";

src = fetchFromGitHub {
owner = "microsoft";
repo = "kata-containers";
rev = version;
hash = "sha256-W36RJFf0MVRIBV4ahpv6pqdAwgRYrlqmu4Y/8qiILS8=";
};
inherit (microsoft.kata-runtime) version src;

sourceRoot = "${src.name}/src/agent";

Expand All @@ -42,16 +36,18 @@ rustPlatform.buildRustPackage rec {
protobuf
];

buildInputs = [
openssl
openssl.dev
lvm2.dev
rustPlatform.bindgenHook
] ++ lib.optionals withSeccomp [
libseccomp.dev
libseccomp.lib
libseccomp
];
buildInputs =
[
openssl
openssl.dev
lvm2.dev
rustPlatform.bindgenHook
]
++ lib.optionals withSeccomp [
libseccomp.dev
libseccomp.lib
libseccomp
];

# Build.rs writes to src
postConfigure = ''
Expand Down
76 changes: 40 additions & 36 deletions packages/by-name/microsoft/kata-image/package.nix
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
# Copyright 2024 Edgeless Systems GmbH
# SPDX-License-Identifier: AGPL-3.0-only

{ lib
, stdenv
, stdenvNoCC
, distro ? "cbl-mariner"
, microsoft
, bubblewrap
, fakeroot
, fetchFromGitHub
, fetchurl
, yq-go
, tdnf
, curl
, util-linux
, writeText
, writeTextDir
, createrepo_c
, writeShellApplication
, parted
, cryptsetup
, closureInfo
, erofs-utils
{
lib,
stdenv,
stdenvNoCC,
distro ? "cbl-mariner",
microsoft,
bubblewrap,
fakeroot,
fetchFromGitHub,
fetchurl,
yq-go,
tdnf,
curl,
util-linux,
writeText,
writeTextDir,
createrepo_c,
writeShellApplication,
parted,
cryptsetup,
closureInfo,
erofs-utils,
}:

let
kata-version = "3.2.0.azl1";
src = fetchFromGitHub {
owner = "microsoft";
repo = "kata-containers";
rev = kata-version;
hash = "sha256-W36RJFf0MVRIBV4ahpv6pqdAwgRYrlqmu4Y/8qiILS8=";
};
# toplevelNixDeps are packages that get installed to the rootfs of the image
# they are used to determine the (nix) closure of the rootfs
toplevelNixDeps = [ microsoft.kata-agent ];
nixClosure = builtins.toString (lib.strings.splitString "\n" (builtins.readFile "${closureInfo {rootPaths = toplevelNixDeps;}}/store-paths"));
nixClosure = builtins.toString (
lib.strings.splitString "\n" (
builtins.readFile "${closureInfo { rootPaths = toplevelNixDeps; }}/store-paths"
)
);
rootfsExtraTree = stdenvNoCC.mkDerivation {
inherit src;
pname = "rootfs-extra-tree";
version = kata-version;
inherit (microsoft.genpolicy) src version;

# https://github.com/microsoft/azurelinux/blob/59ce246f224f282b3e199d9a2dacaa8011b75a06/SPECS/kata-containers-cc/mariner-coco-build-uvm.sh#L34-L41
buildPhase = ''
Expand All @@ -62,8 +59,13 @@ let
dontInstall = true;
};
packageIndex = builtins.fromJSON (builtins.readFile ./package-index.json);
rpmSources = lib.forEach packageIndex
(p: lib.concatStringsSep "#" [ (fetchurl p) (builtins.baseNameOf p.url) ]);
rpmSources = lib.forEach packageIndex (
p:
lib.concatStringsSep "#" [
(fetchurl p)
(builtins.baseNameOf p.url)
]
);

mirror = stdenvNoCC.mkDerivation {
name = "mirror";
Expand Down Expand Up @@ -113,11 +115,13 @@ let
in

stdenv.mkDerivation rec {
inherit src;
pname = "kata-image";
version = kata-version;
inherit (microsoft.genpolicy) src version;

outputs = [ "out" "verity" ];
outputs = [
"out"
"verity"
];

env = {
AGENT_SOURCE_BIN = "${lib.getExe microsoft.kata-agent}";
Expand Down

0 comments on commit 31f02d2

Please sign in to comment.