mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 14:20:23 +01:00
refactor: justfile - nixos-swtich/darwin-switch (#211)
This commit is contained in:
83
Justfile
83
Justfile
@@ -108,19 +108,21 @@ up-nix:
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
# Deploy the nixosConfiguration by hostname match
|
||||||
|
[linux]
|
||||||
|
[group('homelab')]
|
||||||
|
local mode="default":
|
||||||
|
#!/usr/bin/env nu
|
||||||
|
use {{utils_nu}} *;
|
||||||
|
nixos-switch (hostname) {{mode}}
|
||||||
|
|
||||||
|
# Deploy the hyprland nixosConfiguration by hostname match
|
||||||
[linux]
|
[linux]
|
||||||
[group('desktop')]
|
[group('desktop')]
|
||||||
hypr mode="default":
|
hypr mode="default":
|
||||||
#!/usr/bin/env nu
|
#!/usr/bin/env nu
|
||||||
use {{utils_nu}} *;
|
use {{utils_nu}} *;
|
||||||
nixos-switch ai-hyprland {{mode}}
|
nixos-switch $"(hostname)-hyprland" {{mode}}
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('desktop')]
|
|
||||||
s-hypr mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch shoukei-hyprland {{mode}}
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
@@ -141,23 +143,15 @@ darwin-rollback:
|
|||||||
use {{utils_nu}} *;
|
use {{utils_nu}} *;
|
||||||
darwin-rollback
|
darwin-rollback
|
||||||
|
|
||||||
# Depoly to fern(macOS host)
|
# Deploy the darwinConfiguration by hostname match
|
||||||
[macos]
|
[macos]
|
||||||
[group('desktop')]
|
[group('desktop')]
|
||||||
fe mode="default":
|
local mode="default":
|
||||||
#!/usr/bin/env nu
|
#!/usr/bin/env nu
|
||||||
use {{utils_nu}} *;
|
use {{utils_nu}} *;
|
||||||
darwin-build "fern" {{mode}};
|
darwin-build (hostname) {{mode}};
|
||||||
darwin-switch "fern" {{mode}}
|
darwin-switch (hostname) {{mode}}
|
||||||
|
|
||||||
# Depoly to frieren(macOS host)
|
|
||||||
[macos]
|
|
||||||
[group('desktop')]
|
|
||||||
fr mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
darwin-build "frieren" {{mode}};
|
|
||||||
darwin-switch "frieren" {{mode}}
|
|
||||||
|
|
||||||
# Reset launchpad to force it to reindex Applications
|
# Reset launchpad to force it to reindex Applications
|
||||||
[macos]
|
[macos]
|
||||||
@@ -178,13 +172,6 @@ reset-launchpad:
|
|||||||
col tag:
|
col tag:
|
||||||
colmena apply --on '@{{tag}}' --verbose --show-trace
|
colmena apply --on '@{{tag}}' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
local name mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch {{name}} {{mode}}
|
|
||||||
|
|
||||||
# Build and upload a vm image
|
# Build and upload a vm image
|
||||||
[linux]
|
[linux]
|
||||||
[group('homelab')]
|
[group('homelab')]
|
||||||
@@ -204,37 +191,16 @@ lab:
|
|||||||
shoryu:
|
shoryu:
|
||||||
colmena apply --on '@kubevirt-shoryu' --verbose --show-trace
|
colmena apply --on '@kubevirt-shoryu' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
shoryu-local mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch kubevirt-shoryu {{mode}}
|
|
||||||
|
|
||||||
[linux]
|
[linux]
|
||||||
[group('homelab')]
|
[group('homelab')]
|
||||||
shushou:
|
shushou:
|
||||||
colmena apply --on '@kubevirt-shushou' --verbose --show-trace
|
colmena apply --on '@kubevirt-shushou' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
shushou-local mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch kubevirt-shushou {{mode}}
|
|
||||||
|
|
||||||
[linux]
|
[linux]
|
||||||
[group('homelab')]
|
[group('homelab')]
|
||||||
youko:
|
youko:
|
||||||
colmena apply --on '@kubevirt-youko' --verbose --show-trace
|
colmena apply --on '@kubevirt-youko' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
youko-local mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch kubevirt-youko {{mode}}
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Commands for other Virtual Machines
|
# Commands for other Virtual Machines
|
||||||
@@ -256,37 +222,16 @@ upload-idols mode="default":
|
|||||||
aqua:
|
aqua:
|
||||||
colmena apply --on '@aqua' --verbose --show-trace
|
colmena apply --on '@aqua' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
aqua-local mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch aquamarine {{mode}}
|
|
||||||
|
|
||||||
[linux]
|
[linux]
|
||||||
[group('homelab')]
|
[group('homelab')]
|
||||||
ruby:
|
ruby:
|
||||||
colmena apply --on '@ruby' --verbose --show-trace
|
colmena apply --on '@ruby' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
ruby-local mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch ruby {{mode}}
|
|
||||||
|
|
||||||
[linux]
|
[linux]
|
||||||
[group('homelab')]
|
[group('homelab')]
|
||||||
kana:
|
kana:
|
||||||
colmena apply --on '@kana' --verbose --show-trace
|
colmena apply --on '@kana' --verbose --show-trace
|
||||||
|
|
||||||
[linux]
|
|
||||||
[group('homelab')]
|
|
||||||
kana-local mode="default":
|
|
||||||
#!/usr/bin/env nu
|
|
||||||
use {{utils_nu}} *;
|
|
||||||
nixos-switch kana {{mode}}
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Kubernetes related commands
|
# Kubernetes related commands
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ For NixOS:
|
|||||||
sudo nixos-rebuild switch --flake .#ai-hyprland
|
sudo nixos-rebuild switch --flake .#ai-hyprland
|
||||||
|
|
||||||
# deploy via `just`(a command runner with similar syntax to make) & Justfile
|
# deploy via `just`(a command runner with similar syntax to make) & Justfile
|
||||||
just hypr # deploy my pc with hyprland compositor
|
# Deploy the hyprland nixosConfiguration by hostname match
|
||||||
|
just hypr
|
||||||
|
|
||||||
# or we can deploy with details
|
# or we can deploy with details
|
||||||
just hypr debug
|
just hypr debug
|
||||||
@@ -132,11 +133,11 @@ nix-shell -p just nushell
|
|||||||
# 3. comment home-manager's code in lib/macosSystem.nix to speed up the first deployment.
|
# 3. comment home-manager's code in lib/macosSystem.nix to speed up the first deployment.
|
||||||
# 4. comment out the proxy settings in scripts/darwin_set_proxy.py if the proxy is not ready yet.
|
# 4. comment out the proxy settings in scripts/darwin_set_proxy.py if the proxy is not ready yet.
|
||||||
|
|
||||||
# deploy fern's configuration(Apple Silicon)
|
# Deploy the darwinConfiguration by hostname match
|
||||||
just fr
|
just local
|
||||||
|
|
||||||
# deploy with details
|
# deploy with details
|
||||||
just fr debug
|
just local debug
|
||||||
```
|
```
|
||||||
|
|
||||||
> [What y'all will need when Nix drives you to drink.](https://www.youtube.com/watch?v=Eni9PPPPBpg)
|
> [What y'all will need when Nix drives you to drink.](https://www.youtube.com/watch?v=Eni9PPPPBpg)
|
||||||
|
|||||||
13
utils.nu
13
utils.nu
@@ -1,9 +1,15 @@
|
|||||||
|
def repeat-str [s: string, n: int] {
|
||||||
|
(1..$n | each { $s } | str join)
|
||||||
|
}
|
||||||
|
|
||||||
# ================= NixOS related =========================
|
# ================= NixOS related =========================
|
||||||
|
|
||||||
export def nixos-switch [
|
export def nixos-switch [
|
||||||
name: string
|
name: string
|
||||||
mode: string
|
mode: string
|
||||||
] {
|
] {
|
||||||
|
print $"nixos-switch '($name)' in '($mode)' mode..."
|
||||||
|
print (repeat-str "=" 50)
|
||||||
if "debug" == $mode {
|
if "debug" == $mode {
|
||||||
# show details via nix-output-monitor
|
# show details via nix-output-monitor
|
||||||
nom build $".#nixosConfigurations.($name).config.system.build.toplevel" --show-trace --verbose
|
nom build $".#nixosConfigurations.($name).config.system.build.toplevel" --show-trace --verbose
|
||||||
@@ -19,6 +25,7 @@ export def nixos-switch [
|
|||||||
export def make-editable [
|
export def make-editable [
|
||||||
path: string
|
path: string
|
||||||
] {
|
] {
|
||||||
|
print (repeat-str "=" 50)
|
||||||
let tmpdir = (mktemp -d)
|
let tmpdir = (mktemp -d)
|
||||||
rsync -avz --copy-links $"($path)/" $tmpdir
|
rsync -avz --copy-links $"($path)/" $tmpdir
|
||||||
rsync -avz --copy-links --chmod=D2755,F744 $"($tmpdir)/" $path
|
rsync -avz --copy-links --chmod=D2755,F744 $"($tmpdir)/" $path
|
||||||
@@ -31,6 +38,8 @@ export def darwin-build [
|
|||||||
name: string
|
name: string
|
||||||
mode: string
|
mode: string
|
||||||
] {
|
] {
|
||||||
|
print $"darwin-build '($name)' in '($mode)' mode..."
|
||||||
|
print (repeat-str "=" 50)
|
||||||
let target = $".#darwinConfigurations.($name).system"
|
let target = $".#darwinConfigurations.($name).system"
|
||||||
if "debug" == $mode {
|
if "debug" == $mode {
|
||||||
nom build $target --extra-experimental-features "nix-command flakes" --show-trace --verbose
|
nom build $target --extra-experimental-features "nix-command flakes" --show-trace --verbose
|
||||||
@@ -43,6 +52,8 @@ export def darwin-switch [
|
|||||||
name: string
|
name: string
|
||||||
mode: string
|
mode: string
|
||||||
] {
|
] {
|
||||||
|
print $"darwin-switch '($name)' in '($mode)' mode..."
|
||||||
|
print (repeat-str "=" 50)
|
||||||
if "debug" == $mode {
|
if "debug" == $mode {
|
||||||
sudo -E ./result/sw/bin/darwin-rebuild switch --flake $".#($name)" --show-trace --verbose
|
sudo -E ./result/sw/bin/darwin-rebuild switch --flake $".#($name)" --show-trace --verbose
|
||||||
} else {
|
} else {
|
||||||
@@ -61,6 +72,8 @@ export def upload-vm [
|
|||||||
name: string
|
name: string
|
||||||
mode: string
|
mode: string
|
||||||
] {
|
] {
|
||||||
|
print $"upload-vm '($name)' in '($mode)' mode..."
|
||||||
|
print (repeat-str "=" 50)
|
||||||
let target = $".#($name)"
|
let target = $".#($name)"
|
||||||
if "debug" == $mode {
|
if "debug" == $mode {
|
||||||
nom build $target --show-trace --verbose
|
nom build $target --show-trace --verbose
|
||||||
|
|||||||
Reference in New Issue
Block a user