-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
121 lines (105 loc) · 2.92 KB
/
Rakefile
File metadata and controls
121 lines (105 loc) · 2.92 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
here = File.dirname(__FILE__)
bin = File.join(here, 'bin')
is_linux = RbConfig::CONFIG['host_os'] =~ /linux/i
is_mac = RbConfig::CONFIG['host_os'] =~ /darwin/i
# These directories will be created in the target
dirs = FileList[
'.ssh',
'.gnupg',
'.config/kitty',
'.config/Code/User',
'.local/bin',
]
# These will each be installed into the target
symlinks = FileList[
'.bash',
'.bashrc',
'.bash_profile',
'.profile',
'.doom.d',
'.screenrc',
'.tmux.conf',
'.spacemacs.d',
'.aerospace.toml',
'.gitconfig',
'.gitconfig-fbinfra',
'.dircolors',
'.vimrc',
'.zshrc',
'.gnupg/gpg-agent.conf',
'.gnupg/gpg.conf',
'.config/kitty/kitty.conf',
'.config/Code/User/settings.json',
]
# Linux-only symlinks (X11, desktop entries)
linux_symlinks = FileList[
'.Xresources',
'.local/share/applications/org-protocol.desktop',
]
# Systemd units to enable
systemd_units = [
'keybase.service',
'kbfs.service',
'syncthing.service',
]
task :install, [:prefix] do |t, args|
args.with_defaults(:prefix => "target")
mkdir_p args.prefix
dirs.each do |d|
dest = File.join(args.prefix, d)
mkdir_p dest
end
symlinks.each do |f|
from = File.join(here, f)
to = File.join(args.prefix, f)
rm_f(to)
File.exist?(from) and ln_sf(from, to)
end
if is_linux
mkdir_p File.join(args.prefix, '.local/share/applications')
linux_symlinks.each do |f|
from = File.join(here, f)
to = File.join(args.prefix, f)
rm_f(to)
File.exist?(from) and ln_sf(from, to)
end
systemd_dir = '.config/systemd/user'
prefix_systemd_dir = File.join(args.prefix, systemd_dir)
mkdir_p prefix_systemd_dir
local_systemd_dir = File.join(here, systemd_dir)
Dir.glob(File.join(local_systemd_dir, '*')).each do |f|
to = File.join(prefix_systemd_dir, File.basename(f))
ln_sf(f, to)
end
autostart_dir = '.config/autostart'
prefix_autostart_dir = File.join(args.prefix, autostart_dir)
mkdir_p prefix_autostart_dir
local_autostart_dir = File.join(here, autostart_dir)
Dir.glob(File.join(local_autostart_dir, '*')).each do |f|
to = File.join(prefix_autostart_dir, File.basename(f))
ln_sf(f, to)
end
systemd_units.each do |f|
sh %{ systemctl --user enable #{f} || true }
end
sh %{ update-desktop-database #{args.prefix}/.local/share/applications || true }
end
Dir.glob(File.join(bin, '*')).each do |f|
to = File.join(args.prefix, '.local/bin')
ln_sf(f, to)
end
# Detect screen version and symlink the appropriate colors config
screen_v5 = false
begin
ver = `screen --version 2>/dev/null`
if ver =~ /Screen version (\d+)/
screen_v5 = $1.to_i >= 5
end
rescue
end
colors_src = screen_v5 ? '.screenrc.colors.v5' : '.screenrc.colors.legacy'
colors_from = File.join(here, colors_src)
colors_to = File.join(args.prefix, '.screenrc.colors')
rm_f(colors_to)
ln_sf(colors_from, colors_to)
end