2017-05-29 16:32:48 +02:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2021-04-05 12:52:06 +02:00
|
|
|
, buildPythonPackage
|
2017-05-29 16:32:48 +02:00
|
|
|
, bash
|
2018-12-04 05:38:54 +01:00
|
|
|
, bashInteractive
|
2020-11-24 16:29:28 +01:00
|
|
|
, util-linux
|
2017-09-17 07:20:30 +02:00
|
|
|
, boto
|
|
|
|
, setuptools
|
2018-09-24 15:50:52 +02:00
|
|
|
, distro
|
2021-08-27 05:21:48 +02:00
|
|
|
, stdenv
|
|
|
|
, pythonOlder
|
|
|
|
, pytestCheckHook
|
2017-05-29 16:32:48 +02:00
|
|
|
}:
|
2017-09-17 07:20:30 +02:00
|
|
|
|
2021-08-27 05:21:48 +02:00
|
|
|
let
|
|
|
|
guest-configs = stdenv.mkDerivation rec {
|
|
|
|
pname = "guest-configs";
|
|
|
|
version = "20210702.00";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "GoogleCloudPlatform";
|
|
|
|
repo = "guest-configs";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "1965kdrb1ig3z4qwzvyzx1fb4282ak5vgxcvvg5k9c759pzbc5nn";
|
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ bash ];
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
# allows to install the package in `services.udev.packages` in NixOS
|
|
|
|
mkdir -p $out/lib/udev $out/bin
|
|
|
|
|
|
|
|
cp -r "src/lib/udev/rules.d" $out/lib/udev
|
|
|
|
cp "src/lib/udev/google_nvme_id" $out/bin
|
|
|
|
|
|
|
|
for rules in $out/lib/udev/*.rules; do
|
|
|
|
substituteInPlace "$rules" \
|
|
|
|
--replace /bin/sh "${bash}/bin/sh" \
|
|
|
|
--replace /bin/umount "${util-linux}/bin/umount" \
|
|
|
|
--replace /usr/bin/logger "${util-linux}/bin/logger"
|
|
|
|
done
|
|
|
|
|
|
|
|
# sysctl snippets will be used by google-compute-config.nix
|
|
|
|
cp -r "src/etc/sysctl.d" $out
|
|
|
|
|
|
|
|
patchShebangs $out/bin/*
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2021-04-05 12:52:06 +02:00
|
|
|
buildPythonPackage rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "google-compute-engine";
|
2021-08-27 05:21:48 +02:00
|
|
|
version = "20200113.0";
|
2017-05-29 16:32:48 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "GoogleCloudPlatform";
|
|
|
|
repo = "compute-image-packages";
|
2021-08-27 05:21:48 +02:00
|
|
|
rev = "506b9a0dbffec5620887660cd42c57b3cbbadba6";
|
|
|
|
sha256 = "0lmc426mvrajghpavhs6hwl19mgnnh08ziqx5yi15fzpnvwmb8vz";
|
2017-05-29 16:32:48 +02:00
|
|
|
};
|
|
|
|
|
2021-08-27 05:21:48 +02:00
|
|
|
buildInputs = [ bash guest-configs ];
|
|
|
|
propagatedBuildInputs = [ (if pythonOlder "3.7" then boto else distro) setuptools ];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
cd packages/python-google-compute-engine
|
|
|
|
'';
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
"testExtractInterfaceMetadata"
|
|
|
|
"testCallDhclientIpv6"
|
|
|
|
"testWriteConfig"
|
|
|
|
"testCreateInterfaceMapNetifaces"
|
|
|
|
"testCreateInterfaceMapSysfs"
|
|
|
|
"testGetNetworkInterface"
|
|
|
|
];
|
|
|
|
|
|
|
|
checkInputs = [ pytestCheckHook ];
|
2019-09-01 00:27:56 +02:00
|
|
|
|
2017-05-29 16:32:48 +02:00
|
|
|
postPatch = ''
|
|
|
|
for file in $(find google_compute_engine -type f); do
|
|
|
|
substituteInPlace "$file" \
|
2020-05-21 10:35:34 +02:00
|
|
|
--replace /bin/systemctl "/run/current-system/systemd/bin/systemctl" \
|
2018-12-04 05:38:54 +01:00
|
|
|
--replace /bin/bash "${bashInteractive}/bin/bash" \
|
2020-11-24 16:29:28 +01:00
|
|
|
--replace /sbin/hwclock "${util-linux}/bin/hwclock"
|
2017-05-29 16:32:48 +02:00
|
|
|
# SELinux tool ??? /sbin/restorecon
|
|
|
|
done
|
2019-09-01 00:27:56 +02:00
|
|
|
'';
|
2017-05-29 16:32:48 +02:00
|
|
|
|
2021-04-05 17:42:20 +02:00
|
|
|
pythonImportsCheck = [ "google_compute_engine" ];
|
2017-12-21 19:36:20 +01:00
|
|
|
|
2017-05-29 16:32:48 +02:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Google Compute Engine tools and services";
|
2017-09-17 07:20:30 +02:00
|
|
|
homepage = "https://github.com/GoogleCloudPlatform/compute-image-packages";
|
2017-05-29 16:32:48 +02:00
|
|
|
license = licenses.asl20;
|
2021-08-27 05:21:48 +02:00
|
|
|
maintainers = with maintainers; [ cpcloud zimbatm ];
|
2018-04-23 23:03:19 +02:00
|
|
|
platforms = platforms.linux;
|
2017-05-29 16:32:48 +02:00
|
|
|
};
|
|
|
|
}
|