2023-04-18 08:44:46 +01:00
|
|
|
$(eval HOSTNAME=$(shell hostname))
|
2023-04-18 10:01:37 +01:00
|
|
|
NIXOS_CONFIG := $(PWD)/nixos/$(HOSTNAME)-$(USER).nix
|
|
|
|
HOMEMANAGER_CONFIG := $(PWD)/home/$(HOSTNAME)-$(USER).nix
|
2023-01-27 11:29:28 +00:00
|
|
|
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
|
2023-02-09 08:59:12 +00:00
|
|
|
SSH_DIR := $(HOME)/.ssh
|
2023-01-27 11:29:28 +00:00
|
|
|
|
|
|
|
CONFIG_ITEMS := $(wildcard config/*)
|
|
|
|
CONFIG_TARGETS := $(CONFIG_ITEMS:config/%=$(CONFIG_DIR)/%)
|
2023-02-09 08:59:12 +00:00
|
|
|
SSH_ITEMS := $(wildcard ssh/*)
|
|
|
|
SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%)
|
2023-01-27 11:29:28 +00:00
|
|
|
|
2023-04-18 16:42:34 +01:00
|
|
|
.PHONY: default all clean check directories link home install
|
2023-02-09 16:05:24 +00:00
|
|
|
|
2023-03-28 09:34:10 +01:00
|
|
|
default: directories link
|
2023-03-01 17:46:07 +00:00
|
|
|
|
2023-04-18 16:42:34 +01:00
|
|
|
all: default install home
|
2023-02-10 08:13:48 +00:00
|
|
|
|
2023-03-05 22:16:16 +00:00
|
|
|
clean:
|
2023-01-30 22:30:02 +00:00
|
|
|
for link in $(CONFIG_TARGETS); do rm "$$link"; done
|
2023-02-10 08:13:48 +00:00
|
|
|
for link in $(SSH_TARGETS); do rm "$$link"; done
|
2023-04-11 10:14:55 +01:00
|
|
|
rm $(HOME)/.inputrc
|
|
|
|
rm -rf $(HOME)/.local/share/nvim
|
2023-02-09 08:53:40 +00:00
|
|
|
|
2023-04-18 16:42:34 +01:00
|
|
|
directories: $(CONFIG_DIR) $(SSH_DIR)
|
2023-02-09 08:53:40 +00:00
|
|
|
|
2023-04-18 08:44:46 +01:00
|
|
|
$(CONFIG_DIR) $(SSH_DIR) $(CONFIG_DIR)/home-manager:
|
2023-03-15 07:47:37 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
2023-04-18 16:42:34 +01:00
|
|
|
link: $(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc
|
2023-03-04 09:08:14 +00:00
|
|
|
|
2023-01-27 11:29:28 +00:00
|
|
|
$(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/%
|
2023-03-31 13:14:08 +01:00
|
|
|
$(SSH_DIR)/config.d: $(SSH_DIR)/%: ssh/%
|
|
|
|
$(HOME)/.inputrc: $(HOME)/%: %
|
2023-04-05 11:16:41 +01:00
|
|
|
$(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc:
|
2023-03-04 09:08:14 +00:00
|
|
|
ln -s $(PWD)/$? $@
|
2023-02-25 08:46:56 +00:00
|
|
|
|
2023-04-18 16:42:34 +01:00
|
|
|
home: $(CONFIG_DIR)/home-manager/home.nix
|
|
|
|
|
|
|
|
$(CONFIG_DIR)/home-manager/home.nix: $(CONFIG_DIR)/home-manager
|
2023-04-18 10:01:37 +01:00
|
|
|
ln -s $(HOMEMANAGER_CONFIG) $@
|
2023-04-18 08:44:46 +01:00
|
|
|
|
2023-04-18 10:01:37 +01:00
|
|
|
install: /nix /etc/nixos/$(HOSTNAME)-$(USER).nix
|
|
|
|
|
|
|
|
/etc/nixos/$(HOSTNAME)-$(USER).nix:
|
|
|
|
[ -f $(NIXOS_CONFIG) ] || touch $(NIXOS_CONFIG)
|
|
|
|
sudo ln -s $(NIXOS_CONFIG) $@
|
2023-03-02 16:08:39 +00:00
|
|
|
|
2023-04-11 10:14:55 +01:00
|
|
|
/nix:
|
|
|
|
command -v nix > /dev/null && echo "Nix already installed" || sh <(curl -L https://nixos.org/nix/install) --daemon
|