diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix index fe248a94488b..bd7077ff7ea1 100644 --- a/nixos/modules/virtualisation/amazon-image.nix +++ b/nixos/modules/virtualisation/amazon-image.nix @@ -155,7 +155,7 @@ in systemd.services."serial-getty@ttyS0".enable = true; # Creates symlinks for block device names. - services.udev.packages = [ pkgs.ec2-utils ]; + services.udev.packages = [ pkgs.amazon-ec2-utils ]; # Force getting the hostname from EC2. networking.hostName = mkDefault ""; diff --git a/pkgs/tools/admin/amazon-ec2-utils/default.nix b/pkgs/tools/admin/amazon-ec2-utils/default.nix index 2dc91f037a98..f6e92bd5287e 100644 --- a/pkgs/tools/admin/amazon-ec2-utils/default.nix +++ b/pkgs/tools/admin/amazon-ec2-utils/default.nix @@ -2,36 +2,55 @@ , lib , fetchFromGitHub , curl +, gawk , python3 +, installShellFiles }: stdenv.mkDerivation rec { pname = "amazon-ec2-utils"; - version = "1.3"; + version = "2.0"; src = fetchFromGitHub { owner = "aws"; repo = "amazon-ec2-utils"; - rev = version; - hash = "sha256:04dpxaaca144a74r6d93q4lp0d5l32v07rldj7v2v1c6s9nsf4mv"; + rev = "v${version}"; + hash = "sha256-u1rHBV8uVcCywvQNYagtDleYB12tmhyqDbXTBzt45dk="; }; + outputs = [ "out" "man" ]; + + strictDeps = true; buildInputs = [ python3 ]; - - propagatedBuildInputs = [ - curl + nativeBuildInputs = [ + installShellFiles ]; installPhase = '' - mkdir -p $out/bin/ + 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 - cp ebsnvme-id $out/bin/ - cp ec2-metadata $out/bin/ - cp ec2udev-vbd $out/bin/ - cp ec2udev-vcpu $out/bin/ + 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 - chmod +x $out/bin/* + 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; @@ -48,6 +67,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/aws/amazon-ec2-utils"; description = "Contains a set of utilities and settings for Linux deployments in EC2"; license = licenses.mit; - maintainers = with maintainers; [ ketzacoatl ]; + maintainers = with maintainers; [ ketzacoatl thefloweringash ]; }; } diff --git a/pkgs/tools/virtualization/ec2-utils/default.nix b/pkgs/tools/virtualization/ec2-utils/default.nix deleted file mode 100644 index 283219108424..000000000000 --- a/pkgs/tools/virtualization/ec2-utils/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ stdenv, lib, rpmextract, fetchurl, python2, tree }: - -stdenv.mkDerivation { - pname = "ec2-utils"; - version = "0.5.1"; - - # The url can be determined by booting an "Amazon Linux 2" and running: - # > yumdownloader --urls ec2-utils - src = fetchurl { - url = "http://amazonlinux.ap-northeast-1.amazonaws.com/blobstore/a3b4d2c35c2300518fe10381a05b3bd7936ff5cdd3d351143a11bf84073d9e00/ec2-utils-0.5-1.amzn2.0.1.noarch.rpm"; - sha256 = "004y7l3q9gqi78a53lykrpsnz4yp7dds1083w67m2013bk1x5d53"; - }; - - nativeBuildInputs = [ rpmextract ]; - - buildInputs = [ python2 ]; - - unpackPhase = '' - mkdir source - cd source - rpmextract "$src" - ''; - - installPhase = '' - mkdir $out - - mv --target-directory $out \ - etc sbin usr/bin usr/lib - ''; - - postFixup = '' - for i in $out/etc/udev/rules.d/*.rules; do - substituteInPlace "$i" \ - --replace '/sbin' "$out/bin" - done - - substituteInPlace "$out/etc/udev/rules.d/70-ec2-nvme-devices.rules" \ - --replace 'ec2nvme-nsid' "$out/lib/udev/ec2nvme-nsid" - ''; - - meta = { - description = "A set of tools for running in EC2"; - homepage = "https://aws.amazon.com/amazon-linux-ami/"; - license = lib.licenses.asl20; - maintainers = with lib.maintainers; [ thefloweringash ]; - }; -} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index d5dd54b48f11..4b26a470b0ee 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -233,6 +233,7 @@ mapAliases ({ dwarf_fortress = dwarf-fortress; # added 2016-01-23 dwm-git = throw "dwm-git has been removed from nixpkgs, as it had no updates for 2 years not serving it's purpose."; # added 2021-02-07 dylibbundler = macdylibbundler; # added 2021-04-24 + ec2-utils = amazon-ec2-utils; # added 2022-02-01 ec2_ami_tools = ec2-ami-tools; # added 2021-10-08 ec2_api_tools = ec2-api-tools; # added 2021-10-08 elasticmq = throw "elasticmq has been removed in favour of elasticmq-server-bin"; # added 2021-01-17 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fa59ea17a58f..a64b7eb07d20 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1513,8 +1513,6 @@ with pkgs; buildGoModule = buildGo117Module; }; - ec2-utils = callPackage ../tools/virtualization/ec2-utils { }; - exoscale-cli = callPackage ../tools/admin/exoscale-cli { }; altermime = callPackage ../tools/networking/altermime {};