Merge pull request 'machines: don't build on target machine if remote builders can be used' (#2639) from Enzime/clan-core:push-xzowvlsoytvv into main
This commit is contained in:
@@ -100,7 +100,9 @@ def install_machine(opts: InstallOptions) -> None:
|
|||||||
]
|
]
|
||||||
|
|
||||||
if not machine.can_build_locally or opts.build_on_remote:
|
if not machine.can_build_locally or opts.build_on_remote:
|
||||||
machine.info("Architecture mismatch. Building on remote machine")
|
machine.info(
|
||||||
|
f"Target machine has architecture {machine.system} which cannot be built locally or with the configured remote builders. Building on target machine"
|
||||||
|
)
|
||||||
cmd.append("--build-on-remote")
|
cmd.append("--build-on-remote")
|
||||||
|
|
||||||
if machine.target_host.port:
|
if machine.target_host.port:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from dataclasses import dataclass, field
|
|||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
from time import time
|
||||||
from typing import TYPE_CHECKING, Any, Literal
|
from typing import TYPE_CHECKING, Any, Literal
|
||||||
|
|
||||||
from clan_cli.clan_uri import FlakeId
|
from clan_cli.clan_uri import FlakeId
|
||||||
@@ -78,10 +79,32 @@ class Machine:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def can_build_locally(self) -> bool:
|
def can_build_locally(self) -> bool:
|
||||||
# TODO: We could also use the function pkgs.stdenv.hostPlatform.canExecute
|
config = nix_config()
|
||||||
# but this is good enough for now.
|
if self.system == config["system"] or self.system in config["extra-platforms"]:
|
||||||
output = nix_config()
|
return True
|
||||||
return self.system == output["system"]
|
|
||||||
|
unsubstitutable_drv = json.loads(
|
||||||
|
run_no_stdout(
|
||||||
|
nix_eval(
|
||||||
|
[
|
||||||
|
"--impure",
|
||||||
|
"--expr",
|
||||||
|
f'((builtins.getFlake "{self.flake}").inputs.nixpkgs.legacyPackages.{self.system}.runCommandNoCC "clan-can-build-{int(time())}" {{ }} "touch $out").drvPath',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
opts=RunOpts(prefix=self.name),
|
||||||
|
).stdout.strip()
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
run_no_stdout(
|
||||||
|
nix_build([f"{unsubstitutable_drv}^*"]), opts=RunOpts(prefix=self.name)
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
self.debug("failed to build test derivation", exc_info=e)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def deployment(self) -> dict:
|
def deployment(self) -> dict:
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ lint.select = [
|
|||||||
]
|
]
|
||||||
lint.ignore = [
|
lint.ignore = [
|
||||||
"A003",
|
"A003",
|
||||||
"ANN101",
|
|
||||||
"ANN401",
|
"ANN401",
|
||||||
"TRY400",
|
"TRY400",
|
||||||
"E402",
|
"E402",
|
||||||
|
|||||||
Reference in New Issue
Block a user