nixos/Makefile

39 lines
1.1 KiB
Makefile
Raw Normal View History

$(eval HOSTNAME=$(shell hostname))
HOMEMANAGER_CONFIG := $(PWD)/machines/$(HOSTNAME)/$(USER).nix
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager
2023-06-18 10:47:48 +01:00
.PHONY: default clean nixos home /etc/nixos/config nvim
2023-06-18 10:47:48 +01:00
default: nvim
command -v nix > /dev/null || exit 1
2023-06-19 06:24:21 +01:00
if [ -e /etc/nixos/ ]; then make nixos; else make home; fi
bat cache --build
clean:
2023-06-16 14:33:04 +01:00
[ -e /etc/nixos ] && sudo rm /etc/nixos/config || rm -rf $(HOMEMANAGER_CONFIG_DIR)
nixos: /etc/nixos/config
grep -i ./config/machines/$$(hostname) /etc/nixos/configuration.nix && sudo nixos-rebuild switch
2023-05-31 10:04:48 +01:00
home: $(HOMEMANAGER_CONFIG_DIR)/home.nix
home-manager switch
/etc/nixos/config:
sudo rsync -avz --exclude-from=.rsyncignore --filter=':- .gitignore' --delete-during --delete-excluded ./ $@
2023-06-18 10:47:48 +01:00
nvim: $(CONFIG_DIR)/nvim
$(HOMEMANAGER_CONFIG):
touch $@
$(HOMEMANAGER_CONFIG_DIR)/home.nix: $(HOMEMANAGER_CONFIG) $(HOMEMANAGER_CONFIG_DIR) /nix
-ln -s $(HOMEMANAGER_CONFIG) $@
2023-05-04 13:02:05 +01:00
2023-06-18 10:47:48 +01:00
$(CONFIG_DIR)/nvim: $(CONFIG_DIR)
-git clone https://git.xenia.me.uk/xenia/nvim.git $@
touch $@
$(CONFIG_DIR) $(HOMEMANAGER_CONFIG_DIR):
mkdir -p $@