From 7cb296e71785aa9a4d07ee52a591ee14b4c46b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 11 Nov 2024 16:17:54 +0100 Subject: [PATCH] simplify reading hostPlaform.system from nixos --- pkgs/clan-cli/clan_cli/machines/machines.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/machines/machines.py b/pkgs/clan-cli/clan_cli/machines/machines.py index b02599eac..8cee21106 100644 --- a/pkgs/clan-cli/clan_cli/machines/machines.py +++ b/pkgs/clan-cli/clan_cli/machines/machines.py @@ -49,21 +49,14 @@ class Machine: @property def system(self) -> str: # We filter out function attributes because they are not serializable. - attr = f""" - (let - machine = ((builtins.getFlake "{self.flake}").nixosConfigurations.{self.name}); - in - {{ x = machine.pkgs.stdenv.hostPlatform.system; }}).x - """ - if attr in self._eval_cache: - output = self._eval_cache[attr] - else: + attr = f'(builtins.getFlake "{self.flake}").nixosConfigurations.{self.name}.pkgs.hostPlatform.system' + output = self._eval_cache.get(attr) + if output is None: output = run_no_stdout( nix_eval(["--impure", "--expr", attr]) ).stdout.strip() self._eval_cache[attr] = output - value = json.loads(output) - return value + return json.loads(output) @property def can_build_locally(self) -> bool: