anchor.diff:  , passthru ? {}
   , doCheck ? false
   
  -# appended to the luarocks generated config
  -# in peculiar variables like { EVENT_INCDIR } can be useful to work around
  -# luarocks limitations, ie, luarocks consider include/lib folders to be subfolders of the same package in external_deps_dirs
  -# as explained in https://github.com/luarocks/luarocks/issues/766
  +# Non-Lua / system (e.g. C library) dependencies. Is a list of deps, where
  +# each dep is either a derivation, or an attribute set like
  +# { name = "rockspec external_dependencies key"; dep = derivation; }
  +# The latter is used to work-around luarocks having a problem with
  +# multiple-output derivations as external deps:
  +# https://github.com/luarocks/luarocks/issues/766<Paste>
  +, externalDeps ? lib.unique (lib.filter (drv: !drv ? luaModule) (propagatedBuildInputs ++ buildInputs))
  +
  +# Appended to the generated luarocks config
   , extraConfig ? ""
  +# Inserted into the generated luarocks config in the "variables" table
  +, extraVariables ? ""
  +# The two above arguments have access to builder variables -- e.g. to $out
   
   # relative to srcRoot, path to the rockspec to use when using rocks
   , rockspecFilename ?  "../*.rockspec"
  
positive.code: 
  
  # Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
  if disabled
  then throw "${name} not supported for interpreter ${lua}"
  else
  
  let
  
    deps_dirs= lib.concatStringsSep ", " (
      map (x: "\"${builtins.toString x}\"") external_deps
    );
  
    # TODO
    # - add rocktrees (look at torch-distro.nix/https://github.com/luarocks/luarocks/wiki/Config-file-format)
    # - silence warnings
    luarocks_config = "luarocksConfig";
    luarocks_content = ''
      local_cache = ""
      -- array of strings
      external_deps_dirs = {
      ${deps_dirs}
      }
      rocks_trees = {
      }
      ${extraConfig}
    '';
  in
  toLuaModule ( lua.stdenv.mkDerivation (
  builtins.removeAttrs attrs ["disabled" "checkInputs"] // {
  
    name = namePrefix + name;
  
    buildInputs = [ wrapLua lua.pkgs.luarocks ]
      ++ buildInputs
      ++ lib.optionals doCheck checkInputs
      ;
  
    # propagate lua to active setup-hook in nix-shell
    propagatedBuildInputs = propagatedBuildInputs ++ [ lua ];
    doCheck = false;
  
    # enabled only for src.rock
    setSourceRoot= let
  
negative.code: , propagatedNativeBuildInputs ? []
  
  # used to disable derivation, useful for specific lua versions
  # TODO move from this setting meta.broken to a 'disabled' attribute on the
  # package, then use that to skip/include in each lua${ver}Packages set?
  , disabled ? false
  
  # Additional arguments to pass to the makeWrapper function, which wraps
  # generated binaries.
  , makeWrapperArgs ? []
  
  # Skip wrapping of lua programs altogether
  , dontWrapLuaPrograms ? false
  