-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
133 lines (107 loc) · 3.76 KB
/
Copy pathmakefile
File metadata and controls
133 lines (107 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
SHELL := /bin/bash
TARGET ?= $(HOME)
# System-level target used for privileged packages (for example `etc`).
SYSTEM_TARGET ?= /etc
STOW ?= stow
STOW_FLAGS ?= --verbose --target="$(TARGET)"
# Override with `SUDO=doas` if you prefer a different privilege escalator.
SUDO ?= sudo
# Shared package groups
BASE_PACKAGES := \
bin git nvim stow tmux vim yazi zathura zsh eza sxiv emacs
MEDIA_PACKAGES := \
mpd ncmpcpp
# Profiles
PACKAGES_fedora-hyprland := \
$(BASE_PACKAGES) $(MEDIA_PACKAGES) \
hypr waybar wofi swaync foot swappy autostart
PACKAGES_kali-i3 := \
$(BASE_PACKAGES) \
i3 rofi alacritty dunst x11 wallpapers
PACKAGES_macos-aerospace := \
$(BASE_PACKAGES) \
aerospace ghostty karabiner
PACKAGES_arch-desktop := \
$(BASE_PACKAGES) $(MEDIA_PACKAGES)
# Optional system packages per profile.
# These are stowed to SYSTEM_TARGET with sudo in the same make command.
SYSTEM_PACKAGES_fedora-hyprland := etc
SYSTEM_PACKAGES_macos-aerospace :=
SYSTEM_PACKAGES_kali-i3 :=
SYSTEM_PACKAGES_arch-desktop :=
PROFILES := fedora-hyprland macos-aerospace kali-i3 arch-desktop
.PHONY: help list-profiles list-packages \
fedora-hyprland unfedora-hyprland \
macos-aerospace unmacos-aerospace \
kali-i3 unkali-i3 \
arch-desktop unarch-desktop \
_apply-profile _unapply-profile \
everything uneverything all delete
help:
@printf "Usage:\n"
@printf " make <profile> Install profile packages\n"
@printf " make un<profile> Remove profile packages\n"
@printf " (Profiles can also include system files, applied automatically with sudo)\n"
@printf " make list-profiles Show available profiles\n"
@printf " make list-packages PROFILE=<name> Show packages in profile\n"
@printf "\nProfiles: $(PROFILES)\n"
list-profiles:
@printf "%s\n" $(PROFILES)
list-packages:
@if [ -z "$(PROFILE)" ]; then \
printf "Set PROFILE. Example: make list-packages PROFILE=fedora-hyprland\n"; \
exit 1; \
fi
@printf "%s\n" $(PACKAGES_$(PROFILE))
_apply-profile:
@if [ -z "$(PROFILE)" ]; then \
printf "PROFILE is required\n"; \
exit 1; \
fi
# 1) User-level dotfiles -> $(TARGET) (usually $HOME)
$(STOW) $(STOW_FLAGS) --restow $(PACKAGES_$(PROFILE))
# 2) System-level dotfiles -> $(SYSTEM_TARGET) (for example /etc), if configured
@sys_pkgs='$(SYSTEM_PACKAGES_$(PROFILE))'; \
if [ -n "$$sys_pkgs" ]; then \
$(SUDO) $(STOW) --dir="$(CURDIR)" --target="$(SYSTEM_TARGET)" --restow $$sys_pkgs; \
fi
_unapply-profile:
@if [ -z "$(PROFILE)" ]; then \
printf "PROFILE is required\n"; \
exit 1; \
fi
# Reverse operation of _apply-profile for user-level packages.
$(STOW) $(STOW_FLAGS) --delete $(PACKAGES_$(PROFILE))
# Reverse operation of _apply-profile for system-level packages.
@sys_pkgs='$(SYSTEM_PACKAGES_$(PROFILE))'; \
if [ -n "$$sys_pkgs" ]; then \
$(SUDO) $(STOW) --dir="$(CURDIR)" --target="$(SYSTEM_TARGET)" --delete $$sys_pkgs; \
fi
# Public profile targets. Add a new profile by defining:
# - PACKAGES_<profile>
# - optional SYSTEM_PACKAGES_<profile>
# - a pair of targets mirroring the pattern below.
fedora-hyprland: PROFILE=fedora-hyprland
fedora-hyprland: _apply-profile
unfedora-hyprland: PROFILE=fedora-hyprland
unfedora-hyprland: _unapply-profile
macos-aerospace: PROFILE=macos-aerospace
macos-aerospace: _apply-profile
unmacos-aerospace: PROFILE=macos-aerospace
unmacos-aerospace: _unapply-profile
kali-i3: PROFILE=kali-i3
kali-i3: _apply-profile
unkali-i3: PROFILE=kali-i3
unkali-i3: _unapply-profile
arch-desktop: PROFILE=arch-desktop
arch-desktop: _apply-profile
unarch-desktop: PROFILE=arch-desktop
unarch-desktop: _unapply-profile
# Convenience target: install or remove every package folder.
everything:
$(STOW) $(STOW_FLAGS) --restow */
uneverything:
$(STOW) $(STOW_FLAGS) --delete */
# Backward-compatibility aliases.
all: everything
delete: uneverything