-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
124 lines (106 loc) · 3.61 KB
/
Justfile
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
############################################################################
#
# Common commands(suitable for all machines)
#
############################################################################
# List all the just commands
default:
@just --list
# Update all the flake inputs
[group('nix')]
up:
nix flake update
# Update specific input
# Usage: just upp nixpkgs
[group('nix')]
upp input:
nix flake update {{input}}
# List all generations of the system profile
[group('nix')]
history:
nix profile history --profile /nix/var/nix/profiles/system
# Open a nix shell with the flake
[group('nix')]
repl:
nix repl -f flake:nixpkgs
# Remove all generations older than 7 days
[group('nix')]
clean:
# On darwin you may need to switch to root user to run this command
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d
# Garbage collect all unused nix store entries
[group('nix')]
gc:
# garbage collect all unused nix store entries (system-wide)
sudo nix-collect-garbage --delete-older-than 7d
# garbage collect all unused nix store entries (for the user - home-manager)
# https://github.com/NixOS/nix/issues/8508
nix-collect-garbage --delete-older-than 7d
# Enter a shell session which has all the necessary tools for this flake
[group('nix')]
shell:
nix shell nixpkgs#git nixpkgs#neovim
# Format the nix files in this repo
[group('nix')]
fmt:
nix fmt
# Nix Store can contains corrupted entries if the nix store object has been modified unexpectedly.
# This command will verify all the store entries,
# and we need to fix the corrupted entries manually via `sudo nix store delete <store-path-1> <store-path-2> ...`
# Verify all the store entries
[group('nix')]
verify-store:
nix store verify --all
# Repair Nix Store Objects
[group('nix')]
repair-store *paths:
nix store repair {{paths}}
############################################################################
#
# NixOS Desktop related commands
#
############################################################################
# Rebuild and switch to the specified NixOS configuration
# Usage: just switch alpha
[linux]
[group('NixOS')]
switch name mode="default":
#!/usr/bin/env bash
if [ "{{mode}}" == "debug" ]; then
nix build ".#nixosConfigurations.{{name}}.config.system.build.toplevel" --show-trace --verbose
nixos-rebuild switch --flake ".#{{name}}" --show-trace --verbose
else
nixos-rebuild switch --use-remote-sudo --flake ".#{{name}}"
fi
# Deploy alpha's configuration (Desktop PC)
[linux]
[group('NixOS')]
alpha mode="default": (switch "alpha" mode)
############################################################################
#
# Darwin related commands, harmonica is my macbook pro's hostname
#
############################################################################
[macos]
[group('Darwin')]
darwin-rollback:
./result/sw/bin/darwin-rebuild --rollback
# Rebuild and switch to the specified Darwin configuration
# Usage: just switch beta
[macos]
[group('Darwin')]
switch name mode="default":
#!/usr/bin/env bash
if [ "{{mode}}" == "debug" ]; then
nix build ".#darwinConfigurations.{{name}}.system" --extra-experimental-features "nix-command flakes" --show-trace --verbose
./result/sw/bin/darwin-rebuild switch --flake ".#{{name}}" --show-trace --verbose
else
nix build ".#darwinConfigurations.{{name}}.system" --extra-experimental-features "nix-command flakes"
./result/sw/bin/darwin-rebuild switch --flake ".#{{name}}"
fi
# Reset launchpad to force it to reindex Applications
[macos]
[group('Darwin')]
reset-launchpad:
defaults write com.apple.dock ResetLaunchPad -bool true
killall Dock