101 lines
2.9 KiB
Bash
101 lines
2.9 KiB
Bash
export CONFIG_DIR=/home/me/work/config
|
|
export DATA_DIR=/home/me/work/app-data
|
|
export HERE_DIR=/home/me/here
|
|
export LOG_DIR=/tmp/mlog
|
|
export SVDIR=$CONFIG_DIR/hosts/main/services
|
|
export BASH_ENV=$CONFIG_DIR/hosts/main/bashrc
|
|
export HOSTNAME=main
|
|
mkdir -p $LOG_DIR
|
|
|
|
# arch path
|
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
export PATH=$PATH:$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin # nix path
|
|
|
|
# main stuff
|
|
export PATH=$CONFIG_DIR/hosts/main/bin:$PATH
|
|
export SECRETS_DIR=/home/me/secrets
|
|
|
|
# nix lock
|
|
export NIXPKGS_REV=04e1ec9c5dbf94ab78b6b755b5ec28c1d6dd5392 # nix eval ${CONFIG_DIR}#inputs.nixpkgs.rev
|
|
export NIXPKGS_UNSTABLE_REV=ac6b2166e7a9375683b8e98f860f273222337b16 # nix eval ${CONFIG_DIR}#inputs.nixpkgs.rev
|
|
export NIX_PATH=nixpkgs=/nix/store/jpf38g508p4njqzbfkvdfjj7v3s795k9-source # nix flake prefetch nixpkgs/$(nix eval $CONFIG_DIR#inputs.nixpkgs.rev --raw) --json | jq '.storePath' -r
|
|
|
|
# bin paths
|
|
if [ -d /run/current-system ]; then # in case of nixos
|
|
export BIN_ZED=~/work/path-extra/zed
|
|
else
|
|
export BIN_ZED=/usr/sbin/zeditor
|
|
fi
|
|
|
|
## #### detect distro
|
|
detect_distro() {
|
|
local -n reply_distro=$1
|
|
local line key value
|
|
|
|
reply_distro="unknown"
|
|
|
|
# Read file line by line without spawning external commands
|
|
if [[ -f /etc/os-release ]]; then
|
|
while IFS='=' read -r key value; do
|
|
# Clean up the key name
|
|
key="${key##*([[:space:]])}"
|
|
key="${key%%*([[:space:]])}"
|
|
|
|
if [[ "$key" == "ID" ]]; then
|
|
# Strip potential surrounding quotes from the value
|
|
value="${value#\"}"
|
|
value="${value%\"}"
|
|
value="${value#\'}"
|
|
value="${value%\'}"
|
|
|
|
reply_distro="$value"
|
|
return 0
|
|
fi
|
|
done < /etc/os-release
|
|
fi
|
|
}
|
|
|
|
# get_config
|
|
function get_config() {
|
|
if [[ "$2" == "" ]]; then
|
|
local -n reply_config=OUT
|
|
else
|
|
local -n reply_config=$2
|
|
fi
|
|
|
|
declare -A myconfig
|
|
detect_distro DISTRO
|
|
|
|
myconfig["hyprland.bin"]="~/work/src/hyprland/build/Hyprland"
|
|
myconfig["prismlauncher.bin"]="/usr/sbin/prismlauncher"
|
|
myconfig["hyprland.configFile"]="$CONFIG_DIR/hosts/main/hyprland.lua"
|
|
myconfig["steam.homeDir"]="$HERE_DIR/steam-home"
|
|
myconfig["steam.bin"]="/home/me/.nix-profile/bin/steam"
|
|
myconfig["git.bin"]="/bin/git"
|
|
myconfig["ssh.bin"]="/bin/ssh"
|
|
myconfig["mize.configFile"]="$CONFIG_DIR/hosts/main/"
|
|
myconfig["mize.secretsFile"]="~/secrets/mize-config.toml"
|
|
|
|
# nixos case
|
|
if [[ "$DISTRO" == "nixos" ]]; then
|
|
myconfig["zed.bin"]="~/work/path-extra/zed"
|
|
fi
|
|
|
|
# arch case
|
|
if [[ "$DISTRO" == "arch" ]]; then
|
|
myconfig["zed.bin"]="/usr/sbin/zeditor"
|
|
fi
|
|
|
|
reply_config=${myconfig["$1"]}
|
|
}
|
|
|
|
# auto start hyprland in tty
|
|
if [[ $TERM == "linux" ]]; then
|
|
sudo loadkeys de
|
|
fi
|
|
|
|
|
|
if [[ $- == *i* ]]; then
|
|
source $CONFIG_DIR/mods/bashrc-common
|
|
fi
|