clan-cli: clan_cli.dirs -> clan_lib.dirs
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -9,12 +9,12 @@ pkgs/repro-hook
|
||||
democlan
|
||||
example_clan
|
||||
**/result
|
||||
/pkgs/clan-cli/clan_cli/nixpkgs
|
||||
/pkgs/clan-cli/clan_lib/nixpkgs
|
||||
/pkgs/clan-cli/clan_cli/webui/assets
|
||||
nixos.qcow2
|
||||
**/*.glade~
|
||||
/docs/out
|
||||
/pkgs/clan-cli/clan_cli/select
|
||||
/pkgs/clan-cli/clan_lib/select
|
||||
**/.local.env
|
||||
|
||||
# MacOS stuff
|
||||
|
||||
@@ -14,6 +14,7 @@ from .clan import show, update
|
||||
# API endpoints that are not used in the cli.
|
||||
__all__ = ["directory", "disk", "mdns_discovery", "modules", "update"]
|
||||
|
||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
|
||||
@@ -26,7 +27,6 @@ from . import (
|
||||
vms,
|
||||
)
|
||||
from .custom_logger import setup_logging
|
||||
from .dirs import get_clan_flake_toplevel_or_env
|
||||
from .facts import cli as facts
|
||||
from .flash import cli as flash_cli
|
||||
from .hyperlink import help_hyperlink
|
||||
|
||||
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_lib.cmd import run
|
||||
from clan_lib.dirs import machine_gcroot
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import (
|
||||
@@ -14,7 +15,6 @@ from clan_lib.nix import (
|
||||
nix_metadata,
|
||||
)
|
||||
|
||||
from clan_cli.dirs import machine_gcroot
|
||||
from clan_cli.machines.list import list_machines
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.vms.inspect import VmConfig, inspect_vm
|
||||
|
||||
@@ -27,7 +27,7 @@ COMPLETION_TIMEOUT: int = 3
|
||||
|
||||
|
||||
def clan_dir(flake: str | None) -> str | None:
|
||||
from .dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
|
||||
path_result = get_clan_flake_toplevel_or_env()
|
||||
return str(path_result) if path_result is not None else None
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from clan_lib.dirs import vm_state_dir
|
||||
from clan_lib.errors import ClanError
|
||||
|
||||
from clan_cli.dirs import vm_state_dir
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
from . import FactStoreBase
|
||||
|
||||
@@ -2,7 +2,8 @@ import shutil
|
||||
from pathlib import Path
|
||||
from typing import override
|
||||
|
||||
from clan_cli.dirs import vm_state_dir
|
||||
from clan_lib.dirs import vm_state_dir
|
||||
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
from . import SecretStoreBase
|
||||
|
||||
@@ -5,7 +5,8 @@ from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from .dirs import user_history_file
|
||||
from clan_lib.dirs import user_history_file
|
||||
|
||||
from .jsonrpc import ClanJSONEncoder
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix_models.inventory import (
|
||||
@@ -17,7 +18,6 @@ from clan_lib.persist.inventory_store import InventoryStore
|
||||
from clan_lib.persist.util import apply_patch
|
||||
|
||||
from clan_cli.completions import add_dynamic_completer, complete_tags
|
||||
from clan_cli.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_cli.git import commit_file
|
||||
from clan_cli.machines.list import list_machines
|
||||
from clan_cli.templates import (
|
||||
|
||||
@@ -4,10 +4,10 @@ import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.dirs import specific_machine_dir
|
||||
|
||||
from clan_cli import inventory
|
||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||
from clan_cli.dirs import specific_machine_dir
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.secrets.folders import sops_secrets_folder
|
||||
from clan_cli.secrets.machines import has_machine as secrets_has_machine
|
||||
|
||||
@@ -7,11 +7,11 @@ from pathlib import Path
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.cmd import RunOpts, run
|
||||
from clan_lib.dirs import specific_machine_dir
|
||||
from clan_lib.errors import ClanCmdError, ClanError
|
||||
from clan_lib.nix import nix_config, nix_eval
|
||||
|
||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||
from clan_cli.dirs import specific_machine_dir
|
||||
from clan_cli.git import commit_file
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ from dataclasses import dataclass
|
||||
from clan_lib.api import API
|
||||
from clan_lib.api.disk import MachineDiskMatter
|
||||
from clan_lib.api.modules import parse_frontmatter
|
||||
from clan_lib.dirs import specific_machine_dir
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix_models.inventory import Machine as InventoryMachine
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
|
||||
from clan_cli.completions import add_dynamic_completer, complete_tags
|
||||
from clan_cli.dirs import specific_machine_dir
|
||||
from clan_cli.machines.hardware import HardwareConfig
|
||||
from clan_cli.machines.inventory import get_machine
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
@@ -8,12 +8,12 @@ from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from clan_lib.cmd import Log, RunOpts, run
|
||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_build, nix_command
|
||||
from clan_lib.nix_models.inventory import Machine as InventoryMachine
|
||||
|
||||
from clan_cli.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_cli.machines.create import CreateOptions, create_machine
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.vars.generate import generate_vars
|
||||
|
||||
@@ -15,12 +15,11 @@ from typing import IO, Any
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.cmd import Log, RunOpts, run
|
||||
from clan_lib.dirs import user_config_dir
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_shell
|
||||
|
||||
from clan_cli.dirs import user_config_dir
|
||||
|
||||
from .folders import sops_users_folder
|
||||
|
||||
AGE_RECIPIENT_REGEX = re.compile(r"^.*((age1|ssh-(rsa|ed25519) ).*?)(\s|$)")
|
||||
|
||||
@@ -4,6 +4,7 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
from clan_lib.cmd import RunOpts, run
|
||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_lib.errors import ClanCmdError, ClanError
|
||||
from clan_lib.nix import nix_eval
|
||||
|
||||
@@ -12,7 +13,6 @@ from clan_cli.completions import (
|
||||
complete_machines,
|
||||
complete_state_services_for_machine,
|
||||
)
|
||||
from clan_cli.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -4,11 +4,10 @@ from pathlib import Path
|
||||
from typing import Any, Literal, NewType, TypedDict, cast
|
||||
|
||||
from clan_lib.cmd import run
|
||||
from clan_lib.dirs import clan_templates
|
||||
from clan_lib.errors import ClanCmdError, ClanError
|
||||
from clan_lib.flake import Flake
|
||||
|
||||
from clan_cli.dirs import clan_templates
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ from pathlib import Path
|
||||
from typing import Any, NamedTuple
|
||||
|
||||
import pytest
|
||||
from clan_cli.dirs import (
|
||||
TemplateType,
|
||||
clan_templates,
|
||||
nixpkgs_source,
|
||||
specific_machine_dir,
|
||||
)
|
||||
from clan_cli.locked_open import locked_open
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.tests import age_keys
|
||||
from clan_cli.tests.fixture_error import FixtureError
|
||||
from clan_cli.tests.root import CLAN_CORE
|
||||
from clan_cli.tests.temporary_dir import TEMPDIR
|
||||
from clan_lib.dirs import (
|
||||
TemplateType,
|
||||
clan_templates,
|
||||
nixpkgs_source,
|
||||
specific_machine_dir,
|
||||
)
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_test_store
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# from clan_cli.dirs import _get_clan_flake_toplevel
|
||||
# from clan_lib.dirs import _get_clan_flake_toplevel
|
||||
|
||||
# TODO: Reimplement test?
|
||||
# def test_get_clan_flake_toplevel(
|
||||
@@ -16,7 +16,7 @@
|
||||
# (subdir / ".clan-flake").touch()
|
||||
# assert _get_clan_flake_toplevel() == subdir
|
||||
|
||||
from clan_cli.dirs import clan_key_safe, vm_state_dir
|
||||
from clan_lib.dirs import clan_key_safe, vm_state_dir
|
||||
|
||||
|
||||
def test_clan_key_safe() -> None:
|
||||
|
||||
@@ -3,11 +3,11 @@ import shutil
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
|
||||
from clan_cli.dirs import vm_state_dir
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.ssh.host import Host
|
||||
from clan_cli.vars._types import StoreBase
|
||||
from clan_cli.vars.generate import Generator, Var
|
||||
from clan_lib.dirs import vm_state_dir
|
||||
from clan_lib.errors import ClanError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -2,11 +2,11 @@ import shutil
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
|
||||
from clan_cli.dirs import vm_state_dir
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.ssh.host import Host
|
||||
from clan_cli.vars._types import StoreBase
|
||||
from clan_cli.vars.generate import Generator, Var
|
||||
from clan_lib.dirs import vm_state_dir
|
||||
|
||||
|
||||
class SecretStore(StoreBase):
|
||||
|
||||
@@ -13,11 +13,11 @@ from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from clan_lib.cmd import CmdOut, Log, RunOpts, handle_io, run
|
||||
from clan_lib.dirs import module_root, user_cache_dir, vm_state_dir
|
||||
from clan_lib.errors import ClanCmdError, ClanError
|
||||
from clan_lib.nix import nix_shell
|
||||
|
||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||
from clan_cli.dirs import module_root, user_cache_dir, vm_state_dir
|
||||
from clan_cli.facts.generate import generate_facts
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.qemu.qga import QgaSession
|
||||
|
||||
@@ -5,13 +5,13 @@ from dataclasses import dataclass
|
||||
from typing import Any, TypedDict
|
||||
from uuid import uuid4
|
||||
|
||||
from clan_cli.dirs import TemplateType, clan_templates
|
||||
from clan_cli.git import commit_file
|
||||
from clan_cli.machines.hardware import HardwareConfig, show_machine_hardware_config
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.api.modules import Frontmatter, extract_frontmatter
|
||||
from clan_lib.dirs import TemplateType, clan_templates
|
||||
from clan_lib.errors import ClanError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -9,10 +9,10 @@ from typing import TYPE_CHECKING
|
||||
from clan_lib.errors import ClanError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from clan_lib.flake import Flake
|
||||
|
||||
from clan_cli.machines.machines import Machine
|
||||
|
||||
from clan_lib.flake import Flake
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ def specific_machine_dir(machine: "Machine") -> Path:
|
||||
|
||||
|
||||
def module_root() -> Path:
|
||||
return Path(__file__).parent
|
||||
return Path(__file__).parent.parent
|
||||
|
||||
|
||||
def nixpkgs_flake() -> Path:
|
||||
@@ -649,8 +649,7 @@ class Flake:
|
||||
|
||||
This method is used to refresh the cache by reloading it from the flake.
|
||||
"""
|
||||
from clan_cli.dirs import user_cache_dir
|
||||
|
||||
from clan_lib.dirs import user_cache_dir
|
||||
from clan_lib.nix import (
|
||||
nix_metadata,
|
||||
)
|
||||
@@ -703,9 +702,8 @@ class Flake:
|
||||
ClanError: If the number of outputs does not match the number of selectors.
|
||||
AssertionError: If the cache or flake cache path is not properly initialized.
|
||||
"""
|
||||
from clan_cli.dirs import nixpkgs_source, select_source
|
||||
|
||||
from clan_lib.cmd import Log, RunOpts, run
|
||||
from clan_lib.dirs import nixpkgs_source, select_source
|
||||
from clan_lib.nix import (
|
||||
nix_build,
|
||||
nix_config,
|
||||
|
||||
@@ -7,10 +7,10 @@ from functools import cache
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_cli.dirs import nixpkgs_flake, nixpkgs_source
|
||||
from clan_cli.locked_open import locked_open
|
||||
|
||||
from clan_lib.cmd import run
|
||||
from clan_lib.dirs import nixpkgs_flake, nixpkgs_source
|
||||
from clan_lib.errors import ClanError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -8,7 +8,6 @@ from typing import Any
|
||||
|
||||
import clan_cli.clan.create
|
||||
import pytest
|
||||
from clan_cli.dirs import specific_machine_dir
|
||||
from clan_cli.inventory import patch_inventory_with
|
||||
from clan_cli.machines.create import CreateOptions as ClanCreateOptions
|
||||
from clan_cli.machines.create import create_machine
|
||||
@@ -23,6 +22,7 @@ from clan_cli.vars.generate import generate_vars_for_machine, get_generators_clo
|
||||
from clan_lib.api.disk import hw_main_disk_options, set_machine_disk_schema
|
||||
from clan_lib.api.network import check_machine_online
|
||||
from clan_lib.cmd import RunOpts, run
|
||||
from clan_lib.dirs import specific_machine_dir
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_command
|
||||
|
||||
@@ -66,14 +66,14 @@ let
|
||||
chmod -R +w $out
|
||||
|
||||
# In cases where the devshell created this file, this will already exist
|
||||
rm -f $out/clan_cli/nixpkgs
|
||||
rm -f $out/clan_lib/nixpkgs
|
||||
|
||||
substituteInPlace $out/clan_lib/flake/flake.py \
|
||||
--replace-fail '@fallback_nixpkgs_hash@' "$(jq -r '.nodes.nixpkgs.locked.narHash' ${nixpkgs'}/flake.lock)" \
|
||||
--replace-fail '@select_hash@' "$(jq -r '.nodes."nix-select".locked.narHash' ${../../flake.lock})"
|
||||
ln -sf ${nixpkgs'} $out/clan_cli/nixpkgs
|
||||
ln -sf ${nix-select} $out/clan_cli/select
|
||||
cp -r ${../../templates} $out/clan_cli/templates
|
||||
ln -sf ${nixpkgs'} $out/clan_lib/nixpkgs
|
||||
ln -sf ${nix-select} $out/clan_lib/select
|
||||
cp -r ${../../templates} $out/clan_lib/templates
|
||||
'';
|
||||
|
||||
sourceWithoutTests = cliSource (
|
||||
@@ -295,8 +295,8 @@ pythonRuntime.pkgs.buildPythonApplication {
|
||||
# leading to a different NAR hash and copying it here would also lead to `patchShebangs`
|
||||
# changing the contents
|
||||
postInstall = ''
|
||||
cp -r ${nixpkgs'} $out/${pythonRuntime.sitePackages}/clan_cli/nixpkgs
|
||||
ln -sf ${nix-select} $out/${pythonRuntime.sitePackages}/clan_cli/select
|
||||
cp -r ${nixpkgs'} $out/${pythonRuntime.sitePackages}/clan_lib/nixpkgs
|
||||
ln -sf ${nix-select} $out/${pythonRuntime.sitePackages}/clan_lib/select
|
||||
installShellCompletion --bash --name clan \
|
||||
<(${pythonRuntimeWithDeps.pkgs.argcomplete}/bin/register-python-argcomplete --shell bash clan)
|
||||
installShellCompletion --fish --name clan.fish \
|
||||
|
||||
@@ -16,7 +16,7 @@ Repository = "https://git.clan.lol/clan/clan-core"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["clan_lib*", "clan_cli*"]
|
||||
exclude = ["clan_cli.nixpkgs*", "result"]
|
||||
exclude = ["clan_lib.nixpkgs*", "result"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
clan_cli = [
|
||||
@@ -36,7 +36,7 @@ faulthandler_timeout = 240
|
||||
log_level = "DEBUG"
|
||||
log_format = "%(message)s"
|
||||
addopts = "--cov . --cov-report term --cov-report html:.reports/html --no-cov-on-fail --durations 5 --color=yes --new-first -W error -n auto" # Add --pdb for debugging
|
||||
norecursedirs = ["clan_cli/tests/helpers", "clan_cli/nixpkgs"]
|
||||
norecursedirs = ["clan_cli/tests/helpers", "clan_lib/nixpkgs"]
|
||||
# All tests which evaluate any nix library code from clan-core need to use the
|
||||
# `with_core` marker, so basically all tests which evaluate a flake with
|
||||
# machines. In the CI pipeline we run these tests in a separate derivation
|
||||
|
||||
@@ -13,10 +13,10 @@ from typing import IO, ClassVar
|
||||
|
||||
import gi
|
||||
from clan_cli import vms
|
||||
from clan_cli.dirs import vm_state_dir
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.vms.inspect import inspect_vm
|
||||
from clan_cli.vms.qemu import QMPWrapper
|
||||
from clan_lib.dirs import vm_state_dir
|
||||
|
||||
from clan_vm_manager.clan_uri import ClanURI
|
||||
from clan_vm_manager.components.executor import MPProcess, spawn
|
||||
|
||||
@@ -6,9 +6,9 @@ import logging
|
||||
from typing import Any
|
||||
|
||||
from clan_cli.clan.inspect import FlakeConfig, inspect_flake
|
||||
from clan_cli.dirs import user_history_file
|
||||
from clan_cli.locked_open import read_history_file, write_history_file
|
||||
from clan_cli.machines.list import list_machines
|
||||
from clan_lib.dirs import user_history_file
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ from pathlib import Path
|
||||
from tempfile import NamedTemporaryFile
|
||||
from typing import Any, override
|
||||
|
||||
from clan_cli.dirs import find_git_repo_root
|
||||
from clan_cli.machines.machines import Machine
|
||||
from clan_cli.vars.generate import generate_vars
|
||||
from clan_lib.dirs import find_git_repo_root
|
||||
from clan_lib.flake.flake import Flake
|
||||
from clan_lib.nix import nix_config, nix_eval
|
||||
|
||||
|
||||
Reference in New Issue
Block a user