about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/admin/amazon-ec2-utils/default.nix
blob: ed472b2a930e1d0a9eb783cc05c802d552b5fe1d (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
67
68
69
70
71
72
73
74
75
76
77
78
{ stdenv
, lib
, fetchFromGitHub
, bash
, python3
, installShellFiles
, gawk
, curl
}:

stdenv.mkDerivation rec {
  pname = "amazon-ec2-utils";
  version = "2.1.0";

  src = fetchFromGitHub {
    owner = "amazonlinux";
    repo = "amazon-ec2-utils";
    rev = "refs/tags/v${version}";
    hash = "sha256-Yr6pVwyvyVGV4xrjL7VFSkRH8d1w8VLPMTVjXfneJUM=";
  };

  outputs = [ "out" "man" ];

  strictDeps = true;

  buildInputs = [
    bash
    python3
  ];

  nativeBuildInputs = [
    installShellFiles
  ];

  installPhase = ''
    install -Dm755 -t $out/bin/ ebsnvme-id
    install -Dm755 -t $out/bin/ ec2-metadata
    install -Dm755 -t $out/bin/ ec2nvme-nsid
    install -Dm755 -t $out/bin/ ec2udev-vbd

    install -Dm644 -t $out/lib/udev/rules.d/ 51-ec2-hvm-devices.rules
    install -Dm644 -t $out/lib/udev/rules.d/ 51-ec2-xen-vbd-devices.rules
    install -Dm644 -t $out/lib/udev/rules.d/ 53-ec2-read-ahead-kb.rules
    install -Dm644 -t $out/lib/udev/rules.d/ 70-ec2-nvme-devices.rules
    install -Dm644 -t $out/lib/udev/rules.d/ 60-cdrom_id.rules

    installManPage doc/*.8
  '';

  postFixup = ''
    for i in $out/etc/udev/rules.d/*.rules $out/lib/udev/rules.d/*.rules ; do
      substituteInPlace "$i" \
        --replace '/usr/sbin' "$out/bin" \
        --replace '/bin/awk' '${gawk}/bin/awk'
    done

    substituteInPlace "$out/bin/ec2-metadata" \
      --replace 'curl' '${curl}/bin/curl'
  '';

  doInstallCheck = true;

  # We cannot run
  #     ec2-metadata --help
  # because it actually checks EC2 metadata even if --help is given
  # so it won't work in the test sandbox.
  installCheckPhase = ''
    $out/bin/ebsnvme-id --help
  '';

  meta = with lib; {
    changelog = "https://github.com/amazonlinux/amazon-ec2-utils/releases/tag/v${version}";
    description = "Contains a set of utilities and settings for Linux deployments in EC2";
    homepage = "https://github.com/amazonlinux/amazon-ec2-utils";
    license = licenses.mit;
    maintainers = with maintainers; [ ketzacoatl thefloweringash anthonyroussel ];
  };
}