nixpkgs/pkgs/by-name/cs/csmith/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

52 lines
1.8 KiB
Nix

{ lib, stdenv, fetchurl, m4, makeWrapper, libbsd, perlPackages }:
stdenv.mkDerivation rec {
pname = "csmith";
version = "2.3.0";
src = fetchurl {
url = "https://embed.cs.utah.edu/csmith/${pname}-${version}.tar.gz";
sha256 = "1mb5zgixsyf86slggs756k8a5ddmj980md3ic9sa1y75xl5cqizj";
};
nativeBuildInputs = [ m4 makeWrapper ];
buildInputs = [ libbsd ] ++ (with perlPackages; [ perl SysCPU ]);
CXXFLAGS = "-std=c++98";
postInstall = ''
substituteInPlace $out/bin/compiler_test.pl \
--replace '$CSMITH_HOME/runtime' $out/include/${pname}-${version} \
--replace ' ''${CSMITH_HOME}/runtime' " $out/include/${pname}-${version}" \
--replace '$CSMITH_HOME/src/csmith' $out/bin/csmith
substituteInPlace $out/bin/launchn.pl \
--replace '../compiler_test.pl' $out/bin/compiler_test.pl \
--replace '../$CONFIG_FILE' '$CONFIG_FILE'
wrapProgram $out/bin/launchn.pl \
--prefix PERL5LIB : "$PERL5LIB"
mkdir -p $out/share/csmith
mv $out/bin/compiler_test.in $out/share/csmith/
'';
enableParallelBuilding = true;
meta = with lib; {
description = "Random generator of C programs";
homepage = "https://embed.cs.utah.edu/csmith";
# Officially, the license is this: https://github.com/csmith-project/csmith/blob/master/COPYING
license = licenses.bsd2;
longDescription = ''
Csmith is a tool that can generate random C programs that statically and
dynamically conform to the C99 standard. It is useful for stress-testing
compilers, static analyzers, and other tools that process C code.
Csmith has found bugs in every tool that it has tested, and has been used
to find and report more than 400 previously unknown compiler bugs.
'';
maintainers = [ ];
platforms = platforms.all;
};
}