I’m trying to package gitlab-lsp for Nixpkgs.
However, it’s becoming a nightmare due to importNpmLock config hook fails because "cache mode is 'only-if-cached' but no cached response is available" · Issue #408720 · NixOS/nixpkgs · GitHub.
I have not a lot of nodejs experience… I just want that binary in my NixOS. Up until now I have this:
{
buildNpmPackage,
fetchFromGitLab,
lib,
nix-update-script,
nodejs_22,
patch-package,
}:
buildNpmPackage (finalAttrs: {
pname = "gitlab-lsp";
version = "8.45.0";
# DOCS https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp#node-version
nodejs = nodejs_22;
src = fetchFromGitLab {
owner = "gitlab-org";
repo = "editor-extensions/gitlab-lsp";
rev = "v${finalAttrs.version}";
sha256 = "sha256-r6mw9L4NJEsHZWXzu19XscI0RitpRvdJykKd3OCSzb8=";
};
npmInstallFlags = [ "--omit=dev" ];
npmDepsHash = "sha256-uEscdAe/bBvneVye3690wy2grQr+RZnedBr20HmTfnQ=";
nativeBuildInputs = [patch-package];
passthru.updateScript = nix-update-script {
extraArgs = [ "--generate-lockfile" ];
};
meta = {
description = "GitLab Language Server";
homepage = "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ yajo ];
};
})
It fails with:
npm error code ENOTCACHED
npm error request to https://registry.npmjs.org/yocto-queue failed: cache mode is 'only-if-cached' but no cached response is available.
npm error Log files were not written due to an error writing to the directory: /nix/store/whbndfwypyzp8c48nxc1w66hqx3abgpd-gitlab-lsp-8.45.0-npm-deps/_logs
npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
ERROR: npm failed to install dependencies
Here are a few things you can try, depending on the error:
1. Set `makeCacheWritable = true`
Note that this won't help if npm is complaining about not being able to write to the logs directory -- look above that for the actual error.
2. Set `npmFlags = [ "--legacy-peer-deps" ]`
I’ve tried every possible combination of npmFlags, dontNpmBuild, dontNpmInstall, npmDeps, importNpmLock, npmDeps, fetchNpmDeps and npmConfigHook with no luck.
Indeed, it seems that some dependencies are missing their hashes.
Could somebody give me some help on this please? How to fix that? ![]()
Couldn’t we have some kind of helper that adds those missing hashes somewhere?
I asked for help upstream too.
Thank you!