Skip to content

Commit ca38e4e

Browse files
committed
add flake_dir to per repo config
1 parent 47ad4c7 commit ca38e4e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ options.
225225
| :-------- | :---------- | :---- | :-------------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
226226
| lock file | `lock_file` | `str` | dictates which lock file `buildbot-nix` will use when evaluating your flake | `flake.lock` | have multiple lockfiles, one for `nixpkgs-stable`, one for `nixpkgs-unstable` or by default pin an input to a private repo, but have a lockfile with that private repo replaced by a public repo for CI |
227227
| attribute | `attribute` | `str` | which attribute in the flake to evaluate and build | `checks` | using a different attribute, like `hydraJobs` |
228+
| flake_dir | `flake_dir` | `str` | which directory the flake is located | `.` | using a different flake, like `./tests` |
228229

229230
## Binary caches
230231

buildbot_nix/buildbot_nix/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async def run(self) -> int:
176176
"--force-recurse",
177177
"--check-cache-status",
178178
"--flake",
179-
f".#{branch_config.attribute}",
179+
f"{branch_config.flake_dir}#{branch_config.attribute}",
180180
*(
181181
["--reference-lock-file", branch_config.lock_file]
182182
if branch_config.lock_file != "flake.lock"

buildbot_nix/buildbot_nix/repo_config/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import tomllib
2+
from pathlib import Path
23
from tomllib import TOMLDecodeError
34
from typing import TYPE_CHECKING, Self
45

@@ -18,6 +19,7 @@ class RepoConfig(BaseModel):
1819

1920

2021
class BranchConfig(BaseModel):
22+
flake_dir: str = "."
2123
lock_file: str = "flake.lock"
2224
attribute: str = "checks"
2325

@@ -43,10 +45,17 @@ async def extract_during_step(cls, buildstep: BuildStepShellMixin) -> Self:
4345
)
4446
return cls()
4547
try:
46-
return cls.model_validate(tomllib.loads(cmd.stdout))
48+
config = cls.model_validate(tomllib.loads(cmd.stdout))
49+
flake_dir = Path(config.flake_dir).resolve()
50+
root_dir = Path.cwd().resolve()
51+
flake_dir.relative_to(root_dir)
4752
except ValidationError as e:
4853
stdio.addStderr(f"Failed to read repository local configuration, {e}.\n")
4954
return cls()
5055
except TOMLDecodeError as e:
5156
stdio.addStderr(f"Failed to read repository local configuration, {e}.\n")
5257
return cls()
58+
except ValueError:
59+
stdio.addStderr(f"Invalid flake_dir {flake_dir}\n")
60+
return cls()
61+
return config

0 commit comments

Comments
 (0)