52 lines
1.3 KiB
Makefile
52 lines
1.3 KiB
Makefile
$(eval HOSTNAME=$(shell hostname))
|
|
NIXOS_CONFIG := $(PWD)/nixos/$(HOSTNAME).nix
|
|
HOMEMANAGER_CONFIG := $(PWD)/home/$(HOSTNAME)-$(USER).nix
|
|
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
|
|
SSH_DIR := $(HOME)/.ssh
|
|
|
|
CONFIG_ITEMS := $(wildcard config/*)
|
|
CONFIG_TARGETS := $(CONFIG_ITEMS:config/%=$(CONFIG_DIR)/%)
|
|
SSH_ITEMS := $(wildcard ssh/*)
|
|
SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%)
|
|
|
|
.PHONY: default all clean link home nixos install
|
|
|
|
default: install
|
|
|
|
all: nixos
|
|
|
|
clean:
|
|
rm $(SSH_DIR)/config.d
|
|
rm $(HOME)/.inputrc
|
|
rm -rf $(HOME)/.local/share/nvim
|
|
sudo rm /etc/nixos/$(HOSTNAME).nix
|
|
|
|
$(CONFIG_DIR) $(SSH_DIR) $(CONFIG_DIR)/home-manager:
|
|
mkdir -p $@
|
|
|
|
link: $(SSH_DIR)/config.d $(HOME)/.inputrc
|
|
|
|
$(SSH_DIR)/config.d: $(SSH_DIR)/%: ssh/%
|
|
$(HOME)/.inputrc: $(HOME)/%: %
|
|
$(SSH_DIR)/config.d $(HOME)/.inputrc:
|
|
ln -s $(PWD)/$? $@
|
|
|
|
legacy:
|
|
echo "TODO"
|
|
|
|
home: $(CONFIG_DIR)/home-manager/home.nix
|
|
|
|
$(CONFIG_DIR)/home-manager/home.nix: $(CONFIG_DIR)/home-manager
|
|
ln -s $(HOMEMANAGER_CONFIG) $@
|
|
|
|
nixos: /etc/nixos/$(HOSTNAME).nix
|
|
|
|
/etc/nixos/$(HOSTNAME).nix: /nix
|
|
[ -f $(NIXOS_CONFIG) ] || touch $(NIXOS_CONFIG)
|
|
sudo ln -s $(NIXOS_CONFIG) $@
|
|
|
|
install: /nix
|
|
|
|
/nix:
|
|
command -v nix > /dev/null && echo "Nix already installed" || ./scripts/install_nix.sh --daemon
|