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.clangStdenv; }'
22 ./0001-Remove-unused-function-after_eq.patch
23
24 # Fix build for s390-linux, where size_t is different from ptrdiff_t.
25 (fetchurl {
26 url = "https://lore.kernel.org/keyrings/20230301134250.301819-1-hi@alyssa.is/raw";
27 sha256 = "1cbgwxq28fw5ldh38ngcs7xiqvpnmrw0hw9zzhbhb1hdxkavrc1s";
28 })
29 ];
30
31 makeFlags = lib.optionals stdenv.hostPlatform.isStatic "NO_SOLIB=1";
32
33 outputs = [ "out" "lib" "dev" "man" ];
34
35 postPatch = ''
36 # https://github.com/archlinux/svntogit-packages/blob/packages/keyutils/trunk/reproducible.patch
37 substituteInPlace Makefile \
38 --replace \
39 'VCPPFLAGS := -DPKGBUILD="\"$(shell date -u +%F)\""' \
40 'VCPPFLAGS := -DPKGBUILD="\"$(date -ud "@$SOURCE_DATE_EPOCH" +%F)\""'
41 '';
42
43 enableParallelBuilding = true;
44
45 installFlags = [
46 "ETCDIR=$(out)/etc"
47 "BINDIR=$(out)/bin"
48 "SBINDIR=$(out)/sbin"
49 "SHAREDIR=$(out)/share/keyutils"
50 "MANDIR=$(out)/share/man"
51 "INCLUDEDIR=$(dev)/include"
52 "LIBDIR=$(lib)/lib"
53 "USRLIBDIR=$(lib)/lib"
54 ];
55
56 meta = with lib; {
57 homepage = "https://people.redhat.com/dhowells/keyutils/";
58 description = "Tools used to control the Linux kernel key management system";
59 license = licenses.gpl2Plus;
60 platforms = platforms.linux;
61 };
62}