nixos/Makefile

70 lines
2.2 KiB
Makefile

CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
SSH_DIR := $(HOME)/.ssh
THEMES_DIR := $(HOME)/.themes
CONFIG_ITEMS := $(wildcard config/*)
CONFIG_TARGETS := $(CONFIG_ITEMS:config/%=$(CONFIG_DIR)/%)
SSH_ITEMS := $(wildcard ssh/*)
SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%)
THEMES_ITEMS := $(wildcard themes/*)
THEMES_TARGETS := $(THEMES_ITEMS:themes/%=$(THEMES_DIR)/%)
LAZY_REPO := https://github.com/folke/lazy.nvim.git
PYENV_DIR := $(if $(PYENV_ROOT), $(PYENV_ROOT), $(HOME)/.pyenv)
.PHONY: default all clean check directories link configure install
default: directories link configure
all: default install
clean:
for link in $(CONFIG_TARGETS); do rm "$$link"; done
for link in $(SSH_TARGETS); do rm "$$link"; done
for link in $(THEMES_TARGETS); do rm "$$link"; done
rm -rf $(LAZY_DIR)
rm $(HOME)/.profile
rm $(HOME)/.bashrc
rm $(HOME)/.zshrc
rmdir $(HOME)/.ssh/sockets
rm -rf config/nvim/.venv
check:
echo "Placeholder"
directories: $(CONFIG_DIR) $(SSH_DIR) $(THEMES_DIR) $(HOME)/.ssh/sockets $(HOME)/.local/bin
$(CONFIG_DIR) $(SSH_DIR) $(THEMES_DIR) $(HOME)/.ssh/sockets $(HOME)/.local/bin:
mkdir -p $@
link: $(CONFIG_TARGETS) $(SSH_TARGETS) $(THEMES_TARGETS) $(HOME)/.profile $(HOME)/.bashrc $(HOME)/.zshrc
$(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/%
$(SSH_TARGETS): $(SSH_DIR)/%: ssh/%
$(THEMES_TARGETS): $(THEMES_DIR)/%: themes/%
$(HOME)/.profile: $(HOME)/%: %
$(HOME)/.bashrc: $(HOME)/%: %
$(HOME)/.zshrc: $(HOME)/%: %
$(CONFIG_TARGETS) $(SSH_TARGETS) $(THEMES_TARGETS) $(HOME)/.profile $(HOME)/.bashrc $(HOME)/.zshrc:
ln -s $(PWD)/$? $@
configure: config/git/user_email config/nvim/.venv
config/git/user_email:
echo "Missing user_email; Add your email to $$(readlink -f config/git)/user_email"
config/nvim/.venv:
python3 -m venv $@
$@/bin/python3 -m pip install -U pip wheel
$@/bin/python3 -m pip install --use-pep517 pynvim
install: $(LAZY_DIR)
command -v direnv > /dev/null || bin_path=$(HOME)/.local/bin bash packages/direnv.sh
command -v pipx > /dev/null || bash packages/pipx.sh
command -v poetry > /dev/null || python3 packages/poetry.py
command -v pyenv > /dev/null || bash packages/pyenv.sh
command -v starship > /dev/null || bash packages/starship.sh
$(LAZY_DIR):
git clone --depth 1 $(LAZY_REPO) $@