#!/bin/env fish
begin
    set -l dir (status dirname)
    source "$dir/../../lib/software.fish"
    inherit "$dir/../../../Common/Software/nvidia-dkms/main.fish"

    function installSW
        yayinst \
            nvidia-dkms \
            nvidia-utils \
            lib32-nvidia-utils
    end

    function configureSW -V dir
        begin
            printf %s\n \
                "MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)" \
                "" \
                'for i in "${!HOOKS[@]}"; do' \
                '    if [ "${HOOKS[i]}" = "kms" ]; then' \
                '        unset "HOOKS[i]"' \
                "    fi" \
                done
        end | sudo tee /etc/mkinitcpio.conf.d/nvidia.conf >/dev/null

        configureSWBase $argv
    end

    runInstaller $argv
end