refactor: justfile - nixos-swtich/darwin-switch (#211)

This commit is contained in:
Ryan Yin
2025-08-18 21:22:23 +08:00
committed by GitHub
parent adc49e7f6e
commit 30d73dabf1
3 changed files with 32 additions and 73 deletions

View File

@@ -1,9 +1,15 @@
def repeat-str [s: string, n: int] {
(1..$n | each { $s } | str join)
}
# ================= NixOS related =========================
export def nixos-switch [
name: string
mode: string
] {
print $"nixos-switch '($name)' in '($mode)' mode..."
print (repeat-str "=" 50)
if "debug" == $mode {
# show details via nix-output-monitor
nom build $".#nixosConfigurations.($name).config.system.build.toplevel" --show-trace --verbose
@@ -19,6 +25,7 @@ export def nixos-switch [
export def make-editable [
path: string
] {
print (repeat-str "=" 50)
let tmpdir = (mktemp -d)
rsync -avz --copy-links $"($path)/" $tmpdir
rsync -avz --copy-links --chmod=D2755,F744 $"($tmpdir)/" $path
@@ -31,6 +38,8 @@ export def darwin-build [
name: string
mode: string
] {
print $"darwin-build '($name)' in '($mode)' mode..."
print (repeat-str "=" 50)
let target = $".#darwinConfigurations.($name).system"
if "debug" == $mode {
nom build $target --extra-experimental-features "nix-command flakes" --show-trace --verbose
@@ -43,6 +52,8 @@ export def darwin-switch [
name: string
mode: string
] {
print $"darwin-switch '($name)' in '($mode)' mode..."
print (repeat-str "=" 50)
if "debug" == $mode {
sudo -E ./result/sw/bin/darwin-rebuild switch --flake $".#($name)" --show-trace --verbose
} else {
@@ -61,6 +72,8 @@ export def upload-vm [
name: string
mode: string
] {
print $"upload-vm '($name)' in '($mode)' mode..."
print (repeat-str "=" 50)
let target = $".#($name)"
if "debug" == $mode {
nom build $target --show-trace --verbose