2021-01-09 10:05:03 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, curl
|
2022-02-10 20:34:41 +00:00
|
|
|
, gawk
|
2021-01-09 10:05:03 +00:00
|
|
|
, python3
|
2022-02-10 20:34:41 +00:00
|
|
|
, installShellFiles
|
2021-01-09 10:05:03 +00:00
|
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "amazon-ec2-utils";
|
2022-02-10 20:34:41 +00:00
|
|
|
version = "2.0";
|
2021-01-09 10:05:03 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "aws";
|
|
|
|
repo = "amazon-ec2-utils";
|
2022-02-10 20:34:41 +00:00
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-u1rHBV8uVcCywvQNYagtDleYB12tmhyqDbXTBzt45dk=";
|
2021-01-09 10:05:03 +00:00
|
|
|
};
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
|
|
|
strictDeps = true;
|
2021-01-09 10:05:03 +00:00
|
|
|
buildInputs = [
|
|
|
|
python3
|
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
2021-01-09 10:05:03 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
2022-02-10 20:34:41 +00:00
|
|
|
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
|
|
|
|
'';
|
2021-01-09 10:05:03 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
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
|
2021-01-09 10:05:03 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
substituteInPlace "$out/bin/ec2-metadata" \
|
|
|
|
--replace 'curl' '${curl}/bin/curl'
|
2021-01-09 10:05:03 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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; {
|
|
|
|
homepage = "https://github.com/aws/amazon-ec2-utils";
|
|
|
|
description = "Contains a set of utilities and settings for Linux deployments in EC2";
|
|
|
|
license = licenses.mit;
|
2022-02-10 20:34:41 +00:00
|
|
|
maintainers = with maintainers; [ ketzacoatl thefloweringash ];
|
2021-01-09 10:05:03 +00:00
|
|
|
};
|
|
|
|
}
|