#!/usr/bin/env bash

# omarchy:summary=Print the operating system Omarchy runs on: darwin, debian, arch or /etc/os-release's ID
# omarchy:hidden=true

# Based: the one place the tree asks what it runs on. Installers do not
# branch on it; the omarchy-pkg-* primitives and the update steps do.
# OMARCHY_OS in the environment overrides the answer, for a test that
# resolves a package spec for the other OS.
if [[ -n ${OMARCHY_OS:-} ]]; then
  echo "$OMARCHY_OS"
elif [[ $(uname -s) == Darwin ]]; then
  echo darwin
else
  (
    [[ -r /etc/os-release ]] && . /etc/os-release
    case " ${ID:-} ${ID_LIKE:-} " in
      *" debian "* | *" ubuntu "*) echo debian ;;
      *" arch "*) echo arch ;;
      *) echo "${ID:-linux}" ;;
    esac
  )
fi
