#      _       _      _
#   __| | ___ | |_ __| |_ __ ___  _ __
#  / _` |/ _ \| __/ _` | '__/ _ \| '_ \
# | (_| | (_) | || (_| | | | (_) | |_) |
#  \__,_|\___/ \__\__,_|_|  \___/| .__/
#                                |_|

###############################################################
config:
###############################################################

    backup: false
    banner: false
    keepdot: false
    link_dotfile_default: nolink
    link_on_import: nolink
    dotpath: .
    func_file:
    - "../funcs.py"
    filter_file:
    - "../funcs.py"
    # import_configs:
    # - "../config.yaml"
    import_variables:
    - "hardware.yaml"

###############################################################
actions:
###############################################################

    # greetd_install: _greetd_install
    grub_install: update-grub
    locale_install: locale-gen
    libc_locale_install: xbps-reconfigure -f glibc-locales
    pacman_install: |
        pacman-key --init
        pacman-key --populate
    sv_update: |
        sv restart "{{@@ '_dotfile_key' @@}}" ||
        rc-service "{{@@ '_dotfile_key' @@}}" restart

    create_swapfile: _create-swapfile
    dbus_uuidgen: dbus-uuidgen --ensure
    sysctl_apply: sysctl -a
    mkinitcpio: mkinitcpio -P
    restart_runit_service: sv restart "{0}"
    enable_runit_services: ln -sf "{{@@ sys_services @@}}/{0}" "{{@@ sys_svdir @@}}/{0}"
    link_timezone: ln -sf "/usr/share/zoneinfo/{{@@ timezone @@}}" "/etc/localtime"

###############################################################
profiles:
###############################################################

    common:
        dotfiles:
            - bluez
            - fstab
            - grub
            - grub_d
            - iwd
            - kernel_modules
            - locale
            - pam
            - sudoers
            - sysctl
            - udev_rules
            - vconsole

    voidlinux:
        variables:
            sys_services: /etc/sv
            sys_svdir: /etc/runit/runsvdir/default/
            root_subvol: /@void
        include:
            - "common"
        dotfiles:
            - elogind
            - acpid
            - libc_locales
            - runit_services
            - runit_services_enable

    artixlinux:
        variables:
            root_subvol: /@artix
        include:
            - "common"
        dotfiles:
            - elogind
            - mkinitcpio
            - pacman-artix

    archlinux:
        variables:
            root_subvol: /@arch
        include:
            - "common"
        dotfiles:
            - logind
            - mkinitcpio
            - pacman-arch
            - systemd_services

###############################################################
dotfiles:
###############################################################

    # greetd:
    #     src: greetd
    #     dst: /etc/greetd
    #     actions:
    #     - greetd_install

    logind:
        src: logind.conf
        dst: /etc/systemd/logind.conf
        actions:
        - dbus_uuidgen

    iwd:
        src: iwd.conf
        dst: /etc/iwd/main.conf

    elogind:
        src: logind.conf
        dst: /etc/elogind/logind.conf
        actions:
        - dbus_uuidgen

    acpid:
        src: acpi-handler.sh
        dst: /etc/acpi/handler.sh
        actions:
        - restart_runit_service acpid

    grub:
        src: grub
        dst: /etc/default/grub
        actions:
        - grub_install

    grub_d:
        src: grub.d
        dst: /etc/grub.d
        actions:
        - grub_install

    pam:
        src: pam-local-login
        dst: /etc/pam.d/system-local-login

    sudoers:
        src: sudoers
        dst: /etc/sudoers.d/local

    mkinitcpio:
        src: mkinitcpio.conf
        dst: /etc/mkinitcpio.conf
        actions:
        - mkinitcpio

    pacman-artix:
        src: pacman-artix.conf
        dst: /etc/pacman.conf
        actions:
        - pacman_install

    pacman-arch:
        src: pacman-arch.conf
        dst: /etc/pacman.conf
        actions:
        - pacman_install

    bluez:
        src: bluetooth.conf
        dst: /etc/bluetooth/main.conf

    locale:
        src: locale.gen
        dst: /etc/locale.gen
        actions:
        - locale_install

    libc_locales:
        src: locale.gen
        dst: /etc/default/libc-locales
        actions:
        - libc_locale_install

    fstab:
        src: fstab
        dst: /etc/fstab
        actions:
        - create_swapfile

    sysctl:
        src: sysctl
        dst: /etc/sysctl.d
        actions:
        - sysctl_apply

    kernel_modules:
        src: kernel-modules
        dst: /etc/modules-load.d/

    udev_rules:
        src: udev-rules
        dst: /etc/udev/rules.d/

    vconsole:
        src: vconsole.conf
        dst: /etc/vconsole.conf

    # earlyoom:
    #     src: earlyoom
    #     dst: /etc/default/earlyoom

    runit_services:
        src: runit_sv
        dst: /etc/runit/sv

    runit_services_enable:
        src:
        dst:
        actions:
        - enable_runit_services acpid
        - enable_runit_services bluetoothd
        - enable_runit_services crond
        - enable_runit_services dbus
        - enable_runit_services dhcpcd
        - enable_runit_services docker
        - enable_runit_services iwd
        - enable_runit_services ntpd
        - enable_runit_services rundird
        - enable_runit_services seatd
        - enable_runit_services socklog-unix
        - enable_runit_services tlp

    systemd_services:
        src: systemd
        dst: /etc/systemd/system/

    timezone:
        src:
        dst:
        actions:
        - link_timezone
