From a5ca97028ff9af0249b59b3a2f217ce0dd81844a Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Fri, 23 Aug 2019 21:12:15 +0900 Subject: [PATCH 1/2] ec2-utils: init at 0.5.1 --- .../virtualization/ec2-utils/default.nix | 47 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 49 insertions(+) create mode 100644 pkgs/tools/virtualization/ec2-utils/default.nix diff --git a/pkgs/tools/virtualization/ec2-utils/default.nix b/pkgs/tools/virtualization/ec2-utils/default.nix new file mode 100644 index 000000000000..ea088b486fc6 --- /dev/null +++ b/pkgs/tools/virtualization/ec2-utils/default.nix @@ -0,0 +1,47 @@ +{ stdenv, lib, rpmextract, fetchurl, python2, tree }: + +stdenv.mkDerivation { + name = "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.apsl20; + maintainers = with lib.maintainers; [ thefloweringash ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c4498ce8b134..f84d2e09234c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -689,6 +689,8 @@ in ec2_ami_tools = callPackage ../tools/virtualization/ec2-ami-tools { }; + ec2-utils = callPackage ../tools/virtualization/ec2-utils { }; + altermime = callPackage ../tools/networking/altermime {}; alttab = callPackage ../tools/X11/alttab { }; From 4c446b82682249e23a0141d27fa035e6ae8c515a Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Fri, 23 Aug 2019 21:12:33 +0900 Subject: [PATCH 2/2] amazon-image: include ec2-utils in udev rules This sets up device mappings like /dev/xvda -> /dev/nvme0n1 --- nixos/modules/virtualisation/amazon-image.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix index 0c4ad90b4eb6..ba4fcbaf7de7 100644 --- a/nixos/modules/virtualisation/amazon-image.nix +++ b/nixos/modules/virtualisation/amazon-image.nix @@ -125,6 +125,9 @@ in services.openssh.enable = true; services.openssh.permitRootLogin = "prohibit-password"; + # Creates symlinks for block device names. + services.udev.packages = [ pkgs.ec2-utils ]; + # Force getting the hostname from EC2. networking.hostName = mkDefault "";