39 lines
1.1 KiB
Makefile
39 lines
1.1 KiB
Makefile
$(eval HOSTNAME=$(shell hostname))
|
|
HOMEMANAGER_CONFIG := $(PWD)/home/$(HOSTNAME)/$(USER).nix
|
|
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
|
|
HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager
|
|
SUBMODULES := $(CONFIG_DIR)/nvim $(CONFIG_DIR)/hypr $(CONFIG_DIR)/waybar
|
|
|
|
.PHONY: default clean nixos home
|
|
|
|
default: $(SUBMODULES)
|
|
command -v nix > /dev/null || exit 1
|
|
[ -e /etc/nixos/ ] && make nixos || make home
|
|
bat cache --build
|
|
|
|
clean:
|
|
-[ -e /etc/nixos ] && sudo rm /etc/nixos/config || rm -rf $(HOMEMANAGER_CONFIG_DIR)
|
|
-rm $(SUBMODULES)
|
|
|
|
nixos: /etc/nixos/config
|
|
sudo nixos-rebuild switch
|
|
|
|
home: $(HOMEMANAGER_CONFIG_DIR)/home.nix
|
|
home-manager switch
|
|
|
|
/etc/nixos/config:
|
|
sudo rsync -avz --exclude-from=.rsyncignore --filter=':- .gitignore' --delete-during --delete-excluded ./ $@
|
|
|
|
$(HOMEMANAGER_CONFIG):
|
|
touch $@
|
|
|
|
$(HOMEMANAGER_CONFIG_DIR)/home.nix: $(HOMEMANAGER_CONFIG) $(HOMEMANAGER_CONFIG_DIR) /nix
|
|
-ln -s $(HOMEMANAGER_CONFIG) $@
|
|
|
|
$(CONFIG_DIR) $(HOMEMANAGER_CONFIG_DIR):
|
|
mkdir -p $@
|
|
|
|
$(SUBMODULES): $(CONFIG_DIR)/%: %
|
|
$(SUBMODULES):
|
|
-ln -s $$(readlink -f $?) $(CONFIG_DIR)/
|