2022-03-15 20:48:29 +01:00
|
|
|
{ stdenv, lib, rustPlatform, fetchgit
|
|
|
|
, pkg-config, wayland-scanner, libcap, minijail, wayland, wayland-protocols
|
|
|
|
, linux
|
2018-12-14 04:50:21 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
upstreamInfo = with builtins; fromJSON (readFile ./upstream-info.json);
|
|
|
|
|
|
|
|
arch = with stdenv.hostPlatform;
|
|
|
|
if isAarch64 then "arm"
|
|
|
|
else if isx86_64 then "x86_64"
|
|
|
|
else throw "no seccomp policy files available for host platform";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "crosvm";
|
|
|
|
inherit (upstreamInfo) version;
|
|
|
|
|
2022-03-15 20:48:29 +01:00
|
|
|
src = fetchgit (builtins.removeAttrs upstreamInfo.src [ "date" "path" ]);
|
2018-12-14 04:50:21 +01:00
|
|
|
|
|
|
|
patches = [
|
2019-12-17 18:49:39 +01:00
|
|
|
./default-seccomp-policy-dir.diff
|
2018-12-14 04:50:21 +01:00
|
|
|
];
|
|
|
|
|
2022-03-15 20:48:29 +01:00
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
2018-12-14 04:50:21 +01:00
|
|
|
|
2022-03-15 20:48:29 +01:00
|
|
|
nativeBuildInputs = [ pkg-config wayland-scanner ];
|
2018-12-14 04:50:21 +01:00
|
|
|
|
2022-03-15 20:48:29 +01:00
|
|
|
buildInputs = [ libcap minijail wayland wayland-protocols ];
|
2018-12-14 04:50:21 +01:00
|
|
|
|
|
|
|
postPatch = ''
|
2022-03-15 20:48:29 +01:00
|
|
|
cp ${./Cargo.lock} Cargo.lock
|
2018-12-14 04:50:21 +01:00
|
|
|
sed -i "s|/usr/share/policy/crosvm/|$out/share/policy/|g" \
|
|
|
|
seccomp/*/*.policy
|
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
export DEFAULT_SECCOMP_POLICY_DIR=$out/share/policy
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/policy/
|
|
|
|
cp seccomp/${arch}/* $out/share/policy/
|
|
|
|
'';
|
|
|
|
|
2020-04-22 01:39:05 +02:00
|
|
|
CROSVM_CARGO_TEST_KERNEL_BINARY =
|
|
|
|
lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform)
|
2021-01-23 02:33:55 +01:00
|
|
|
"${linux}/${stdenv.hostPlatform.linux-kernel.target}";
|
2020-04-22 01:39:05 +02:00
|
|
|
|
2022-03-15 20:48:29 +01:00
|
|
|
passthru.updateScript = ./update.py;
|
2018-12-14 04:50:21 +01:00
|
|
|
|
2020-04-22 01:39:05 +02:00
|
|
|
meta = with lib; {
|
2018-12-14 04:50:21 +01:00
|
|
|
description = "A secure virtual machine monitor for KVM";
|
|
|
|
homepage = "https://chromium.googlesource.com/chromiumos/platform/crosvm/";
|
2019-12-18 12:33:16 +01:00
|
|
|
maintainers = with maintainers; [ qyliss ];
|
2018-12-14 04:50:21 +01:00
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = [ "aarch64-linux" "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|