Previous package build / derivation still seems to be in cache

I created a custom/local/own package for vscode.js.debug.

{pkgs ? import <nixpkgs> {}}: let
  l10n = pkgs.fetchurl {
    url = "https://github.com/microsoft/vscode-loc/archive/main.zip";
    hash = "sha256-WuPXRjuNGfYjwqAUjqru8cX+NPxq/q2ppKePpvRjScs=";
  };
in
  pkgs.buildNpmPackage rec {
    pname = "vscode-js-debug";
    version = "1.92.0";

    buildInputs = [
      pkgs.nodejs_20
    ];

    src = pkgs.fetchFromGitHub {
      owner = "microsoft";
      repo = "vscode-js-debug";
      rev = "v${version}";
      sha256 = "1sqz5azj87mpjxr8v187z64853dcyhakqwf30pzzb1aryrnr1cxj";
    };

    npmDepsHash = "sha256-h7qTwl0bYYBVRg3Rh14oafarnCnOp1TUmwVq9M+evjg=";
    npmFlags = ["--legacy-peer-deps" "--ignore-scripts"];
    makeCacheWritable = true;

    postPatch = ''
      substituteInPlace gulpfile.js --replace-fail \
      "await got('https://github.com/microsoft/vscode-loc/archive/main.zip', opts).buffer();" \
      "fs.readFileSync('${l10n}');"
    '';

    buildPhase = ''
      npx gulp vsDebugServerBundle
    '';

    installPhase = ''
      mkdir -p $out/out/src
      cp -r dist/src/* $out/out/src/
    '';

    meta = with pkgs.lib; {
      description = "A DAP-based JavaScript debugger";
      homepage = "https://github.com/microsoft/vscode-js-debug";
      license = licenses.mit;
      maintainers = with maintainers; [ancientITguy];
      platforms = platforms.all;
    };
  }

I built it once with version 1.91.0 but in a version/shape I did not want to have. Then I built it in version 1.92.0 based on the definition above.

After a garbage collection and nix-build I see only 1.92.0 in nix store:

ls -d /nix/store/*vscode-js-debug*
/nix/store/csrzqx0286lf1g74ws296pqrd4kzbm4h-vscode-js-debug-1.92.0      /nix/store/qmpsjyax4v51r9xk464z100h10mslm6r-vscode-js-debug-1.92.0-npm-deps.drv
/nix/store/kf5x02gcnvd46barg8ykicrcnfkd0syk-vscode-js-debug-1.92.0.drv

However when referencing in my configuration or pulling it this nix-shell, I get 1.91.0:

$ nix-shell -p vscode-js-debug
this path will be fetched (8.76 MiB download, 43.65 MiB unpacked):
  /nix/store/wfh1zdd9xbfmskp3bpjhrfw37l8a2cz9-vscode-js-debug-1.91.0
copying path '/nix/store/wfh1zdd9xbfmskp3bpjhrfw37l8a2cz9-vscode-js-debug-1.91.0' from 'https://cache.nixos.org'...

I am aware that I am still lacking basic understanding of NixOS cache / store concepts. Can someone please help me to understand, where this old version is coming from or how I can remove it or make my latest version the one that is used?

This command will pull the package from nixpkgs, so the outdated version comes from the upstream package. It probably doesn’t show up on search.nixos.org because it’s an alias, but it does exist: nixpkgs/pkgs/by-name/vs/vscode-js-debug/package.nix at 9e2335ac963ae6863194f516b57b01febd499e84 · NixOS/nixpkgs · GitHub

To use your own package, you’ll need to actually refer to it with nix-shell. The -p flag will use an attribute from the nixpkgs on your NIX_PATH, not a local file with a similar name.

You could do that with the -E flag instead of -p, but I’d suggest just renaming your file to default.nix and running nix-shell without arguments, or using a proper shell.nix.

1 Like

I see, thank you @TLATER. That makes sense.
OK, that particular version does not work with NeoVim DAP adapter mxsdev/nvim-dap-vscode-js - which had been (before all the Yak Shaving) my initial problem.
Hence I will rename my local package as it is specific anyways.