Skip to content

Commit 418f69e

Browse files
authored
amazon-ec2-utils: wrap programs (NixOS#355259)
2 parents 42de2bc + d87f62c commit 418f69e

File tree

1 file changed

+59
-32
lines changed

1 file changed

+59
-32
lines changed
Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
2-
stdenv,
32
lib,
43
bash,
4+
coreutils,
55
curl,
66
fetchFromGitHub,
77
gawk,
8+
gnugrep,
9+
gnused,
810
installShellFiles,
11+
makeWrapper,
12+
nix-update-script,
913
python3,
14+
stdenv,
15+
util-linux,
1016
}:
1117

1218
stdenv.mkDerivation rec {
@@ -20,67 +26,88 @@ stdenv.mkDerivation rec {
2026
hash = "sha256-plTBh2LAXkYVSxN0IZJQuPr7QxD7+OAqHl/Zl8JPCmg=";
2127
};
2228

23-
outputs = [
24-
"out"
25-
"man"
26-
];
27-
2829
strictDeps = true;
2930

3031
nativeBuildInputs = [
3132
installShellFiles
33+
makeWrapper
3234
];
3335

3436
buildInputs = [
3537
bash
3638
python3
3739
];
3840

39-
postInstall = ''
40-
install -Dm755 -t $out/bin/ ebsnvme-id
41-
install -Dm755 -t $out/bin/ ec2-metadata
42-
install -Dm755 -t $out/bin/ ec2nvme-nsid
43-
install -Dm755 -t $out/bin/ ec2udev-vbd
41+
installPhase = ''
42+
mkdir $out
4443
45-
install -Dm644 -t $out/lib/udev/rules.d/ 51-ec2-hvm-devices.rules
46-
install -Dm644 -t $out/lib/udev/rules.d/ 51-ec2-xen-vbd-devices.rules
47-
install -Dm644 -t $out/lib/udev/rules.d/ 53-ec2-read-ahead-kb.rules
48-
install -Dm644 -t $out/lib/udev/rules.d/ 70-ec2-nvme-devices.rules
49-
install -Dm644 -t $out/lib/udev/rules.d/ 60-cdrom_id.rules
44+
for file in {ebsnvme-id,ec2-metadata,ec2nvme-nsid,ec2udev-vbd}; do
45+
install -D -m 755 -t $out/bin "$file"
46+
done
5047
51-
installManPage doc/*.8
52-
'';
48+
wrapProgram $out/bin/ec2-metadata \
49+
--prefix PATH : ${
50+
lib.makeBinPath [
51+
coreutils
52+
curl
53+
util-linux
54+
]
55+
}
56+
57+
wrapProgram $out/bin/ec2nvme-nsid \
58+
--prefix PATH : ${
59+
lib.makeBinPath [
60+
coreutils
61+
]
62+
}
63+
64+
wrapProgram $out/bin/ec2udev-vbd \
65+
--prefix PATH : ${
66+
lib.makeBinPath [
67+
coreutils
68+
gnugrep
69+
gnused
70+
]
71+
}
72+
73+
for file in *.rules; do
74+
install -D -m 644 -t $out/lib/udev/rules.d "$file"
75+
done
5376
54-
postFixup = ''
5577
substituteInPlace $out/lib/udev/rules.d/{51-ec2-hvm-devices,70-ec2-nvme-devices}.rules \
56-
--replace-fail '/usr/sbin' "$out/bin"
78+
--replace-fail /usr/sbin $out/bin
5779
5880
substituteInPlace $out/lib/udev/rules.d/53-ec2-read-ahead-kb.rules \
59-
--replace-fail '/bin/awk' '${gawk}/bin/awk'
81+
--replace-fail /bin/awk ${gawk}/bin/awk
6082
61-
substituteInPlace "$out/bin/ec2-metadata" \
62-
--replace-fail 'curl' '${curl}/bin/curl'
83+
installManPage doc/*.8
6384
'';
6485

86+
outputs = [
87+
"out"
88+
"man"
89+
];
90+
6591
doInstallCheck = true;
6692

67-
# We cannot run
68-
# ec2-metadata --help
69-
# because it actually checks EC2 metadata even if --help is given
70-
# so it won't work in the test sandbox.
93+
# We can't run `ec2-metadata` since it calls IMDS even with `--help`.
7194
installCheckPhase = ''
7295
$out/bin/ebsnvme-id --help
7396
'';
7497

75-
meta = with lib; {
76-
changelog = "https://github.com/amazonlinux/amazon-ec2-utils/releases/tag/v${version}";
98+
passthru = {
99+
updateScript = nix-update-script { };
100+
};
101+
102+
meta = {
77103
description = "Contains a set of utilities and settings for Linux deployments in EC2";
78104
homepage = "https://github.com/amazonlinux/amazon-ec2-utils";
79-
license = licenses.mit;
80-
maintainers = with maintainers; [
105+
license = lib.licenses.mit;
106+
maintainers = with lib.maintainers; [
107+
anthonyroussel
108+
arianvp
81109
ketzacoatl
82110
thefloweringash
83-
anthonyroussel
84111
];
85112
};
86113
}

0 commit comments

Comments
 (0)