Skip to content

factory

get_package_manager(*, distro, manager)

Return a unified package manager backend for the given environment.

Parameters:

Name Type Description Default
distro str

A normalized distro identifier (e.g. "ubuntu").

required
manager str

The package manager identifier (e.g. "apt").

required

Returns:

Type Description
PackageManager | None

A PackageManager instance if supported, otherwise None.

Source code in src/personal_os_setup/tasks/factory.py
def get_package_manager(*, distro: str, manager: str) -> PackageManager | None:
    """Return a unified package manager backend for the given environment.

    Args:
        distro: A normalized distro identifier (e.g. `"ubuntu"`).
        manager: The package manager identifier (e.g. `"apt"`).

    Returns:
        A `PackageManager` instance if supported, otherwise `None`.
    """
    factory = _PACKAGE_MANAGER_FACTORY_BY_DISTRO.get(distro, {}).get(manager)
    return factory() if factory else None

get_system_action_sections(*, system, distro, info, packages=None)

Build the ordered list of (section_name, [SystemAction]) tuples for this OS/distro.

Sections are assembled conditionally on system/distro: package-manager sections always come first, then Start (all OSes), zsh/chezmoi (Linux+macOS), system (NVIDIA/CUDA/docker/vicinae; Windows+Linux), and WSL/Windows-utility sections (Windows only).

Parameters:

Name Type Description Default
system str

Normalized OS family (e.g. "windows", "darwin", "linux").

required
distro str

Normalized distro identifier (e.g. "ubuntu").

required
info str | None

Extra environment info (e.g. WSL detection note), or None.

required
packages list[PackageRef] | None

The full package catalog for this distro, used to populate the "install zsh setup prerequisites" action in the dotfiles section (packages tagged with the "terminal_tools" category in packages.yaml).

None
Source code in src/personal_os_setup/tasks/factory.py
def get_system_action_sections(
    *, system: str, distro: str, info: str | None, packages: list[PackageRef] | None = None
) -> list[Section]:
    """Build the ordered list of `(section_name, [SystemAction])` tuples for this OS/distro.

    Sections are assembled conditionally on `system`/`distro`: package-manager
    sections always come first, then Start (all OSes), zsh/chezmoi (Linux+macOS),
    system (NVIDIA/CUDA/docker/vicinae; Windows+Linux), and WSL/Windows-utility
    sections (Windows only).

    Args:
        system: Normalized OS family (e.g. `"windows"`, `"darwin"`, `"linux"`).
        distro: Normalized distro identifier (e.g. `"ubuntu"`).
        info: Extra environment info (e.g. WSL detection note), or `None`.
        packages: The full package catalog for this distro, used to populate the
            "install zsh setup prerequisites" action in the dotfiles section (packages
            tagged with the `"terminal_tools"` category in `packages.yaml`).
    """
    sections: list[Section] = []

    # Package managers (apt, snap, brew...) - at the top for quick access.
    sections.extend(_package_manager_sections(distro))

    # Start section (onboarding walkthrough + documentation link) applies to every OS.
    sections.append(_start_section(system))

    #################
    ## Linux & Darwin
    #################
    if system in {"darwin", "linux"}:
        sections.append(_dotfiles_section(distro, packages or []))

    ########
    ## System (NVIDIA/CUDA, docker post-install, vicinae)
    ########
    if system in {"windows", "linux"}:
        sections.append(_system_section(system=system, distro=distro))

    ########
    ## Windows
    ########
    if system == "windows":
        settings_path = _windows_terminal_settings_path()
        sections.append(_wsl_section(settings_path))
        sections.append(_advanced_wsl_section())
        sections.append(_windows_utilities_section(settings_path))

    return sections