same.work.yaml file is used to define a workspace in a monorepo setup. It allows you to group multiple projects together and share common tools.
Purpose
In a monorepo, you often have multiple projects (e.g., a backend service, a frontend app, a shared library) that need to be built together or have inter-dependencies. The workspace configuration:- Discovers Projects: Tells
samewhere to find the projects within the repository using glob patterns. - Shares Tools: Defines a common set of tools (e.g., a specific Go version, Node.js version) that can be used by all projects in the workspace.
Schema
version
The version of the configuration schema. Currently, the only supported version is “1”.
projects
A list of glob patterns to locate project directories. Any directory matching these patterns that contains a
same.yaml file will be included in the workspace.Example: ["packages/*", "services/*"]tools
A map of tool aliases to their Nix package specifications. These tools are available to all projects in the workspace.
Tool Inheritance & Overrides
Tools defined insame.work.yaml are automatically available to all projects. However, projects can override these tools or define their own additions.
- Inheritance: If a tool is defined in
same.work.yamlbut not insame.yaml, the project uses the workspace version. - Override: If a tool with the same alias is defined in both files, the definition in
same.yamltakes precedence. This allows specific projects to use different versions of a tool (e.g., testing a library against a newer Go version).
Example
same.work.yaml
packages/myapp/same.yaml