3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/os-specific/linux/libbpf/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

55 lines
1.5 KiB
Nix

{ lib, stdenv, fetchFromGitHub, pkgconfig
, libelf, zlib
, fetchpatch
}:
with builtins;
stdenv.mkDerivation rec {
pname = "libbpf";
version = "0.1.1";
src = fetchFromGitHub {
owner = "libbpf";
repo = "libbpf";
rev = "v${version}";
sha256 = "0ilnnm4q22f8fagwp8kb37licy4ks861i2iqh2djsypqhnxvx3fv";
};
patches = [
(fetchpatch { # included upstream for > 0.1.0
name = "link-zlib.patch";
url = "https://github.com/libbpf/libbpf/commit/8b14cb43ff837.diff";
sha256 = "17mvjrs7s727drz013a8qlyj0345ldi2kph6pazcmxv6kl1qrz2z";
})
];
patchFlags = "-p2";
# https://github.com/libbpf/libbpf/pull/201#issuecomment-689174740
postPatch = ''
substituteInPlace ../scripts/check-reallocarray.sh \
--replace 'mktemp /tmp/' 'mktemp ' \
--replace '/bin/rm' 'rm'
'';
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ libelf zlib ];
sourceRoot = "source/src";
enableParallelBuilding = true;
makeFlags = [ "PREFIX=$(out)" ];
# FIXME: Multi-output requires some fixes to the way the pkgconfig file is
# constructed (it gets put in $out instead of $dev for some reason, with
# improper paths embedded). Don't enable it for now.
# outputs = [ "out" "dev" ];
meta = with lib; {
description = "Upstream mirror of libbpf";
homepage = "https://github.com/libbpf/libbpf";
license = with licenses; [ lgpl21 /* or */ bsd2 ];
maintainers = with maintainers; [ thoughtpolice vcunat ];
platforms = platforms.linux;
};
}