nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 makeWrapper,
6 perlPackages,
7}:
8
9let
10 version = "2.06";
11in
12stdenv.mkDerivation {
13 pname = "cloc";
14 inherit version;
15
16 src = fetchFromGitHub {
17 owner = "AlDanial";
18 repo = "cloc";
19 rev = "v${version}";
20 sha256 = "sha256-u/qIkoN8xFA/aggjbSfVHbhUvRo6fWqcJWSMO/Q0hQo=";
21 };
22
23 setSourceRoot = ''
24 sourceRoot=$(echo */Unix)
25 '';
26
27 nativeBuildInputs = [ makeWrapper ];
28 buildInputs = with perlPackages; [
29 perl
30 AlgorithmDiff
31 ParallelForkManager
32 RegexpCommon
33 ];
34
35 makeFlags = [
36 "prefix="
37 "DESTDIR=$(out)"
38 "INSTALL=install"
39 ];
40
41 postFixup = "wrapProgram $out/bin/cloc --prefix PERL5LIB : $PERL5LIB";
42
43 doInstallCheck = true;
44 installCheckPhase = ''
45 runHook preInstallCheck
46
47 echo -n 'checking --version...'
48 $out/bin/cloc --version | grep '${version}' > /dev/null
49 echo ' ok'
50
51 cat > test.nix <<EOF
52 {a, b}: {
53 test = a
54 + b;
55 }
56 EOF
57
58 echo -n 'checking lines in test.nix...'
59 $out/bin/cloc --quiet --csv test.nix | grep '1,Nix,0,0,4' > /dev/null
60 echo ' ok'
61
62 runHook postInstallCheck
63 '';
64
65 meta = {
66 description = "Program that counts lines of source code";
67 homepage = "https://github.com/AlDanial/cloc";
68 license = lib.licenses.gpl2Plus;
69 platforms = lib.platforms.all;
70 maintainers = with lib.maintainers; [ rycee ];
71 mainProgram = "cloc";
72 };
73}