at 23.05-pre 73 lines 2.0 kB view raw
1{ fetchurl, lib, stdenv, perl, makeWrapper }: 2 3stdenv.mkDerivation rec { 4 pname = "sloccount"; 5 version = "2.26"; 6 7 src = fetchurl { 8 url = "https://www.dwheeler.com/${pname}/${pname}-${version}.tar.gz"; 9 sha256 = "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"; 10 }; 11 12 nativeBuildInputs = [ makeWrapper ]; 13 buildInputs = [ perl ]; 14 15 # Make sure the Flex-generated files are newer than the `.l' files, so that 16 # Flex isn't needed to recompile them. 17 patchPhase = '' 18 for file in * 19 do 20 if grep -q /usr/bin/perl "$file" 21 then 22 echo "patching \`$file'..." 23 substituteInPlace "$file" --replace \ 24 "/usr/bin/perl" "${perl}/bin/perl" 25 fi 26 done 27 28 for file in *.l 29 do 30 touch "$(echo $file | sed -es'/\.l$/.c/g')" 31 done 32 ''; 33 34 makeFlags = [ "PREFIX=$(out)" "CC=${stdenv.cc.targetPrefix}cc" ]; 35 36 doCheck = true; 37 checkPhase = ''HOME="$TMPDIR" PATH="$PWD:$PATH" make test''; 38 39 preInstall = '' 40 mkdir -p "$out/bin" 41 mkdir -p "$out/share/man/man1" 42 mkdir -p "$out/share/doc" 43 ''; 44 45 postInstall = '' 46 for w in "$out/bin"/*; do 47 isScript "$w" || continue 48 wrapProgram "$w" --prefix PATH : "$out/bin" 49 done 50 ''; 51 52 meta = { 53 description = "Set of tools for counting physical Source Lines of Code (SLOC)"; 54 55 longDescription = '' 56 This is the home page of "SLOCCount", a set of tools for 57 counting physical Source Lines of Code (SLOC) in a large number 58 of languages of a potentially large set of programs. This suite 59 of tools was used in my papers More than a Gigabuck: Estimating 60 GNU/Linux's Size and Estimating Linux's Size to measure the SLOC 61 of entire GNU/Linux distributions, and my essay Linux Kernel 62 2.6: It's Worth More! Others have measured Debian GNU/Linux and 63 the Perl CPAN library using this tool suite. 64 ''; 65 66 license = lib.licenses.gpl2Plus; 67 68 homepage = "https://www.dwheeler.com/sloccount/"; 69 70 maintainers = [ ]; 71 platforms = lib.platforms.all; 72 }; 73}