How to create a package for markuplint?

Hi I’m new to nixpkgs. I’m trying to create a package for markuplint. So far I’ve done the following but I get errors.

{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchYarnDeps,
  yarnConfigHook,
  yarnBuildHook,
  yarnInstallHook,
  nodejs,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "markuplint";
  version = "4.12.0";

  src = fetchFromGitHub {
    owner = "markuplint";
    repo = "markuplint";
    rev = "v${finalAttrs.version}";
    hash = "sha256-3yU3H5a4h9sUpE/YMeY9DDtmM/jJ/yKGlr5KvMg0fLE=";
  };

  yarnOfflineCache = fetchYarnDeps {
    yarnLock = finalAttrs.src + "/yarn.lock";
    hash = "sha256-uoCrxxUGcOvBJJ/otU1yytdSLDFn5xVe+t7L05SL9Vc=";
  };

  nativeBuildInputs = [
    yarnConfigHook
    yarnBuildHook
    yarnInstallHook
    # Needed for executing package.json scripts
    nodejs
  ];

  meta = {
    description = "Static code analysis tool for HTML";
    homepage = "https://markuplint.dev";
    license = lib.licenses.mit;
    mainProgram = "markuplint";
    maintainers = [ ];
  };
})

error log

       last 25 log lines:
       >     at NpmResolver.<anonymous> (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:50440:15)
       >     at Generator.next (<anonymous>)
       >     at step (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:310:30)
       >     at /nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:321:13
       > Error: Couldn't find any versions for "@markuplint/shared" that matches "4.4.10" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
       >     at MessageError.ExtendableBuiltin (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:721:66)
       >     at new MessageError (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:750:123)
       >     at NpmResolver.<anonymous> (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:50440:15)
       >     at Generator.next (<anonymous>)
       >     at step (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:310:30)
       >     at /nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:321:13
       > Error: Couldn't find any versions for "@markuplint/types" that matches "4.7.5" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
       >     at MessageError.ExtendableBuiltin (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:721:66)
       >     at new MessageError (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:750:123)
       >     at NpmResolver.<anonymous> (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:50440:15)
       >     at Generator.next (<anonymous>)
       >     at step (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:310:30)
       >     at /nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:321:13
       > Error: Couldn't find any versions for "@markuplint/cli-utils" that matches "4.4.10" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
       >     at MessageError.ExtendableBuiltin (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:721:66)
       >     at new MessageError (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:750:123)
       >     at NpmResolver.<anonymous> (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:50440:15)
       >     at Generator.next (<anonymous>)
       >     at step (/nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:310:30)
       >     at /nix/store/bn868hy4v171i58jx25bls555jspbhl9-yarn-1.22.22/libexec/yarn/lib/cli.js:321:13
       For full logs, run 'nix log /nix/store/qrx5q1202k4japsqja8xb4nrh0zrypvy-markuplint-4.12.0.drv'.
1 Like
  1. download the file https://registry.npmjs.org/markuplint/-/markuplint-4.12.0.tgz
  2. extract archive
  3. run npm i --package-lock-only --ignore-scripts
  4. get resulting package-lock.json
{
  lib,
  fetchurl,
  buildNpmPackage,
}:

buildNpmPackage (finalAttrs: {
  pname = "markuplint";
  version = "4.12.0";

  src = fetchurl {
    url = "https://registry.npmjs.org/markuplint/-/markuplint-${finalAttrs.version}.tgz";
    hash = "sha256-mt6qjKf5GoybYTkAduXNbuPxzpbzwyOiLoH0QJh/tyo=";
  };
  npmDepsHash = "sha256-1w7WlVoDtE4rMrVWHs7gNAv2BwdNGYLd/hV7z8wPyyE=";

  postPatch = ''
    ln -s ${./package-lock.json} package-lock.json
  '';

  dontNpmBuild = true;

  meta = {
    description = "Static code analysis tool for HTML";
    homepage = "https://markuplint.dev";
    license = lib.licenses.mit;
    mainProgram = "markuplint";
    maintainers = [ ];
  };
})