2020-04-22 00:39:05 +01:00
|
|
|
{ stdenv, lib, rustPlatform, fetchgit, runCommand, symlinkJoin
|
2021-01-17 02:09:27 +00:00
|
|
|
, pkg-config, minijail, dtc, libusb1, libcap, linux
|
2018-12-14 03:50:21 +00: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";
|
|
|
|
|
2019-12-17 17:49:39 +00:00
|
|
|
crosvmSrc = fetchgit {
|
|
|
|
inherit (upstreamInfo.components."chromiumos/platform/crosvm")
|
|
|
|
url rev sha256 fetchSubmodules;
|
|
|
|
};
|
|
|
|
|
|
|
|
adhdSrc = fetchgit {
|
|
|
|
inherit (upstreamInfo.components."chromiumos/third_party/adhd")
|
|
|
|
url rev sha256 fetchSubmodules;
|
|
|
|
};
|
2018-12-14 03:50:21 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "crosvm";
|
|
|
|
inherit (upstreamInfo) version;
|
|
|
|
|
2019-12-17 17:49:39 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
runHook preUnpack
|
|
|
|
|
|
|
|
mkdir -p chromiumos/platform chromiumos/third_party
|
|
|
|
|
|
|
|
pushd chromiumos/platform
|
|
|
|
unpackFile ${crosvmSrc}
|
|
|
|
mv ${crosvmSrc.name} crosvm
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd chromiumos/third_party
|
|
|
|
unpackFile ${adhdSrc}
|
|
|
|
mv ${adhdSrc.name} adhd
|
|
|
|
popd
|
2018-12-14 03:50:21 +00:00
|
|
|
|
2019-12-17 17:49:39 +00:00
|
|
|
chmod -R u+w -- "$sourceRoot"
|
|
|
|
|
|
|
|
runHook postUnpack
|
|
|
|
'';
|
|
|
|
|
|
|
|
sourceRoot = "chromiumos/platform/crosvm";
|
2018-12-14 03:50:21 +00:00
|
|
|
|
|
|
|
patches = [
|
2019-12-17 17:49:39 +00:00
|
|
|
./default-seccomp-policy-dir.diff
|
2018-12-14 03:50:21 +00:00
|
|
|
];
|
|
|
|
|
2020-04-22 00:39:05 +01:00
|
|
|
cargoSha256 = "0lhivwvdihslwp81i3sa5q88p5hr83bzkvklrcgf6x73arwk8kdz";
|
2018-12-14 03:50:21 +00:00
|
|
|
|
2021-01-17 02:09:27 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2018-12-14 03:50:21 +00:00
|
|
|
|
|
|
|
buildInputs = [ dtc libcap libusb1 minijail ];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
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 00:39:05 +01:00
|
|
|
CROSVM_CARGO_TEST_KERNEL_BINARY =
|
|
|
|
lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform)
|
2021-01-23 01:33:55 +00:00
|
|
|
"${linux}/${stdenv.hostPlatform.linux-kernel.target}";
|
2020-04-22 00:39:05 +01:00
|
|
|
|
2019-12-17 17:49:39 +00:00
|
|
|
passthru = {
|
|
|
|
inherit adhdSrc;
|
|
|
|
src = crosvmSrc;
|
|
|
|
updateScript = ./update.py;
|
|
|
|
};
|
2018-12-14 03:50:21 +00:00
|
|
|
|
2020-04-22 00:39:05 +01:00
|
|
|
meta = with lib; {
|
2018-12-14 03:50:21 +00:00
|
|
|
description = "A secure virtual machine monitor for KVM";
|
|
|
|
homepage = "https://chromium.googlesource.com/chromiumos/platform/crosvm/";
|
2019-12-18 11:33:16 +00:00
|
|
|
maintainers = with maintainers; [ qyliss ];
|
2018-12-14 03:50:21 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = [ "aarch64-linux" "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|