nixpkgs/pkgs/by-name/cl/cloc/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

62 lines
1.4 KiB
Nix

{ lib, stdenv, fetchFromGitHub, makeWrapper, perlPackages }:
let version = "2.02";
in stdenv.mkDerivation {
pname = "cloc";
inherit version;
src = fetchFromGitHub {
owner = "AlDanial";
repo = "cloc";
rev = "v${version}";
sha256 = "sha256-qTrBCCC2J8Ewt6GvYlnXU8F1iB31A1xTFXdkee8L0Os=";
};
setSourceRoot = ''
sourceRoot=$(echo */Unix)
'';
nativeBuildInputs = [ makeWrapper ];
buildInputs = with perlPackages; [
perl
AlgorithmDiff
ParallelForkManager
RegexpCommon
];
makeFlags = [ "prefix=" "DESTDIR=$(out)" "INSTALL=install" ];
postFixup = "wrapProgram $out/bin/cloc --prefix PERL5LIB : $PERL5LIB";
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
echo -n 'checking --version...'
$out/bin/cloc --version | grep '${version}' > /dev/null
echo ' ok'
cat > test.nix <<EOF
{a, b}: {
test = a
+ b;
}
EOF
echo -n 'checking lines in test.nix...'
$out/bin/cloc --quiet --csv test.nix | grep '1,Nix,0,0,4' > /dev/null
echo ' ok'
runHook postInstallCheck
'';
meta = {
description = "Program that counts lines of source code";
homepage = "https://github.com/AlDanial/cloc";
license = lib.licenses.gpl2Plus;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ rycee ];
mainProgram = "cloc";
};
}