From 8ed8c0fb66330c1ff55749d8edb3fcae8379de57 Mon Sep 17 00:00:00 2001 From: commiterate <111539270+commiterate@users.noreply.github.com> Date: Sun, 10 Nov 2024 21:15:34 -0500 Subject: [PATCH] amazon-ec2-net-utils: init at 2.5.1 --- .../am/amazon-ec2-net-utils/package.nix | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 pkgs/by-name/am/amazon-ec2-net-utils/package.nix diff --git a/pkgs/by-name/am/amazon-ec2-net-utils/package.nix b/pkgs/by-name/am/amazon-ec2-net-utils/package.nix new file mode 100644 index 0000000000000..328813698e346 --- /dev/null +++ b/pkgs/by-name/am/amazon-ec2-net-utils/package.nix @@ -0,0 +1,115 @@ +{ + lib, + bash, + coreutils, + curl, + fetchFromGitHub, + gnugrep, + gnused, + installShellFiles, + iproute2, + makeWrapper, + nix-update-script, + stdenv, + systemd, +}: + +stdenv.mkDerivation rec { + pname = "amazon-ec2-net-utils"; + version = "2.5.1"; + + src = fetchFromGitHub { + owner = "amazonlinux"; + repo = "amazon-ec2-net-utils"; + rev = "refs/tags/v${version}"; + hash = "sha256-Nmrhu3j3JZA7GeJsLwOfdFKfyPYl1vFiH5Zr372eAXk="; + }; + + strictDeps = true; + + nativeBuildInputs = [ + installShellFiles + makeWrapper + ]; + + buildInputs = [ + bash + ]; + + outputs = [ + "out" + "man" + ]; + + # See https://github.com/amazonlinux/amazon-ec2-net-utils/blob/v2.5.1/GNUmakefile#L26-L37. + installPhase = '' + mkdir $out + + for file in bin/*.sh; do + install -D -m 755 "$file" $out/bin/$(basename --suffix ".sh" "$file") + substituteInPlace $out/bin/$(basename --suffix ".sh" "$file") \ + --replace-fail AMAZON_EC2_NET_UTILS_LIBDIR $out/share/amazon-ec2-net-utils + done + + substituteInPlace $out/bin/setup-policy-routes \ + --replace-fail /lib/systemd ${systemd}/lib/systemd + + wrapProgram $out/bin/setup-policy-routes \ + --prefix PATH : ${ + lib.makeBinPath [ + coreutils + # bin/setup-policy-roots.sh sources lib/lib.sh which needs these. + # + # lib/lib.sh isn't executable so we can't use it with wrapProgram. + curl + gnugrep + gnused + iproute2 + systemd + ] + } + + for file in lib/*.sh; do + install -D -m 644 -t $out/share/amazon-ec2-net-utils "$file" + done + + substituteInPlace $out/share/amazon-ec2-net-utils/lib.sh \ + --replace-fail /usr/lib/systemd $out/lib/systemd + + for file in udev/*.rules; do + install -D -m 644 -t $out/lib/udev/rules.d "$file" + done + + substituteInPlace $out/lib/udev/rules.d/99-vpc-policy-routes.rules \ + --replace-fail /usr/bin/systemctl ${systemd}/bin/systemctl + + for file in systemd/network/*.network; do + install -D -m 644 -t $out/lib/systemd/network "$file" + done + + for file in systemd/system/*.{service,timer}; do + install -D -m 644 -t $out/lib/systemd/system "$file" + done + + substituteInPlace $out/lib/systemd/system/policy-routes@.service \ + --replace-fail /usr/bin/setup-policy-routes $out/bin/setup-policy-routes + + substituteInPlace $out/lib/systemd/system/refresh-policy-routes@.service \ + --replace-fail /usr/bin/setup-policy-routes $out/bin/setup-policy-routes + + installManPage doc/*.8 + ''; + + passthru = { + updateScript = nix-update-script { }; + }; + + meta = { + description = "Contains a set of utilities for managing elastic network interfaces on Amazon EC2"; + homepage = "https://github.com/amazonlinux/amazon-ec2-net-utils"; + license = lib.licenses.asl20; + platforms = lib.platforms.linux; + # TODO: Find maintainer(s). + maintainers = with lib.maintainers; [ ]; + }; +}