nixos/Makefile

52 lines
1.9 KiB
Makefile
Raw Normal View History

$(eval HOSTNAME=$(shell hostname))
CONFIG_REPO := git@gitlab.com:elitherl/nixos.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 legacy lclean
default:
[ -e /etc/nixos/ ] && make nixos || make home
all: install nixos home
clean:
2023-04-11 10:14:55 +01:00
rm -rf $(HOME)/.local/share/nvim
rm -rf $(HOME)/.local/state/nvim
[ -e $(HOMEMANAGER_CONFIG_DIR) ] && rm -rf $(HOMEMANAGER_CONFIG_DIR)
/nix:
command -v nix > /dev/null && echo "Nix already installed" || ./scripts/installers/nix.sh --daemon
/etc/nixos/config:
sudo git clone $(CONFIG_REPO) /etc/nixos/config
nixos: /etc/nixos/config
home: $(HOMEMANAGER_CONFIG_DIR)/home.nix
$(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
legacy: $(CONFIG_DIR) $(BIN_DIR)
fc-list | grep -iE "(fira.*code)*(nerd.*font)" > /dev/null || ./scripts/installers/firacode.sh && fc-cache
command -v nvim > /dev/null || ./scripts/installers/nvim.sh
[ -e $(CONFIG_DIR)/nvim ] || ln -s $(PWD)/home/tui/config/nvim $(CONFIG_DIR)/
command -v starship > /dev/null || ./scripts/installers/starship.sh --yes --bin-dir $(BIN_DIR)
[ -e $(CONFIG_DIR)/starship.toml ] || ln -s $(PWD)/home/env/config/starship.toml $(CONFIG_DIR)/
command -v direnv > /dev/null || bin_path="$(BIN_DIR)" ./scripts/installers/direnv.sh
lclean: clean
[ -e $(HOME)/.fonts/FiraCode ] && rm -rf $(HOME)/.fonts/FiraCode
[ -e $(BIN_DIR)/nvim ] && rm $(BIN_DIR)/nvim
[ -e $(CONFIG_DIR)/nvim ] && rm $(CONFIG_DIR)/nvim
[ -e $(BIN_DIR)/starship ] && rm $(BIN_DIR)/starship
[ -e $(CONFIG_DIR)/starship.toml ] && rm $(CONFIG_DIR)/starship.toml
[ -e $(BIN_DIR)/direnv ] && rm $(BIN_DIR)/direnv