nixos/Makefile

40 lines
1.1 KiB
Makefile
Raw Normal View History

$(eval HOSTNAME=$(shell hostname))
2023-05-19 08:57:42 +01:00
NIXOS_REPO := https://git.xenia.me.uk/xenia/nixos.git
NVIM_REPO := https://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 $@
2023-05-04 13:02:05 +01:00
$(CONFIG_DIR)/nvim: $(CONFIG_DIR)
git clone $(NVIM_REPO) $@