simplify reading hostPlaform.system from nixos
This commit is contained in:
@@ -49,21 +49,14 @@ class Machine:
|
|||||||
@property
|
@property
|
||||||
def system(self) -> str:
|
def system(self) -> str:
|
||||||
# We filter out function attributes because they are not serializable.
|
# We filter out function attributes because they are not serializable.
|
||||||
attr = f"""
|
attr = f'(builtins.getFlake "{self.flake}").nixosConfigurations.{self.name}.pkgs.hostPlatform.system'
|
||||||
(let
|
output = self._eval_cache.get(attr)
|
||||||
machine = ((builtins.getFlake "{self.flake}").nixosConfigurations.{self.name});
|
if output is None:
|
||||||
in
|
|
||||||
{{ x = machine.pkgs.stdenv.hostPlatform.system; }}).x
|
|
||||||
"""
|
|
||||||
if attr in self._eval_cache:
|
|
||||||
output = self._eval_cache[attr]
|
|
||||||
else:
|
|
||||||
output = run_no_stdout(
|
output = run_no_stdout(
|
||||||
nix_eval(["--impure", "--expr", attr])
|
nix_eval(["--impure", "--expr", attr])
|
||||||
).stdout.strip()
|
).stdout.strip()
|
||||||
self._eval_cache[attr] = output
|
self._eval_cache[attr] = output
|
||||||
value = json.loads(output)
|
return json.loads(output)
|
||||||
return value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_build_locally(self) -> bool:
|
def can_build_locally(self) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user