nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 makeWrapper,
7 llvm,
8 libclang,
9 flex,
10 zlib,
11 perlPackages,
12 util-linux,
13}:
14
15stdenv.mkDerivation {
16 pname = "creduce";
17 version = "2.10.0-unstable-2024-06-01";
18
19 src = fetchFromGitHub {
20 owner = "csmith-project";
21 repo = "creduce";
22 rev = "31e855e290970cba0286e5032971509c0e7c0a80";
23 hash = "sha256-RbxFqZegsCxnUaIIA5OfTzx1wflCPeF+enQt90VwMgA=";
24 };
25
26 postPatch = ''
27 substituteInPlace {clex,clang_delta,delta,unifdef,creduce,.}/CMakeLists.txt --replace-fail \
28 "cmake_minimum_required(VERSION 2.8.12)" "cmake_minimum_required(VERSION 3.10)"
29 ''
30 +
31 # On Linux, c-reduce's preferred way to reason about
32 # the cpu architecture/topology is to use 'lscpu',
33 # so let's make sure it knows where to find it:
34 lib.optionalString stdenv.hostPlatform.isLinux ''
35 substituteInPlace creduce/creduce_utils.pm --replace-fail \
36 lscpu ${util-linux}/bin/lscpu
37 '';
38
39 nativeBuildInputs = [
40 cmake
41 makeWrapper
42 llvm.dev
43 ];
44 buildInputs = [
45 # Ensure stdenv's CC is on PATH before clang-unwrapped
46 stdenv.cc
47 # Actual deps:
48 llvm
49 libclang
50 flex
51 zlib
52 ]
53 ++ (with perlPackages; [
54 perl
55 ExporterLite
56 FileWhich
57 GetoptTabular
58 RegexpCommon
59 TermReadKey
60 ]);
61
62 postInstall = ''
63 wrapProgram $out/bin/creduce --prefix PERL5LIB : "$PERL5LIB"
64 '';
65
66 meta = {
67 description = "C program reducer";
68 mainProgram = "creduce";
69 homepage = "https://embed.cs.utah.edu/creduce";
70 # Officially, the license is: https://github.com/csmith-project/creduce/blob/master/COPYING
71 license = lib.licenses.ncsa;
72 longDescription = ''
73 C-Reduce is a tool that takes a large C or C++ program that has a
74 property of interest (such as triggering a compiler bug) and
75 automatically produces a much smaller C/C++ program that has the same
76 property. It is intended for use by people who discover and report
77 bugs in compilers and other tools that process C/C++ code.
78 '';
79 maintainers = [ ];
80 platforms = lib.platforms.all;
81 };
82}