From 5dfcf94adcdb5df052701a672d8421cd2b3ec834 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Mon, 22 Jul 2024 23:00:22 +0200 Subject: [PATCH] fix(build): use per-worker slot store Signed-off-by: Raito Bezarius --- buildbot_nix/__init__.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/buildbot_nix/__init__.py b/buildbot_nix/__init__.py index 95a430a..67dba49 100644 --- a/buildbot_nix/__init__.py +++ b/buildbot_nix/__init__.py @@ -58,14 +58,17 @@ class NixBuilder: publicHostKey: str | None = None sshUser: str | None = None sshKey: str | None = None - systems: list[str] = field(default_factory=lambda: ["-"]) - supportedFeatures: list[str] = field(default_factory=lambda: ["-"]) - mandatoryFeatures: list[str] = field(default_factory=lambda: ["-"]) + systems: list[str] = field(default_factory=lambda: []) + supportedFeatures: list[str] = field(default_factory=lambda: []) + mandatoryFeatures: list[str] = field(default_factory=lambda: []) def to_nix_line(self): + systems = ["-"] if not self.systems else self.systems + supportedFeatures = ["-"] if not self.supportedFeatures else self.supportedFeatures + mandatoryFeatures = ["-"] if not self.mandatoryFeatures else self.mandatoryFeatures encoded_public_key = base64.b64encode(self.publicHostKey.encode('ascii')).decode('ascii') if self.publicHostKey is not None else "-" fullConnection = f"{self.protocol}://{self.sshUser}@{self.hostName}" if self.sshUser is not None else self.hostName - return f"{fullConnection} {",".join(self.systems)} {self.sshKey or "-"} {self.maxJobs} {self.speedFactor} {",".join(self.supportedFeatures)} {",".join(self.mandatoryFeatures)} {encoded_public_key}" + return f"{fullConnection} {",".join(systems)} {self.sshKey or "-"} {self.maxJobs} {self.speedFactor} {",".join(supportedFeatures)} {",".join(mandatoryFeatures)} {encoded_public_key}" @dataclass @@ -658,6 +661,20 @@ def nix_build_config( ) -> util.BuilderConfig: """Builds one nix flake attribute.""" factory = util.BuildFactory() + factory.addStep( + steps.ShellCommand( + name="Copy the derivation to the local worker store", + command=[ + "nix", + "copy", + "--derivation", + "--to", + "../store", + util.Interpolate("%(prop:drv_path)s^*") + ] + ) + ) + factory.addStep( NixBuildCommand( env={}, @@ -679,6 +696,8 @@ def nix_build_config( "7200", "--builders", builders_spec, + "--store", + util.Interpolate("%(prop:builddir)s/store"), "--out-link", util.Interpolate("result-%(prop:attr)s"), util.Interpolate("%(prop:drv_path)s^*"), @@ -698,6 +717,8 @@ def nix_build_config( "nix", "store", "sign", + "--store", + util.Interpolate("%(prop:builddir)s/store"), "--key-file", signing_keyfile, util.Interpolate(