1{ lib
2, fetchFromGitHub
3, buildPythonPackage
4, bash
5, bashInteractive
6, util-linux
7, boto
8, setuptools
9, distro
10}:
11
12buildPythonPackage rec {
13 pname = "google-compute-engine";
14 version = "20190124";
15
16 src = fetchFromGitHub {
17 owner = "GoogleCloudPlatform";
18 repo = "compute-image-packages";
19 rev = version;
20 sha256 = "08cy0jd463kng6hwbd3nfldsp4dpd2lknlvdm88cq795wy0kh4wp";
21 };
22
23 buildInputs = [ bash ];
24 propagatedBuildInputs = [ boto setuptools distro ];
25
26 postPatch = ''
27 for file in $(find google_compute_engine -type f); do
28 substituteInPlace "$file" \
29 --replace /bin/systemctl "/run/current-system/systemd/bin/systemctl" \
30 --replace /bin/bash "${bashInteractive}/bin/bash" \
31 --replace /sbin/hwclock "${util-linux}/bin/hwclock"
32 # SELinux tool ??? /sbin/restorecon
33 done
34
35 substituteInPlace google_config/udev/64-gce-disk-removal.rules \
36 --replace /bin/sh "${bash}/bin/sh" \
37 --replace /bin/umount "${util-linux}/bin/umount" \
38 --replace /usr/bin/logger "${util-linux}/bin/logger"
39 '';
40
41 postInstall = ''
42 # allows to install the package in `services.udev.packages` in NixOS
43 mkdir -p $out/lib/udev/rules.d
44 cp -r google_config/udev/*.rules $out/lib/udev/rules.d
45
46 # sysctl snippets will be used by google-compute-config.nix
47 mkdir -p $out/sysctl.d
48 cp google_config/sysctl/*.conf $out/sysctl.d
49
50 patchShebangs $out/bin/*
51 '';
52
53 doCheck = false;
54 pythonImportsCheck = [ "google_compute_engine" ];
55
56 meta = with lib; {
57 description = "Google Compute Engine tools and services";
58 homepage = "https://github.com/GoogleCloudPlatform/compute-image-packages";
59 license = licenses.asl20;
60 maintainers = with maintainers; [ zimbatm ];
61 platforms = platforms.linux;
62 };
63}