Help creating flake package for custom latex packages

Hey so i have a repo with some custom packages i use in latex in .sty that i want to organize in a flake to add it to my configuration.

with what i read so far i could muster up this flake file:

{
  description = "My LaTeX Packages for TeX Live";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        myLatexPackages = pkgs.stdenvNoCC.mkDerivation {
          name = "myLatexPackages";
          src = ./.;
          installPhase = ''
            mkdir -p $out/tex/latex/myLatexPackages
            cp -r packages/* $out/tex/latex/myLatexPackages/
          '';
        };
      in {
        packages = {
          inherit myLatexPackages;
          default = myLatexPackages;
        };
      });
}

trying to add to my configuration inside

pkgs.texlive.combine {
  inherit (inputs.myLatexPackages.packages.${pkgs.system}) myLatexPackages
}

im getting the following erro:

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'home-manager-generation'
         whose name attribute is located at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/trivial-builders/default.nix:59:17:
           58|         enableParallelBuilding = true;
           59|         inherit buildCommand name;
             |                 ^
           60|         passAsFile = [ "buildCommand" ]

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'activation-script'
         whose name attribute is located at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'text' of derivation 'activation-script'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/trivial-builders/default.nix:102:17:
          101|       ({
          102|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                 ^
          103|         passAsFile = [ "text" ]

       … while calling the 'concatStringsSep' builtin
         at /nix/store/cx1ca0rhmn6wwb93cpln8f9143bjs1wn-source/modules/home-environment.nix:682:13:
          681|           if sortedCommands ? result then
          682|             concatStringsSep "\n" (map mkCmd sortedCommands.result)
             |             ^
          683|           else

       … while calling 'mkCmd'
         at /nix/store/cx1ca0rhmn6wwb93cpln8f9143bjs1wn-source/modules/home-environment.nix:675:17:
          674|       let
          675|         mkCmd = res: ''
             |                 ^
          676|             _iNote "Activating %s" "${res.name}"

       … while evaluating the attribute 'data'
         at /nix/store/cx1ca0rhmn6wwb93cpln8f9143bjs1wn-source/modules/lib/dag.nix:89:43:
           88|     in if sorted ? result then {
           89|       result = map (v: { inherit (v) name data; }) sorted.result;
             |                                           ^
           90|     } else

       … while evaluating the attribute 'data'
         at /nix/store/cx1ca0rhmn6wwb93cpln8f9143bjs1wn-source/modules/lib/dag.nix:83:9:
           82|         name = n;
           83|         data = v.data;
             |         ^
           84|         after = v.after ++ dagBefore dag n;

       … from call site
         at /nix/store/cx1ca0rhmn6wwb93cpln8f9143bjs1wn-source/modules/lib/dag.nix:83:16:
           82|         name = n;
           83|         data = v.data;
             |                ^
           84|         after = v.after ++ dagBefore dag n;

       … while calling anonymous lambda
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/attrsets.nix:1204:18:
         1203|         mapAttrs
         1204|           (name: value:
             |                  ^
         1205|             if isAttrs value && cond value

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/attrsets.nix:1207:18:
         1206|             then recurse (path ++ [ name ]) value
         1207|             else f (path ++ [ name ]) value);
             |                  ^
         1208|     in

       … while calling anonymous lambda
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:256:72:
          255|           # For definitions that have an associated option
          256|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          257|

       … while evaluating the attribute 'value'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:927:9:
          926|     in warnDeprecation opt //
          927|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          928|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `home.activation.installPackages.data':

       … while evaluating the attribute 'mergedValue'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:962:5:
          961|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          962|     mergedValue =
             |     ^
          963|       if isDefined then

       … while evaluating a branch condition
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:963:7:
          962|     mergedValue =
          963|       if isDefined then
             |       ^
          964|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal

       … while evaluating the attribute 'values'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:956:9:
          955|       in {
          956|         values = defs''';
             |         ^
          957|         inherit (defs'') highestPrio;

       … while evaluating a branch condition
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:952:11:
          951|           # Avoid sorting if we don't have to.
          952|           if any (def: def.value._type or "" == "order") defs''.values
             |           ^
          953|           then sortProperties defs''.values

       … while calling the 'any' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:952:14:
          951|           # Avoid sorting if we don't have to.
          952|           if any (def: def.value._type or "" == "order") defs''.values
             |              ^
          953|           then sortProperties defs''.values

       … while evaluating the attribute 'values'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:1079:7:
         1078|     in {
         1079|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
         1080|       inherit highestPrio;

       … while calling the 'concatMap' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:1079:16:
         1078|     in {
         1079|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |                ^
         1080|       inherit highestPrio;

       … while calling the 'concatMap' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:942:17:
          941|         # Process mkMerge and mkIf properties.
          942|         defs' = concatMap (m:
             |                 ^
          943|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while calling anonymous lambda
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:942:28:
          941|         # Process mkMerge and mkIf properties.
          942|         defs' = concatMap (m:
             |                            ^
          943|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while calling the 'map' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:943:11:
          942|         defs' = concatMap (m:
          943|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |           ^
          944|         ) defs;

       … while evaluating definitions from `/nix/store/cx1ca0rhmn6wwb93cpln8f9143bjs1wn-source/modules/home-environment.nix':

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:943:128:
          942|         defs' = concatMap (m:
          943|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                ^
          944|         ) defs;

       … while calling 'dischargeProperties'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:1030:25:
         1029|   */
         1030|   dischargeProperties = def:
             |                         ^
         1031|     if def._type or "" == "merge" then

       … while evaluating a branch condition
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:1031:5:
         1030|   dischargeProperties = def:
         1031|     if def._type or "" == "merge" then
             |     ^
         1032|       concatMap dischargeProperties def.contents

       … while evaluating the attribute 'value'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/modules.nix:665:53:
          664|                 (n: value:
          665|                   [{ inherit (module) file; inherit value; }]
             |                                                     ^
          666|                 )

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'home-manager-path'
         whose name attribute is located at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'passAsFile' of derivation 'home-manager-path'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/trivial-builders/default.nix:60:9:
           59|         inherit buildCommand name;
           60|         passAsFile = [ "buildCommand" ]
             |         ^
           61|           ++ (derivationArgs.passAsFile or [ ]);

       … while evaluating the attribute 'passAsFile'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:113:9:
          112|         # XXX: The size is somewhat arbitrary
          113|         passAsFile = if builtins.stringLength pkgs >= 128 * 1024 then [ "pkgs" ] else [ ];
             |         ^
          114|       }

       … while evaluating a branch condition
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:113:22:
          112|         # XXX: The size is somewhat arbitrary
          113|         passAsFile = if builtins.stringLength pkgs >= 128 * 1024 then [ "pkgs" ] else [ ];
             |                      ^
          114|       }

       … in the argument of the not operator
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:113:52:
          112|         # XXX: The size is somewhat arbitrary
          113|         passAsFile = if builtins.stringLength pkgs >= 128 * 1024 then [ "pkgs" ] else [ ];
             |                                                    ^
          114|       }

       … while calling the 'lessThan' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:113:52:
          112|         # XXX: The size is somewhat arbitrary
          113|         passAsFile = if builtins.stringLength pkgs >= 128 * 1024 then [ "pkgs" ] else [ ];
             |                                                    ^
          114|       }

       … while calling the 'stringLength' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:113:25:
          112|         # XXX: The size is somewhat arbitrary
          113|         passAsFile = if builtins.stringLength pkgs >= 128 * 1024 then [ "pkgs" ] else [ ];
             |                         ^
          114|       }

       … while calling the 'toJSON' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:108:16:
          107|           ;
          108|         pkgs = builtins.toJSON chosenOutputs;
             |                ^
          109|         extraPathsFrom = lib.optional includeClosures (writeClosure pathsForClosure);

       … while evaluating list element at index 6

       … while evaluating attribute 'paths'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:68:7:
           67|     chosenOutputs = map (drv: {
           68|       paths =
             |       ^
           69|         # First add the usual output(s): respect if user has chosen explicitly,

       … while evaluating list element at index 0
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/build-support/buildenv/default.nix:68:7:
           67|     chosenOutputs = map (drv: {
           68|       paths =
             |       ^
           69|         # First add the usual output(s): respect if user has chosen explicitly,

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'texlive-combined-2024'
         whose name attribute is located at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'buildInputs' of derivation 'texlive-combined-2024'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:422:7:
          421|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          422|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          423|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … while calling the 'elemAt' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:422:37:
          421|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          422|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |                                     ^
          423|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … while calling the 'map' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:351:8:
          350|       (map (drv: getDev drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost))
          351|       (map (drv: getDev drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs'))
             |        ^
          352|     ]

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:351:59:
          350|       (map (drv: getDev drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost))
          351|       (map (drv: getDev drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs'))
             |                                                           ^
          352|     ]

       … while calling 'checkDependencyList''
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:318:43:
          317|   checkDependencyList = checkDependencyList' [];
          318|   checkDependencyList' = positions: name: deps:
             |                                           ^
          319|     imap1

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/stdenv/generic/make-derivation.nix:319:5:
          318|   checkDependencyList' = positions: name: deps:
          319|     imap1
             |     ^
          320|       (index: dep:

       … while calling 'imap1'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/lists.nix:335:14:
          334|   */
          335|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |              ^
          336|

       … while calling the 'genList' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/lists.nix:335:20:
          334|   */
          335|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |                    ^
          336|

       … while evaluating the second argument passed to builtins.genList

       … while calling the 'length' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/lists.nix:335:60:
          334|   */
          335|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |                                                            ^
          336|

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix:454:14:
          453|           gnused
          454|         ] ++ lib.optional needsGhostscript ghostscript;
             |              ^
          455|

       … while calling 'optional'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/lists.nix:785:20:
          784|   */
          785|   optional = cond: elem: if cond then [elem] else [];
             |                    ^
          786|

       … while evaluating a branch condition
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/lib/lists.nix:785:26:
          784|   */
          785|   optional = cond: elem: if cond then [elem] else [];
             |                          ^
          786|

       … while calling the 'any' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix:200:24:
          199|     # and ignoring luatex, perl, and shell scripts (those must be patched using postFixup)
          200|     needsGhostscript = lib.any (
             |                        ^
          201|       p:

       … while evaluating the attribute 'bin'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix:132:7:
          131|       # split binary and tlpkg from tex, texdoc, texsource
          132|       bin =
             |       ^
          133|         if __fromCombineWrapper then

       … while calling the 'filter' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix:134:11:
          133|         if __fromCombineWrapper then
          134|           builtins.filter (p: p.tlType == "bin") all # texlive.combine: legacy filter
             |           ^
          135|         else

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/build-tex-env.nix:98:11:
           97|         if __fromCombineWrapper then
           98|           requiredTeXPackages null
             |           ^
           99|         else

       … while calling 'requiredTeXPackages'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:75:25:
           74|   __extraVersion = extraVersion;
           75|   requiredTeXPackages = _: converted;
             |                         ^
           76|   __combine = true;

       … while calling the 'map' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:70:15:
           69|   all = lib.filter pkgFilter combined ++ lib.filter (pkg: pkg.tlType == "tlpkg") combined;
           70|   converted = builtins.map toSpecified all;
             |               ^
           71| in

       … while calling the 'filter' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:69:9:
           68|     };
           69|   all = lib.filter pkgFilter combined ++ lib.filter (pkg: pkg.tlType == "tlpkg") combined;
             |         ^
           70|   converted = builtins.map toSpecified all;

       … from call site
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:52:14:
           51|     );
           52|   combined = combinePkgs (lib.attrValues pkgSet);
             |              ^
           53|

       … while calling 'combinePkgs'
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:25:5:
           24|   combinePkgs =
           25|     pkgList:
             |     ^
           26|     lib.catAttrs "pkg" (

       … while calling the 'catAttrs' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:26:5:
           25|     pkgList:
           26|     lib.catAttrs "pkg" (
             |     ^
           27|       let

       … while calling the 'genericClosure' builtin
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/combine-wrapper.nix:47:7:
           46|       in
           47|       builtins.genericClosure {
             |       ^
           48|         startSet = pkgListToSets pkgList;

       … in the left operand of the update (//) operator
         at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/default.nix:123:21:
          122|       lib.optional (tlType != null) (drv // { inherit tlType; })
          123|     else [ (drv.tex // { tlType = "run"; }) ] ++
             |                     ^
          124|       lib.optional (drv ? texdoc) (drv.texdoc // { tlType = "doc"; } // lib.optionalAttrs (drv ? man) { hasManpages = true; }) ++

       error: attribute 'tex' missing
       at /nix/store/593xvgv994xlkm5mb7w4p1xxnzrs9wv6-source/pkgs/tools/typesetting/tex/texlive/default.nix:123:13:
          122|       lib.optional (tlType != null) (drv // { inherit tlType; })
          123|     else [ (drv.tex // { tlType = "run"; }) ] ++
             |             ^
          124|       lib.optional (drv ? texdoc) (drv.texdoc // { tlType = "doc"; } // lib.optionalAttrs (drv ? man) { hasManpages = true; }) ++

I figured out, here is the flake:

{
  description = "My LaTeX Packages for TeX Live";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        myLatexPackages = pkgs.stdenv.mkDerivation {
          name = "myLatexPackages";
          src = ./packages;
          installPhase = ''
              mkdir -p $out/tex/latex
              cp -r $src/**/*.{sty,cls} $out/tex/latex
              '';
          passthru.tlType = "run";
        };
      in {
        defaultPackage = myLatexPackages;
        packages = {
          inherit myLatexPackages;
          default = myLatexPackages;
        };
      });
}

use on config like this:

config = let
    myLatexPackage = {
      pkgs = [inputs.myLatexPackages.packages.${pkgs.system}.default];
    };
    tex = pkgs.texlive.combine {
      inherit myLatexPackage;
#...
1 Like