Unverified Commit ec69ac12 authored by dish's avatar dish Committed by GitHub
Browse files

sloc: repackage using buildNpmPackage (#466101)

parents fbe583b8 7de00d15
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
{
  lib,
  buildNpmPackage,
  fetchFromGitHub,
  fetchurl,
  testers,
  nix-update-script,
}:

buildNpmPackage (finalAttrs: {
  pname = "sloc";
  version = "0.3.2";

  src = fetchFromGitHub {
    owner = "flosse";
    repo = "sloc";
    rev = "v${finalAttrs.version}";
    hash = "sha256-YDrJn/NSXa1LcFK1bxVQF5Qp/Ru38JTszZUMBiK3PPI=";
  };

  npmDepsHash = "sha256-cFUWwmsYy75qAfhkY6tc4Hxwjo8WJcC5urQC22UnnVU=";

  postPatch =
    let
      lockfile = fetchurl {
        url = "https://raw.githubusercontent.com/flosse/sloc/e26044011821c4e170859362f2de657d64118711/package-lock.json";
        hash = "sha256-yWVErql5SWOSbbw2DZUlXBJp7zqZngkc8uAC5ZfnjX0=";
      };
    in
    ''
      if [ -e ./package-lock.json ]; then
        echo "Remove postPatch!"
        exit 1
      else
        cp ${lockfile} ./package-lock.json
      fi
    '';

  npmBuildScript = "prepublish";

  doCheck = true;

  checkPhase = ''
    runHook preCheck

    npm test

    runHook postCheck
  '';

  passthru = {
    tests = {
      wrapped = testers.testVersion {
        package = finalAttrs.finalPackage;
      };
    };
    updateScript = nix-update-script { };
  };

  meta = {
    description = "Simple tool to count SLOC (source lines of code)";
    homepage = "https://github.com/flosse/sloc";
    changelog = "https://github.com/flosse/sloc/blob/${finalAttrs.src.rev}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ tomodachi94 ];
    mainProgram = "sloc";
    platforms = lib.platforms.all;
  };
})
+1 −0
Original line number Diff line number Diff line
@@ -303,6 +303,7 @@ mapAliases {
  inherit (pkgs) serve; # added 2025-08-27
  inherit (pkgs) serverless; # Added 2023-11-29
  shout = throw "shout was removed because it was deprecated upstream in favor of thelounge."; # Added 2024-10-19
  inherit (pkgs) sloc; # Added 2025-11-28
  smartdc = throw "'smartdc' was removed because it was unmaintained upstream"; # Added 2025-11-14
  inherit (pkgs) snyk; # Added 2023-08-30
  "socket.io" = throw "socket.io was removed because it provides no executable"; # added 2025-03-23
+0 −1
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
, "purs-tidy"
, "sass"
, "semver"
, "sloc"
, "vega-cli"
, "vercel"
, "wavedrom-cli"
+0 −26
Original line number Diff line number Diff line
@@ -22834,32 +22834,6 @@ in
    bypassCache = true;
    reconstructLock = true;
  };
  sloc = nodeEnv.buildNodePackage {
    name = "sloc";
    packageName = "sloc";
    version = "0.3.2";
    src = fetchurl {
      url = "https://registry.npmjs.org/sloc/-/sloc-0.3.2.tgz";
      sha512 = "tnB+gi6TiFpt3qmCGfaV+78dfKwLiH5HRohkW+PnJYHNAcEdk408uxWG+F/3pu4w1eyCO2NC5CpZKuiyMac5GQ==";
    };
    dependencies = [
      sources."async-3.2.6"
      sources."cli-table-0.3.11"
      sources."colors-1.0.3"
      sources."commander-11.1.0"
      sources."picomatch-2.3.1"
      sources."readdirp-3.6.0"
    ];
    buildInputs = globalBuildInputs;
    meta = {
      description = "sloc is a simple tool to count SLOC (source lines of code)";
      homepage = "https://github.com/flosse/sloc#readme";
      license = "MIT";
    };
    production = true;
    bypassCache = true;
    reconstructLock = true;
  };
  vega-cli = nodeEnv.buildNodePackage {
    name = "vega-cli";
    packageName = "vega-cli";
+0 −2
Original line number Diff line number Diff line
@@ -6712,8 +6712,6 @@ with pkgs;
  # pandoc takes long to build and documentation isn't needed for just running the cli
  shellcheck-minimal = haskell.lib.compose.justStaticExecutables shellcheck.unwrapped;

  sloc = nodePackages.sloc;

  speedtest-cli = with python3Packages; toPythonApplication speedtest-cli;

  splint = callPackage ../development/tools/analysis/splint {