2023-04-18 08:44:46 +01:00
|
|
|
$(eval HOSTNAME=$(shell hostname))
|
2023-06-17 10:27:02 +01:00
|
|
|
HOMEMANAGER_CONFIG := $(PWD)/machines/$(HOSTNAME)/$(USER).nix
|
2023-01-27 11:29:28 +00:00
|
|
|
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
|
2023-05-04 12:29:07 +01:00
|
|
|
HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager
|
2023-01-27 11:29:28 +00:00
|
|
|
|
2023-06-21 08:23:48 +01:00
|
|
|
.PHONY: default all clean nixos home home-init /etc/nixos/config nvim
|
2023-01-27 11:29:28 +00:00
|
|
|
|
2023-06-20 15:26:07 +01:00
|
|
|
default:
|
2023-05-31 20:37:10 +01:00
|
|
|
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
|
2023-06-20 15:26:07 +01:00
|
|
|
|
|
|
|
all: default nvim
|
2023-05-31 20:37:10 +01:00
|
|
|
bat cache --build
|
2023-02-10 08:13:48 +00:00
|
|
|
|
2023-03-05 22:16:16 +00:00
|
|
|
clean:
|
2023-06-16 14:33:04 +01:00
|
|
|
[ -e /etc/nixos ] && sudo rm /etc/nixos/config || rm -rf $(HOMEMANAGER_CONFIG_DIR)
|
2023-03-04 09:08:14 +00:00
|
|
|
|
2023-05-25 10:00:49 +01:00
|
|
|
nixos: /etc/nixos/config
|
2023-06-17 10:27:02 +01:00
|
|
|
grep -i ./config/machines/$$(hostname) /etc/nixos/configuration.nix && sudo nixos-rebuild switch
|
2023-05-31 10:04:48 +01:00
|
|
|
|
2023-06-21 08:23:48 +01:00
|
|
|
home: $(HOMEMANAGER_CONFIG_DIR)/home.nix $(CONFIG_DIR)/nixpkgs/config.nix $(HOME)/.nix-defexpr/channels/home-manager
|
2023-06-19 07:57:46 +01:00
|
|
|
nix-shell -p home-manager --run "home-manager switch"
|
2023-05-16 09:58:47 +01:00
|
|
|
|
2023-06-21 08:23:48 +01:00
|
|
|
home-init: $(HOMEMANAGER_CONFIG_DIR)/home.nix $(CONFIG_DIR)/nixpkgs/config.nix $(HOME)/.nix-defexpr/channels/home-manager
|
|
|
|
nix-shell '<home-manager>' -A install
|
|
|
|
|
2023-05-16 09:58:47 +01:00
|
|
|
/etc/nixos/config:
|
2023-05-31 11:18:45 +01:00
|
|
|
sudo rsync -avz --exclude-from=.rsyncignore --filter=':- .gitignore' --delete-during --delete-excluded ./ $@
|
2023-05-16 09:58:47 +01:00
|
|
|
|
2023-06-18 10:47:48 +01:00
|
|
|
nvim: $(CONFIG_DIR)/nvim
|
|
|
|
|
2023-05-31 20:37:10 +01:00
|
|
|
$(HOMEMANAGER_CONFIG):
|
|
|
|
touch $@
|
2023-05-04 12:29:07 +01:00
|
|
|
|
2023-05-31 20:37:10 +01:00
|
|
|
$(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-21 08:23:48 +01:00
|
|
|
$(CONFIG_DIR)/nixpkgs/config.nix:
|
|
|
|
echo '{ allowUnfree = true; }' > $@
|
|
|
|
|
|
|
|
$(HOME)/.nix-defexpr/channels/home-manager:
|
|
|
|
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
|
|
|
|
nix-channel --update
|
|
|
|
|
2023-06-18 10:47:48 +01:00
|
|
|
$(CONFIG_DIR)/nvim: $(CONFIG_DIR)
|
2023-06-19 14:33:05 +01:00
|
|
|
-nix-shell -p git --run "git clone https://git.xenia.me.uk/xenia/nvim.git $@"
|
2023-06-20 13:35:45 +01:00
|
|
|
-nix-shell -p git --run "git -C $@ pull --ff-only"
|
2023-06-18 10:47:48 +01:00
|
|
|
|
2023-05-31 20:37:10 +01:00
|
|
|
$(CONFIG_DIR) $(HOMEMANAGER_CONFIG_DIR):
|
|
|
|
mkdir -p $@
|