nixos/Makefile

72 lines
2.3 KiB
Makefile
Raw Normal View History

CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
FONT_DIR := $(HOME)/.local/share/fonts
ZSH_DIR := $(if $(ZSH), $(ZSH), $(HOME)/.oh-my-zsh)
SSH_DIR := $(HOME)/.ssh
ZSH_CUSTOM_DIR := $(if $(ZSH_CUSTOM), $(ZSH_CUSTOM), $(ZSH_DIR)/custom)
HOME_ITEMS := $(wildcard home/*)
HOME_TARGETS := $(HOME_ITEMS:home/%=$(HOME)/.%)
CONFIG_ITEMS := $(wildcard config/*)
CONFIG_TARGETS := $(CONFIG_ITEMS:config/%=$(CONFIG_DIR)/%)
ZSH_ITEMS := $(wildcard ohmyzsh/*.zsh)
ZSH_TARGETS := $(ZSH_ITEMS:ohmyzsh/%.zsh=$(ZSH_CUSTOM_DIR)/%.zsh)
SSH_ITEMS := $(wildcard ssh/*)
SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%)
PACKER_REPO := https://github.com/wbthomason/packer.nvim
PACKER_DIR := $(HOME)/.local/share/nvim/site/pack/packer/start/packer.nvim
POWERLEVEL_REPO := https://github.com/romkatv/powerlevel10k.git
POWERLEVEL_DIR := $(ZSH_CUSTOM_DIR)/themes/powerlevel10k
TPM_REPO := https://github.com/tmux-plugins/tpm
TPM_DIR := $(HOME)/.tmux/plugins/tpm
2023-02-11 10:02:36 +00:00
.PHONY: all clean link unlink install uninstall pacman
all: link install
clean: unlink uninstall
2023-02-10 08:14:10 +00:00
link: $(HOME_TARGETS) $(CONFIG_TARGETS) $(SSH_TARGETS) $(HOME)/.ssh/sockets
unlink:
for link in $(HOME_TARGETS); do rm "$$link"; done
2023-01-30 22:30:02 +00:00
for link in $(CONFIG_TARGETS); do rm "$$link"; done
for link in $(SSH_TARGETS); do rm "$$link"; done
rmdir $(HOME)/.ssh/sockets
2023-02-11 10:02:36 +00:00
install: $(ZSH_DIR) $(POWERLEVEL_DIR) $(ZSH_TARGETS) $(PACKER_DIR) $(TPM_DIR)
python3 -m pip list | grep -E "libtmux.*0\.16\.1" > /dev/null ||\
python3 -m pip install --user libtmux==0.16.1
uninstall:
rm -rf $(ZSH_DIR)
rm -rf $(PACKER_DIR)
2023-02-11 10:02:36 +00:00
pacman:
sort -h pkglist.txt -o pkglist.txt
pacman -T - < pkglist.txt ||\
sudo pacman --needed -S - < pkglist.txt
$(HOME_TARGETS): $(HOME)/.%: home/%
$(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/%
$(ZSH_TARGETS): $(ZSH_CUSTOM_DIR)/%.zsh: ohmyzsh/%.zsh
$(SSH_TARGETS): $(SSH_DIR)/%: ssh/%
$(HOME_TARGETS) $(CONFIG_TARGETS) $(ZSH_TARGETS) $(SSH_TARGETS):
ln -s $(PWD)/$? $@
$(PACKER_DIR):
git clone --depth 1 $(PACKER_REPO) $@
$(POWERLEVEL_DIR): $(ZSH_DIR)
git clone --depth 1 $(POWERLEVEL_REPO) $@
$(TPM_DIR):
git clone --depth 1 $(TPM_REPO) $@
$(ZSH_DIR):
sh -c "$$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
$(CONFIG_DIR) $(SSH_DIR) $(HOME)/.ssh/sockets:
mkdir -p $@