Importing sub-dir flake.nix within root flake.nix

Hi,

I have been inspired since watching vimjoyer video about packaging scripts within

root flake.nix

{
  description = "Testing writers for nix";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    gomod2nix = {
      url = "github:nix-community/gomod2nix";
      inputs = {
        flake-utils.follows = "flake-utils";
        nixpkgs.follows = "nixpkgs";
      };
    };
    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
  };

  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
      gomod2nix,
      pre-commit-hooks,
      ...
    }@inputs:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config.allowUnfree = true;
        };
        g-update = import ./g-update/flake.nix;
      in
      {

        packages = {
          output1 = pkgs.writeScriptBin "myscript" ''
            echo foo
          '';
          output2 = pkgs.writeScriptBin "myscript2" ''
            chmod 777 myscript.sh
            ./myscript.sh;
          '';
          # nix run/build '.#output3'
          output3 = pkgs.writeScriptBin "myscript3" ''
            export PATH=${pkgs.lib.makeBinPath [ pkgs.hello ]}:$PATH
            chmod 777 run-hello.sh
            ${./run-hello.sh}
          '';
          output4 = g-update.outputs {
            inherit self;
            inherit nixpkgs;
            inherit flake-utils;
            inherit gomod2nix;
            inherit pre-commit-hooks;
            # derive = "a"; ??
          };
        };
      }
    );
}

the g-update/flake.nix

{
  description = "A basic gomod2nix flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    gomod2nix = {
      url = "github:nix-community/gomod2nix";
      inputs = {
        flake-utils.follows = "flake-utils";
        nixpkgs.follows = "nixpkgs";
      };
    };
    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
  };

  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
      gomod2nix,
      pre-commit-hooks,
    }@inputs:
    (flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        # The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
        # This has no effect on other platforms.
        callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
      in
      {
        packages.default = callPackage ./. {
          inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
        };
        devShells.default = callPackage ./shell.nix {
          inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
          inherit pre-commit-hooks;
        };
      }
    ));
}

When running I get the following error

❯ nix run ".#output4"
warning: Git tree '/home/henri/Documents/houseVandersleyen/nixScripts' is dirty
error: attribute 'packages.x86_64-linux.output4.type' does not exist

The main.go isn’t important, but the source code can be found here and was inspired by this discussion

Any help is appreciated

I am just calling the defaul.nix of the sub folder directly and that solves it