fix(build): use per-worker slot store

Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
raito 2024-07-22 23:00:22 +02:00
parent 4aa1d7e78c
commit 021e2064ae

View file

@ -59,14 +59,17 @@ class NixBuilder:
publicHostKey: str | None = None publicHostKey: str | None = None
sshUser: str | None = None sshUser: str | None = None
sshKey: str | None = None sshKey: str | None = None
systems: list[str] = field(default_factory=lambda: ["-"]) systems: list[str] = field(default_factory=lambda: [])
supportedFeatures: list[str] = field(default_factory=lambda: ["-"]) supportedFeatures: list[str] = field(default_factory=lambda: [])
mandatoryFeatures: list[str] = field(default_factory=lambda: ["-"]) mandatoryFeatures: list[str] = field(default_factory=lambda: [])
def to_nix_line(self): 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 "-" 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 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 @dataclass
@ -666,6 +669,20 @@ 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^*")
]
)
)
factory.addStep( factory.addStep(
NixBuildCommand( NixBuildCommand(
env={}, env={},
@ -687,6 +704,8 @@ def nix_build_config(
"7200", "7200",
"--builders", "--builders",
builders_spec, builders_spec,
"--store",
util.Interpolate("%(prop:builddir)s/store"),
"--out-link", "--out-link",
util.Interpolate("result-%(prop:attr)s"), util.Interpolate("result-%(prop:attr)s"),
util.Interpolate("%(prop:drv_path)s^*"), util.Interpolate("%(prop:drv_path)s^*"),
@ -706,6 +725,8 @@ def nix_build_config(
"nix", "nix",
"store", "store",
"sign", "sign",
"--store",
util.Interpolate("%(prop:builddir)s/store"),
"--key-file", "--key-file",
signing_keyfile, signing_keyfile,
util.Interpolate( util.Interpolate(