40 lines
1.1 KiB
Makefile
40 lines
1.1 KiB
Makefile
$(eval HOSTNAME=$(shell hostname))
|
|
NIXOS_REPO := git@git.xenia.me.uk:xenia/nixos.git
|
|
NVIM_REPO := git@git.xenia.me.uk:xenia/nvim.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 all clean nixos home nvim
|
|
|
|
default:
|
|
[ -e /etc/nixos/ ] && make nixos || make home
|
|
|
|
all: default nvim
|
|
|
|
clean:
|
|
[ -e $(HOMEMANAGER_CONFIG_DIR) ] && rm -rf $(HOMEMANAGER_CONFIG_DIR)
|
|
|
|
nixos: /etc/nixos/config
|
|
|
|
home: $(HOMEMANAGER_CONFIG_DIR)/home.nix
|
|
|
|
nvim: $(CONFIG_DIR)/nvim
|
|
|
|
/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)
|
|
git clone $(NVIM_REPO) $@
|