refactor: Justfile

This commit is contained in:
Ryan Yin
2024-01-02 11:47:59 +08:00
parent 709f56a0c2
commit e3ba141695
3 changed files with 74 additions and 35 deletions
+21 -32
View File
@@ -9,26 +9,24 @@ set shell := ["nu", "-c"]
# #
############################################################################ ############################################################################
nixos-switch := "nixos-rebuild switch --use-remote-sudo --flake" i3 mode="default":
debug-args := "--show-trace --verbose" use utils.nu *; \
nixos-switch .#ai_i3 {{mode}}
i3: hypr mode="default":
{{nixos-switch}} .#ai_i3 use utils.nu *; \
nixos-switch .#ai_hyprland {{mode}}
hypr:
{{nixos-switch}} .#ai_hyprland
s-i3: s-i3 mode="default":
{{nixos-switch}} .#shoukei_i3 use utils.nu *; \
nixos-switch .#shoukei_i3 {{mode}}
s-hypr:
{{nixos-switch}} .#shoukei_hyprland
i3-debug: s-hypr mode="default":
{{nixos-switch}} .#ai_i3 {{debug-args}} use utils.nu *; \
nixos-switch .#shoukei_hyprland {{mode}}
hypr-debug:
{{nixos-switch}} .#ai_hyprland {{debug-args}}
up: up:
nix flake update nix flake update
@@ -58,31 +56,22 @@ gc:
# #
############################################################################ ############################################################################
darwin-prefix := "./result/sw/bin/darwin-rebuild"
darwin-switch := darwin-prefix + " switch --flake"
darwin-set-proxy: darwin-set-proxy:
sudo python3 scripts/darwin_set_proxy.py sudo python3 scripts/darwin_set_proxy.py
sleep 1sec sleep 1sec
darwin-rollback: darwin-rollback:
{{darwin-prefix}} rollback rollback
ha: darwin-set-proxy ha mode="default": darwin-set-proxy
nix build .#darwinConfigurations.harmonica.system use utils.nu *; \
{{darwin-switch}} .#harmonica darwin-build "harmonica" {{mode}}; \
darwin-switch "harmonica" {{mode}}
ha-debug: darwin-set-proxy fe mode="default":
nom build .#darwinConfigurations.harmonica.system {{debug-args}} use utils.nu *; \
{{darwin-switch}} .#harmonica {{debug-args}} darwin-build "fern" {{mode}}; \
darwin-switch "fern" {{mode}}
fe: darwin-set-proxy
nix build .#darwinConfigurations.fern.system
{{darwin-switch}} .#fern
fe-debug: darwin-set-proxy
nom build .#darwinConfigurations.fern.system {{debug-args}}
{{darwin-switch}} .#fern {{debug-args}}
############################################################################ ############################################################################
# #
+3 -3
View File
@@ -97,7 +97,7 @@ just i3 # deploy my pc with i3 window manager
# just hypr # deploy my pc with hyprland compositor # just hypr # deploy my pc with hyprland compositor
# or we can deploy with details # or we can deploy with details
just i3-debug just i3 debug
# just hypr-debug # just hypr-debug
``` ```
@@ -111,8 +111,8 @@ just ha
just fe just fe
# deploy with details # deploy with details
just ha-debug just ha debug
# just fe # just fe debug
``` ```
> [What y'all will need when Nix drives you to drink.](https://www.youtube.com/watch?v=Eni9PPPPBpg) (copy from hlissner's dotfiles, it really matches my feelings when I first started using NixOS...) > [What y'all will need when Nix drives you to drink.](https://www.youtube.com/watch?v=Eni9PPPPBpg) (copy from hlissner's dotfiles, it really matches my feelings when I first started using NixOS...)
+50
View File
@@ -0,0 +1,50 @@
# ================= NixOS related =========================
export def nixos-switch [
name: string
mode: string
] {
if "debug" == $mode {
nixos-rebuild switch --use-remote-sudo --flake $".#($name)" --show-trace --verbose
} else {
nixos-rebuild switch --use-remote-sudo --flake $".#($name)"
}
}
# ================= macOS related =========================
const darwin_dir = './result/sw/bin'
export def darwin-build [
name: string
mode: string
] {
let target = $".#darwinConfigurations.($name).system"
with-env { PATH : ($env.PATH | prepend darwin_dir) } {
if "debug" == $mode {
nom build $target --show-trace --verbose
} else {
nix build $target
}
}
}
export def darwin-switch [
name: string
mode: string
] {
with-env { PATH : ($env.PATH | prepend darwin_dir) } {
if "debug" == $mode {
darwin-rebuild switch --flake $".#($name)" --show-trace --verbose
} else {
darwin-rebuild switch --flake $".#($name)"
}
}
}
export def darwin-rollback [] {
with-env { PATH : ($env.PATH | prepend darwin_dir) } {
darwin-rebuild rollback
}
}