#!/usr/bin/env nu
# SPDX-FileCopyrightText: 2025-present Krys Lawrence <aquarion.5.krystopher@spamgourmet.org>
# SPDX-License-Identifier: AGPL-3.0-only

# Part of the aquarion-libtts library of the Aquarion AI project.
# Copyright (C) 2025-present Krys Lawrence <aquarion.5.krystopher@spamgourmet.org>
#
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free Software
# Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.


# Initialize a fresh Devbox
#
# This installs Hatch and pre-commit in an isolated environments.
def "main" []: nothing -> string {
    (
        uv tool install -p $env.AQ_PYTHON_MINIMUM_VERSION --managed-python
        $"hatch~=($env.AQ_HATCH_MINIMUM_VERSION)"
        --with $"pip~=($env.AQ_PIP_MINIMUM_VERSION)"
    )
    (
        uv tool install -p $env.AQ_PYTHON_MINIMUM_VERSION --managed-python
        $"pre-commit~=($env.AQ_PRE_COMMIT_MINIMUM_VERSION)"
    )
    pre-commit install --install-hooks
    (
        uv tool install -p $env.AQ_PYTHON_MINIMUM_VERSION --managed-python
        $"commitizen~=($env.AQ_COMMITIZEN_MINIMUM_VERSION)"
        --with $"cz-conventional-gitmoji~=($env.AQ_CZ_CONVENTIONAL_GITMOJI_MINIMUM_VERSION)"
    )
    (
        uv tool install -p $env.AQ_PYTHON_MINIMUM_VERSION --managed-python
        $"reuse~=($env.AQ_REUSE_MINIMUM_VERSION)"
    )
    lang extract
    lang compile
    nix-store --optimize
    nix-collect-garbage -d
    pre-commit gc
}
