nixos/Makefile
Evie Litherland-Smith 2cc371ed63 Switch Makefile back to https repo urls
Update directive will update repo urls before pulling
2023-05-28 20:21:16 +01:00

56 lines
1.8 KiB
Makefile

$(eval HOSTNAME=$(shell hostname))
NIXOS_REPO := https://git.xenia.me.uk/xenia/nixos.git
NVIM_REPO := https://git.xenia.me.uk/xenia/nvim.git
HYPR_REPO := https://git.xenia.me.uk/xenia/hyprland.git
WAYBAR_REPO := https://git.xenia.me.uk/xenia/waybar.git
HOMEMANAGER_CONFIG := $(PWD)/home/$(HOSTNAME)/$(USER).nix
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
BIN_DIR := $(HOME)/.local/bin
HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager
.PHONY: default update clean nixos home nvim hypr waybar
default: nvim hypr waybar
[ -e /etc/nixos/ ] && make nixos || make home
update: $(CONFIG_DIR)/nvim $(CONFIG_DIR)/hypr $(CONFIG_DIR)/waybar
git -C $(CONFIG_DIR)/nvim remote set-url origin $(NVIM_REPO)
git -C $(CONFIG_DIR)/hypr remote set-url origin $(HYPR_REPO)
git -C $(CONFIG_DIR)/waybar remote set-url origin $(WAYBAR_REPO)
for repo in $?; do git -C $$repo pull --ff-only; done
clean:
[ -e $(HOMEMANAGER_CONFIG_DIR) ] && rm -rf $(HOMEMANAGER_CONFIG_DIR)
nixos: /etc/nixos/config
home: $(HOMEMANAGER_CONFIG_DIR)/home.nix
nvim: $(CONFIG_DIR)/nvim
hypr: $(CONFIG_DIR)/hypr
waybar: $(CONFIG_DIR)/waybar
/nix:
command -v nix > /dev/null || echo "Install nix package manager before continuing"; exit 1
/etc/nixos/config:
sudo git clone $(NIXOS_REPO) $@
$(HOMEMANAGER_CONFIG_DIR)/home.nix: $(HOMEMANAGER_CONFIG_DIR) /nix
[ -f $(HOMEMANAGER_CONFIG) ] || touch $(HOMEMANAGER_CONFIG)
ln -s $(HOMEMANAGER_CONFIG) $@
$(CONFIG_DIR) $(HOMEMANAGER_CONFIG_DIR) $(BIN_DIR):
mkdir -p $@
$(CONFIG_DIR)/nvim: $(CONFIG_DIR)
[ -d $@ ] && touch $@ || git clone $(NVIM_REPO) $@
$(CONFIG_DIR)/hypr: $(CONFIG_DIR)
[ -d $@ ] && touch $@ || git clone $(HYPR_REPO) $@ | continue
$(CONFIG_DIR)/waybar: $(CONFIG_DIR)
[ -d $@ ] && touch $@ || git clone $(WAYBAR_REPO) $@ | continue