{
  lib,
  stdenv,
  fetchurl,
  gettext,
}:

# Note: this package is used for bootstrapping fetchurl, and thus
# cannot use fetchpatch! All mutable patches (generated by GitHub or
# cgit) that are needed here should be included directly in Nixpkgs as
# files.

stdenv.mkDerivation (finalAttrs: {
  pname = "attr";
  version = "2.6.0";

  src = fetchurl {
    url = "mirror://savannah/attr/attr-${finalAttrs.version}.tar.gz";
    hash = "sha256-1C+jdFExgLtIyxGkZpb0iCQOUST/HmrYiwq/9waYVhI=";
  };

  outputs = [
    "bin"
    "dev"
    "out"
    "man"
    "doc"
  ];

  nativeBuildInputs = [ gettext ];

  strictDeps = true;

  postPatch = ''
    for script in install-sh include/install-sh; do
      patchShebangs $script
    done
  '';

  # See nixos/tests/attr.nix
  doCheck = false;

  __structuredAttrs = true;

  meta = {
    homepage = "https://savannah.nongnu.org/projects/attr/";
    description = "Library and tools for manipulating extended attributes";
    platforms = lib.platforms.linux;
    badPlatforms = lib.platforms.microblaze;
    license = lib.licenses.gpl2Plus;
    teams = [ lib.teams.security-review ];
    identifiers.cpeParts = lib.meta.cpeFullVersionWithVendor "attr_project" finalAttrs.version;
  };
})
