summary refs log tree commit diff
path: root/pkgs/tools/virtualization/google-guest-agent/default.nix
blob: 423f43a02de03fbd3fddc7e27d2529074e8ceab4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ lib
, buildGoModule
, fetchFromGitHub
, coreutils
, makeWrapper
, google-guest-configs
, google-guest-oslogin
, iproute2
, procps
}:

buildGoModule rec {
  pname = "guest-agent";
  version = "20230821.00";

  src = fetchFromGitHub {
    owner = "GoogleCloudPlatform";
    repo = pname;
    rev = "refs/tags/${version}";
    hash = "sha256-DP15KDnD09edBxOQDwP0cjVIFxjMzE1hu1Sbu6Faj9Y=";
  };

  vendorHash = "sha256-PGvyDjhLwIKhR6NmwzbzjfkBK+FqsziAdsybQmCbtCc=";

  patches = [ ./disable-etc-mutation.patch ];

  nativeBuildInputs = [ makeWrapper ];

  postPatch = ''
    substitute ${./fix-paths.patch} fix-paths.patch \
      --subst-var out \
      --subst-var-by true "${coreutils}/bin/true"
    patch -p1 < ./fix-paths.patch
  '';

  # We don't add `shadow` here; it's added to PATH if `mutableUsers` is enabled.
  binPath = lib.makeBinPath [
    google-guest-configs
    google-guest-oslogin
    iproute2
    procps
  ];

  # Skip tests which require networking.
  preCheck = ''
    rm google_guest_agent/wsfc_test.go
  '';

  postInstall = ''
    mkdir -p $out/etc/systemd/system
    cp *.service $out/etc/systemd/system
    install -Dm644 instance_configs.cfg $out/etc/default/instance_configs.cfg

    wrapProgram $out/bin/google_guest_agent \
      --prefix PATH ":" "$binPath"
  '';

  meta = with lib; {
    description = "Guest Agent for Google Compute Engine";
    homepage = "https://github.com/GoogleCloudPlatform/guest-agent";
    changelog = "https://github.com/GoogleCloudPlatform/guest-agent/releases/tag/${version}";
    license = licenses.asl20;
    maintainers = with maintainers; [ abbradar ];
    platforms = platforms.linux;
  };
}