summary refs log tree commit diff
path: root/pkgs/tools/virtualization/google-guest-configs/default.nix
blob: dd3c01c6229a065901350136701db9c9dcdccf6c (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
{ stdenv, lib, fetchFromGitHub, makeWrapper, substituteAll
, ipcalc, iproute2, util-linux, coreutils, ethtool, gnugrep, gnused, nvme-cli }:

stdenv.mkDerivation rec {
  pname = "google-guest-configs";
  version = "20211116.00";

  src = fetchFromGitHub {
    owner = "GoogleCloudPlatform";
    repo = "guest-configs";
    rev = version;
    sha256 = "sha256-0SRu6p/DsHNNI20mkXJitt/Ee5S2ooiy5hNmD+ndecM=";
  };

  binDeps = lib.makeBinPath [ coreutils util-linux gnugrep gnused ethtool ipcalc iproute2 ];

  nativeBuildInputs = [ makeWrapper ];

  dontConfigure = true;
  dontBuild = true;

  postPatch = ''
    substitute ${./fix-paths.patch} fix-paths.patch \
      --subst-var out \
      --subst-var-by nvme "${nvme-cli}/bin/nvme" \
      --subst-var-by sh "${stdenv.shell}" \
      --subst-var-by umount "${util-linux}/bin/umount" \
      --subst-var-by logger "${util-linux}/bin/logger"
    patch -p1 < ./fix-paths.patch
  '';

  installPhase = ''
    mkdir -p $out/{bin,etc,lib}
    cp -r src/etc/{modprobe.d,sysctl.d} $out/etc
    cp -r src/lib/udev $out/lib
    cp -r src/sbin/* $out/bin
    cp -r src/usr/bin/* $out/bin

    for i in $out/bin/* $out/lib/udev/google_nvme_id; do
      wrapProgram "$i" \
        --prefix "PATH" ":" "$binDeps"
    done
  '';

  meta = with lib; {
    homepage = "https://github.com/GoogleCloudPlatform/guest-configs";
    description = "Linux Guest Environment for Google Compute Engine";
    license = licenses.asl20;
    platforms = platforms.linux;
    maintainers = with maintainers; [ abbradar ];
  };
}