From cb1703d0591641b34ff72f4ac471c51f8015c7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 19 May 2025 12:09:08 +0200 Subject: [PATCH] drop deploy_as_root check We haven't documented macOS support yet, so I don't expect many people using it yet. Now that the pull request is merged probably most people starting with darwin-nix will be on that commit anyway, so it's not worth the check, given that the sudo version doesn't work very well. --- pkgs/clan-cli/clan_cli/machines/machines.py | 24 +-------------------- pkgs/clan-cli/clan_cli/machines/update.py | 7 +----- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/machines/machines.py b/pkgs/clan-cli/clan_cli/machines/machines.py index 3ac2019bf..71a725f57 100644 --- a/pkgs/clan-cli/clan_cli/machines/machines.py +++ b/pkgs/clan-cli/clan_cli/machines/machines.py @@ -9,10 +9,9 @@ from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, Any -from clan_lib.cmd import Log, RunOpts, run from clan_lib.errors import ClanCmdError, ClanError from clan_lib.flake import Flake -from clan_lib.nix import nix_config, nix_eval, nix_test_store +from clan_lib.nix import nix_config, nix_test_store from clan_cli.facts import public_modules as facts_public_modules from clan_cli.facts import secret_modules as facts_secret_modules @@ -179,27 +178,6 @@ class Machine: ) as build_host: yield build_host - @cached_property - def deploy_as_root(self) -> bool: - if self._class_ == "nixos": - return True - - # Currently nix-darwin HEAD requires you to deploy as a non-root user - # however there is a soon to be merged PR that requires deployment - # as root to match NixOS: https://github.com/nix-darwin/nix-darwin/pull/1341 - return json.loads( - run( - nix_eval( - [ - f"{self.flake}#darwinConfigurations.{self.name}.options.system", - "--apply", - "system: system ? primaryUser", - ] - ), - RunOpts(log=Log.NONE), - ).stdout.strip() - ) - def nix( self, attr: str, diff --git a/pkgs/clan-cli/clan_cli/machines/update.py b/pkgs/clan-cli/clan_cli/machines/update.py index ea2e99eb0..28328fd1f 100644 --- a/pkgs/clan-cli/clan_cli/machines/update.py +++ b/pkgs/clan-cli/clan_cli/machines/update.py @@ -109,11 +109,6 @@ def deploy_machine(machine: Machine) -> None: target_host = stack.enter_context(machine.target_host()) build_host = stack.enter_context(machine.build_host()) - if machine._class_ == "darwin": - if not machine.deploy_as_root and target_host.user == "root": - msg = f"'targetHost' should be set to a non-root user for deploying to nix-darwin on machine '{machine.name}'" - raise ClanError(msg) - host = build_host or target_host generate_facts([machine], service=None, regenerate=False) @@ -138,7 +133,7 @@ def deploy_machine(machine: Machine) -> None: f"{path}#{machine.name}", ] - become_root = machine.deploy_as_root + become_root = True if machine._class_ == "nixos": nix_options += [