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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 += [
|
||||
|
||||
Reference in New Issue
Block a user