How to use locally built packages as dependency for further local package

I’ve written the following flake.nix file:

{
  description = "Just a C++ project";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
  };

  outputs = {
    self, nixpkgs
    }: let
      system = "x86_64-linux";
    in {
      defaultPackage.${system} = 
        with import nixpkgs {inherit system;};
        stdenv.mkDerivation {
          name = "dummy-project";
          version = "v1.0.0";
          src = ./.;

          nativeBuildInputs = [ cmake ];

          buildInputs = [
            dummy-dependency        # this causes me a headache
            gtest
            ];
        };
    };
}

As you can see, this flake has a dependency on dummy-dependency. Since dummy-dependency is a company internal dependency, I can’t make it public through git or even publish it to the nixpkgs directory so it is built locally from a locally cloned repository (I know, not ideal, but it’s a first step in testing this package manager without too much work).

The dummy-dependency repository has a default.nix file writte by me, which looks like this:

with import <nixpkgs> {};
stdenv.mkDerivation {
  pname = "dummy-dependency"
  version = "1.0.0";
  src = ./.;

  system = "x86_64-linux";

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [ 
    boost
    gtest
    ];
}

This package has been built using nix build and it seems like the files have landed correctly in the /nix/store/ directory.

$ find /nix/store/ -type d -name "*dummy-dependency*" -print
/nix/store/l52xdhnbh7l1pd9vzlavwjp9kw7db16h-dummy-dependency
/nix/store/pyfba247zhs377plyy2kkd1vxvc1xsj0-dummy-dependency
/nix/store/6vvd6v3kiascqcb58zb1xch2vk00ians-dummy-dependency

Although building the initially mentioned flake (first field), throws the following error:

error: undefined variable 'dummy-dependency'

How does one build and install packages locally without having to upload / make them public, and at the same time be able to import them as dependencies for further projects?

Welcome to reproducibility city
Where the lambda is blue and questions are tricky.

Flakes has a path syntax for absolute path. Maybe you can use it as your input,

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
    dumbdep.url = "./../two-live-crew_me-so-dummy";
    dumbdep.flake = false; # because there no flake.nix in your dependency
  };

While this is correct answer to your question about no uploading/make it public.
I think what you should be looking for is private git authorization, because local paths to other dependencies may only work in your machine. Also take a look in substituter - unfortunate name to any ssh/s3/http server - where you can share your builds between machine (like cache.nixos.org but privately).

Once you have the input, you have to change your outputs:

  outputs = { self, nixpkgs, dumbdep }:
     #... too lazy to type
         buildInputs = [
           (callPackage dumbdep {}) # callPackage because is not a flake
           # or dumbdep.packages."${system}".default # if it was a flake.
           gtest
         ];

Note: your flake template is outdated, defaultPackage.system is now packages.system.default