-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
129 lines (115 loc) · 3.76 KB
/
justfile
File metadata and controls
129 lines (115 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
# dotfiles installation helpers
DOTFILES := `git rev-parse --show-toplevel`
GC_DURATION := "30d"
INSTALL_FLAGS := ""
SUDO := `command -v doas 2&>/dev/null && echo "doas" || echo "bash"`
# List all.
[private]
default:
@just --list --unsorted
# Install config for nixos.
install flags=INSTALL_FLAGS: hier-build-base symlinks-link hier-build-extra
#!/usr/bin/env fish
# Update channels:
if string match -i -r ".*update.*" {{flags}} 1&2>/dev/null
{{SUDO}} nix-channel --update
end
if string match -i -r ".*upgrade.*" {{flags}} 1&2>/dev/null
{{SUDO}} nix-channel --update
end
# Update the configuration:
{{SUDO}} nixos-rebuild switch -I nixos-config="{{DOTFILES}}/pkgs/nix/configuration.nixos.nix" -j 4
# Run GC:
if test $status -eq 0
{{SUDO}} nix-collect-garbage --delete-older-than {{GC_DURATION}}
{{SUDO}} nix-store --gc
# {{SUDO}} nixos-rebuild boot
just post-install
end
# Install minimal config for shell and other environments.
# This is for nix installs, not nixos.
install-shell flags=INSTALL_FLAGS: hier-build-base symlinks-link hier-build-extra
#!/usr/bin/env fish
if string match -i -r ".*update.*" {{flags}} 1&2>/dev/null
nix-channel --update
{{SUDO}} nix-channel --update
end
nix profile install -f {{DOTFILES}}/pkgs/nix/configuration.profile.nix \
--extra-experimental-features nix-command
if test $status -eq 0
nix-env --delete-generations {{GC_DURATION}}
nix-store --gc
end
just post-install
# Build base directories.
hier-build-base:
@just directory-ensure-mk ~/.config
@just directory-ensure-mk ~/.local
@just directory-ensure-mk ~/.local/share/applications
@just directory-ensure-mk ~/downloads
@just directory-ensure-mk ~/workspace
@just directory-ensure-mk ~/workspace/bin
@just directory-ensure-mk ~/workspace/dev
@just directory-ensure-mk ~/workspace/dev/games
@just directory-ensure-mk ~/workspace/games
@just directory-ensure-mk ~/workspace/software
@just directory-ensure-mk ~/workspace/storage
# Build extra directories.
hier-build-extra:
@xdg-user-dirs-update
@just directory-ensure-rm ~/Desktop
@just directory-ensure-rm ~/Documents
@just directory-ensure-rm ~/Downloads
@just directory-ensure-rm ~/Music
@just directory-ensure-rm ~/Pictures
@just directory-ensure-rm ~/Public
@just directory-ensure-rm ~/Templates
@just directory-ensure-rm ~/Videos
# Build extra directories.
hier-build-symlinks:
@# Create base folders for symlinks:
@mkdir -p ~/.config
@mkdir -p ~/.fonts
@mkdir -p ~/.ssh
@mkdir -p ~/.local/share/applications
@mkdir -p ~/.local/share/fcitx5
@mkdir -p ~/.local/share/icons
@mkdir -p ~/.local/share/man
@mkdir -p ~/.local/share/omf
@mkdir -p ~/.local/share/themes
# Ensure directory exists.
directory-ensure-mk dir:
#!/usr/bin/env fish
test -d {{dir}} || mkdir -p {{dir}}
# Ensure directory doesn't exist.
directory-ensure-rm dir:
#!/usr/bin/env fish
rmdir {{dir}} 2> /dev/null || true
# Link symlinks.
symlinks-link: hier-build-symlinks
#!/usr/bin/env fish
# Stow symlinks:
ln -s -T {{DOTFILES}} ~/.config/dotfiles 2> /dev/null
pushd ~/.config/dotfiles
stow --adopt --restow --target ~/. dotfiles
set stowed $status
popd
# Symlink dotfiles:
if ! test -e ~/workspace/dotfiles;
ln -s (realpath {{DOTFILES}}) ~/workspace/dotfiles
end
if ! test -e ~/.config/dotfiles;
ln -s (realpath {{DOTFILES}}) ~/.config/dotfiles
end
exit $stowed
# post-install events.
[private]
post-install:
# Update bat.
bat cache --build
# Update fonts.
fc-cache -fv
# Update vale.
vale sync
# Mise install
mise install