Packaging an existing texlive package

I want to update a texlive package. The package is already in nix packages but not upto date. So in home manager i added the updated package by using the texlive.combine function and included the package by pulling it directly from github source. Now after building the derivation when i do kpsewhich package.sty it seems to be using the old package. That means I am not overriding it properly .

 {pkgs,fetchFromGitHub,...}:
pkgs.stdenvNoCC.mkDerivation rec{
  name = "stex";
  src = fetchFromGitHub {
    owner = "slatex";
    repo = "sTeX";
    rev = "stex4";
    sha256 = "ZPAplgopAdEnPzguFDA2qSrpMgmTcxvxY8ciT8GCvjQ=";
  };
  sourceRoot = "${src.name}/tex";
  installPhase = "cp -r $src $out";
  passthru.tlType = "run";
}

This above code is imported in home-manager derivation. then my home-manager looks something like this

some code here .....
let pkgs-unstable = import <nixpkgs-unstable> {};
stex = pkgs.callPackage ./modules/stex {}; 
in 
{
..........
home.packages = [
  (pkgs-unstable.texlive.combine {
      inherit (pkgs-unstable.texlive) scheme-full;
      stex = {pkgs = [stex];};
    })
];
............
}; 

so this is the code i am using the stex package should be overriden in the scheme-full
but its not working my texlive has the old stex.sty files

I stumbled upon this when trying to get a new version of erewhon-math to work.
Instead of creating my own derivation, I wanted to override the package in pkgs.texlive.pkgs as is/has been common with python environments.
Unfortunately, it is not as straightforward with texlive packages.
Each derivation in pkgs.texlive.pgs appears to depend on sub-derivations that provide certain functionality (“tex”, “doc”, “bin”, …), the outputs of which are symlinked into an appropriate folder structure.
For erewhon-math I only need the tex functionality, and I have this somewhere:

tlpkgs = pkgs.texlive.pkgs;
erewhon-math = tlpkgs.erewhon-math.overrideAttrs (prevAttrs : {
  version = "0.72";
  revision = "r76878";
  outputDrvs = prevAttrs.outputDrvs // {
    tex = prevAttrs.outputDrvs.tex.overrideAttrs {
      name = "erewhon-math-0.72-tex";
      src = pkgs.fetchurl {
        url = "https://ftp.rrze.uni-erlangen.de/ctan/systems/texlive/tlnet/archive/erewhon-math.r76878.tar.xz";
        hash = "sha256-To56Y2Q66H8z9OTkq8HrWPgHRXfrybRC7aepIZjc2Ig=";
      };
      outputHash = "sha256-us8/Lx9LbcSFbj1Oe/bSKQuYCIxfuyKSOZuxwBef/+E=";
    };
  };
});

The version is from ctan, the revision from looking at the files at the archive url.
Now I can use my erewhon-math derivation as a list entry to texliveFull.withPackages.
I am not sure about how to obtain the hashes elegantly; I simply built my config repeatedly and copied the printed hashes into the config file.

Another example, not changing src this time, but wrapping executable to see missing library:

latexdiff = tlpkgs.latexdiff.overrideAttrs (prevAttrs: {
  outputDrvs = prevAttrs.outputDrvs // {
    out = prevAttrs.outputDrvs.out.overrideAttrs (prevOut: {
      nativeBuildInputs = (prevOut.nativeBuildInputs or []) ++ [ pkgs.makeWrapper ];
      buildInputs = (prevOut.buildInputs or []) ++ (with pkgs.perlPackages; [
        EncodeLocale
      ]);
      buildCommand = (prevOut.buildCommand or "") + ''
        wrapProgram $out/bin/latexdiff --prefix PERL5LIB : "$PERL5LIB"
      '';
    });
  };
})