1{ lib, stdenv, fetchurl }:
2
3# Note: this package is used for bootstrapping fetchurl, and thus
4# cannot use fetchpatch! All mutable patches (generated by GitHub or
5# cgit) that are needed here should be included directly in Nixpkgs as
6# files.
7
8stdenv.mkDerivation rec {
9 pname = "keyutils";
10 version = "1.6.3";
11
12 src = fetchurl {
13 url = "https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/snapshot/${pname}-${version}.tar.gz";
14 sha256 = "sha256-ph1XBhNq5MBb1I+GGGvP29iN2L1RB+Phlckkz8Gzm7Q=";
15 };
16
17 patches = [
18 ./conf-symlink.patch
19 # This patch solves a duplicate symbol error when building with a clang stdenv
20 # Before removing this patch, please ensure the package still builds by running eg.
21 # nix-build -E 'with import ./. {}; pkgs.keyutils.override { stdenv = pkgs.llvmPackages_latest.stdenv; }'
22 ./0001-Remove-unused-function-after_eq.patch
23 ];
24
25 makeFlags = lib.optionals stdenv.hostPlatform.isStatic "NO_SOLIB=1";
26
27 outputs = [ "out" "lib" "dev" ];
28
29 postPatch = ''
30 # https://github.com/archlinux/svntogit-packages/blob/packages/keyutils/trunk/reproducible.patch
31 substituteInPlace Makefile \
32 --replace \
33 'VCPPFLAGS := -DPKGBUILD="\"$(shell date -u +%F)\""' \
34 'VCPPFLAGS := -DPKGBUILD="\"$(date -ud "@$SOURCE_DATE_EPOCH" +%F)\""'
35 '';
36
37 enableParallelBuilding = true;
38
39 installFlags = [
40 "ETCDIR=$(out)/etc"
41 "BINDIR=$(out)/bin"
42 "SBINDIR=$(out)/sbin"
43 "SHAREDIR=$(out)/share/keyutils"
44 "MANDIR=$(out)/share/man"
45 "INCLUDEDIR=$(dev)/include"
46 "LIBDIR=$(lib)/lib"
47 "USRLIBDIR=$(lib)/lib"
48 ];
49
50 meta = with lib; {
51 homepage = "https://people.redhat.com/dhowells/keyutils/";
52 description = "Tools used to control the Linux kernel key management system";
53 license = licenses.gpl2Plus;
54 platforms = platforms.linux;
55 };
56}