nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 libintl,
7 texinfo,
8 buildPackages,
9 pkgsStatic,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "indent";
14 version = "2.2.13";
15
16 src = fetchurl {
17 url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz";
18 hash = "sha256-nmRjT8TOZ5eyBLy4iXzhT90KtIyldpb3h2fFnK5XgJU=";
19 };
20
21 patches = [
22 (fetchpatch {
23 name = "CVE-2023-40305.part-1.patch";
24 url = "https://git.savannah.gnu.org/cgit/indent.git/patch/?id=df4ab2d19e247d059e0025789ba513418073ab6f";
25 hash = "sha256-OLXBlYTdEuFK8SIsyC5Xr/hHWlvXiRqY2h79w+H5pGk=";
26 })
27 (fetchpatch {
28 name = "CVE-2023-40305.part-2.patch";
29 url = "https://git.savannah.gnu.org/cgit/indent.git/patch/?id=2685cc0bef0200733b634932ea7399b6cf91b6d7";
30 hash = "sha256-t+QF7N1aqQ28J2O8esZ2bc5K042cUuZR4MeMeuWIgPw=";
31 })
32 ];
33
34 # avoid https://savannah.gnu.org/bugs/?64751
35 postPatch = ''
36 sed -E -i '/output\/else-comment-2-br(-ce)?.c/d' regression/TEST
37 sed -E -i 's/else-comment-2-br(-ce)?.c//g' regression/TEST
38 '';
39
40 makeFlags = [ "AR=${stdenv.cc.targetPrefix}ar" ];
41
42 strictDeps = true;
43 nativeBuildInputs = [ texinfo ];
44 buildInputs = [ libintl ];
45 depsBuildBuild = [ buildPackages.stdenv.cc ]; # needed when cross-compiling
46
47 env.NIX_CFLAGS_COMPILE = toString (
48 lib.optional stdenv.cc.isClang "-Wno-implicit-function-declaration"
49 ++ lib.optional (
50 stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc) "13"
51 ) "-Wno-unused-but-set-variable"
52 );
53
54 hardeningDisable = [ "format" ];
55
56 doCheck = true;
57
58 passthru.tests.static = pkgsStatic.indent;
59 meta = {
60 homepage = "https://www.gnu.org/software/indent/";
61 description = "Source code reformatter";
62 mainProgram = "indent";
63 license = lib.licenses.gpl3Plus;
64 maintainers = [ lib.maintainers.mmahut ];
65 platforms = lib.platforms.unix;
66 };
67}