nixos/Makefile
2023-02-09 08:59:12 +00:00

64 lines
2 KiB
Makefile

LOCAL_BIN := $(HOME)/.local/bin
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)
ZSH_CUSTOM_DIR := $(if $(ZSH_CUSTOM), $(ZSH_CUSTOM), $(ZSH_DIR)/custom)
SSH_DIR := $(HOME)/.ssh
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
.PHONY := install clean home packages config zsh ssh nvim
install: home packages config zsh ssh nvim
clean:
for link in $(HOME_TARGETS); do rm "$$link"; done
for link in $(CONFIG_TARGETS); do rm "$$link"; done
rm $(HOME)/.ssh/config
rm -rf $(PACKER_DIR)
rm -rf $(ZSH_DIR)
home: $(HOME_TARGETS)
packages:
pacman -T - < pkglist.txt || sudo pacman --needed -S - < pkglist.txt
config: $(CONFIG_TARGETS)
zsh: $(ZSH_DIR) $(POWERLEVEL_DIR) $(ZSH_TARGETS)
ssh: $(SSH_TARGETS) $(HOME)/.ssh/sockets
nvim: $(PACKER_DIR)
$(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)/$? $$(dirname $@)
$(PACKER_DIR):
git clone --depth 1 $(PACKER_REPO) $@
$(ZSH_DIR):
sh -c "$$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
$(POWERLEVEL_DIR): $(ZSH_DIR)
git clone --depth 1 $(POWERLEVEL_REPO) $@
$(LOCAL_BIN) $(CONFIG_DIR) $(FONT_DIR) $(SSH_DIR) $(HOME)/.ssh/sockets:
mkdir -p $@