Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 coreutils,
6 makeWrapper,
7 google-guest-configs,
8 google-guest-oslogin,
9 iproute2,
10 procps,
11}:
12
13buildGoModule rec {
14 pname = "guest-agent";
15 version = "20230821.00";
16
17 src = fetchFromGitHub {
18 owner = "GoogleCloudPlatform";
19 repo = "guest-agent";
20 tag = version;
21 hash = "sha256-DP15KDnD09edBxOQDwP0cjVIFxjMzE1hu1Sbu6Faj9Y=";
22 };
23
24 vendorHash = "sha256-PGvyDjhLwIKhR6NmwzbzjfkBK+FqsziAdsybQmCbtCc=";
25
26 patches = [ ./disable-etc-mutation.patch ];
27
28 nativeBuildInputs = [ makeWrapper ];
29
30 postPatch = ''
31 substitute ${./fix-paths.patch} fix-paths.patch \
32 --subst-var out \
33 --subst-var-by true "${coreutils}/bin/true"
34 patch -p1 < ./fix-paths.patch
35 '';
36
37 # We don't add `shadow` here; it's added to PATH if `mutableUsers` is enabled.
38 binPath = lib.makeBinPath [
39 google-guest-configs
40 google-guest-oslogin
41 iproute2
42 procps
43 ];
44
45 # Skip tests which require networking.
46 preCheck = ''
47 rm google_guest_agent/wsfc_test.go
48 '';
49
50 postInstall = ''
51 mkdir -p $out/etc/systemd/system
52 cp *.service $out/etc/systemd/system
53 install -Dm644 instance_configs.cfg $out/etc/default/instance_configs.cfg
54
55 wrapProgram $out/bin/google_guest_agent \
56 --prefix PATH ":" "$binPath"
57 '';
58
59 meta = {
60 description = "Guest Agent for Google Compute Engine";
61 homepage = "https://github.com/GoogleCloudPlatform/guest-agent";
62 changelog = "https://github.com/GoogleCloudPlatform/guest-agent/releases/tag/${version}";
63 license = lib.licenses.asl20;
64 maintainers = with lib.maintainers; [ abbradar ];
65 platforms = lib.platforms.linux;
66 };
67}