fixup! randomly pick a builder and pass it as --store

This commit is contained in:
Yureka 2024-08-06 11:43:59 +02:00
parent d21f406a25
commit 4a7a9f837a

View file

@ -64,11 +64,15 @@ class NixBuilder:
def to_nix_store(self): def to_nix_store(self):
fullConnection = f"{self.sshUser}@{self.hostName}" if self.sshUser is not None else self.hostName fullConnection = f"{self.sshUser}@{self.hostName}" if self.sshUser is not None else self.hostName
fullConnection = f"{self.protocol}://{fullConnection}" fullConnection = f"{self.protocol}://{fullConnection}"
params = []
if self.sshKey is not None: if self.sshKey is not None:
fullConnection += f"?ssh-key={self.sshKey}" params += f"ssh-key={self.sshKey}"
if self.publicHostKey is not None: if self.publicHostKey is not None:
encoded_public_key = base64.b64encode(self.publicHostKey.encode('ascii')).decode('ascii') encoded_public_key = base64.b64encode(self.publicHostKey.encode('ascii')).decode('ascii')
fullConnection += f"?base64-ssh-public-host-key={encoded_public_key}" params += f"base64-ssh-public-host-key={encoded_public_key}"
if params != []:
fullConnection += "?"
fullConnection += "&".join(params)
return fullConnection return fullConnection
@ -629,22 +633,10 @@ def nix_build_config(
) -> util.BuilderConfig: ) -> util.BuilderConfig:
"""Builds one nix flake attribute.""" """Builds one nix flake attribute."""
factory = util.BuildFactory() 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^*")
]
)
)
# pick a store to run the build on # pick a store to run the build on
build_store = random.choice(build_stores) # TODO proper scheduling instead of picking the first builder
build_store = build_stores[0]
factory.addStep( factory.addStep(
NixBuildCommand( NixBuildCommand(
@ -657,8 +649,6 @@ def nix_build_config(
"--option", "--option",
"keep-going", "keep-going",
"true", "true",
# do not build directly on the coordinator
"--max-jobs", "0",
"--option", "--option",
# stop stuck builds after 20 minutes # stop stuck builds after 20 minutes
"--max-silent-time", "--max-silent-time",