Skip to content

Commit

Permalink
genpolicy-msft: add support for volumeDevices
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed May 24, 2024
1 parent ab55f1a commit ccc6ee3
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions packages/by-name/genpolicy-msft/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

{ lib
, fetchFromGitHub
, fetchurl
, fetchpatch
, applyPatches
, pkgs
, rustPlatform
, openssl
, pkg-config
Expand All @@ -25,6 +26,17 @@ rustPlatform.buildRustPackage rec {
hash = "sha256-W36RJFf0MVRIBV4ahpv6pqdAwgRYrlqmu4Y/8qiILS8=";
};

patches = [
# TODO(burgerdev): drop this patch after upstream applied it
(fetchpatch {
name = "genpolicy_device_support.patch";
url = "https://github.com/kata-containers/kata-containers/commit/f61b43777834f097fcca26864ee634125d9266ef.patch";
sha256 = "sha256-wBOyrFY4ZdWBjF5bIrHm7CFy6lVclcvwhF85wXpFZoc=";
})
];

patchFlags = [ "-p4" ];

sourceRoot = "${src.name}/src/tools/genpolicy";

cargoHash = "sha256-YxIwsjs4K0TNVlwwA+PrOrCf16h7ZW+zU/jXeFfIMZo=";
Expand All @@ -49,14 +61,16 @@ rustPlatform.buildRustPackage rec {
'';

passthru = rec {
settings = fetchurl {
settings = pkgs.stdenv.mkDerivation {
name = "${pname}-${version}-settings";
# TODO(burgerdev): see whether future releases contain this file as an asset again (not true for 3.2.0.azl1).
url = "https://raw.githubusercontent.com/microsoft/kata-containers/${version}/src/tools/genpolicy/genpolicy-settings.json";
hash = "sha256-jrhzDqesm16yCV3aex48c2OcEimCUrxwhoaJUtAMPvo=";
downloadToTemp = true;
recursiveHash = true;
postFetch = "install -D $downloadedFile $out/genpolicy-settings.json";
inherit src sourceRoot patches patchFlags;

phases = [ "unpackPhase" "patchPhase" "installPhase" ];
installPhase = ''
runHook preInstall
install -D genpolicy-settings.json $out/genpolicy-settings.json
runHook postInstall
'';
};

# Settings that allow exec into CVM pods - not safe for production use!
Expand All @@ -65,14 +79,16 @@ rustPlatform.buildRustPackage rec {
patches = [ ./genpolicy_msft_settings_dev.patch ];
};

rules = fetchurl {
rules = pkgs.stdenv.mkDerivation {
name = "${pname}-${version}-rules";
# TODO(burgerdev): see whether future releases contain this file as an asset again (not true for 3.2.0.azl1).
url = "https://raw.githubusercontent.com/microsoft/kata-containers/${version}/src/tools/genpolicy/rules.rego";
hash = "sha256-fhE5hDND5QeZtEw3u+qgSVsFO+00cc41k/r/Y+km6TU=";
downloadToTemp = true;
recursiveHash = true;
postFetch = "install -D $downloadedFile $out/genpolicy-rules.rego";
inherit src sourceRoot patches patchFlags;

phases = [ "unpackPhase" "patchPhase" "installPhase" ];
installPhase = ''
runHook preInstall
install -D rules.rego $out/genpolicy-rules.rego
runHook postInstall
'';
};

rules-coordinator = applyPatches {
Expand Down

0 comments on commit ccc6ee3

Please sign in to comment.