"Global"/Extra Options

a way of passing additional options "globally" to modules is by using extraOpts.

in nix flakes, this is accomplished by using specialArgs in nixosSystem.

for example, check out these few lines in our flake.nix: [source]

# note: unrelated attributes stripped and removed.
# note2: this code is now out of date from our code, but can still be referenced.
{
  outputs = { ... }:{
    nixosConfigurations = {
      koumakan = lib.nixosSystem {
        specialArgs = {
          _utils = (import ./global/utils.nix) { inherit pkgs; };

          someOtherArg = {thisCanBe = "LiterallyAnything";};
        };
      };
    };
  };
}

With this, you can now do this in other imported nixos modules.

{ someOtherArg, ... }: {
  users.users.${someOtherArg} = {};
}

this avoids the horror of import ../../../utils/bar.nix; and various other things.

refer to nixpkgs:nixos/lib/eval-config.nix and nixpkgs:lib/modules.nix#122 for more info

pointers by @natsukagami