nixos/Makefile

48 lines
1.4 KiB
Makefile
Raw Normal View History

$(eval HOSTNAME=$(shell hostname))
NIXOS_CONFIG := $(PWD)/nixos/$(HOSTNAME)-$(USER).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 check directories link install
default: directories link
all: default install
clean:
2023-01-30 22:30:02 +00:00
for link in $(CONFIG_TARGETS); do rm "$$link"; done
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
directories: $(CONFIG_DIR) $(SSH_DIR) $(CONFIG_DIR)/home-manager
$(CONFIG_DIR) $(SSH_DIR) $(CONFIG_DIR)/home-manager:
mkdir -p $@
link: $(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc
$(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/%
2023-03-31 13:14:08 +01:00
$(SSH_DIR)/config.d: $(SSH_DIR)/%: ssh/%
$(HOME)/.inputrc: $(HOME)/%: %
$(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc:
ln -s $(PWD)/$? $@
2023-02-25 08:46:56 +00:00
$(CONFIG_DIR)/home-manager/home.nix:
ln -s $(HOMEMANAGER_CONFIG) $@
install: /nix /etc/nixos/$(HOSTNAME)-$(USER).nix
/etc/nixos/$(HOSTNAME)-$(USER).nix:
[ -f $(NIXOS_CONFIG) ] || touch $(NIXOS_CONFIG)
sudo ln -s $(NIXOS_CONFIG) $@
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