diff --git a/Justfile b/Justfile index 08312982..a93108ca 100644 --- a/Justfile +++ b/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] [group('desktop')] hypr mode="default": #!/usr/bin/env nu use {{utils_nu}} *; - nixos-switch ai-hyprland {{mode}} - -[linux] -[group('desktop')] -s-hypr mode="default": - #!/usr/bin/env nu - use {{utils_nu}} *; - nixos-switch shoukei-hyprland {{mode}} + nixos-switch $"(hostname)-hyprland" {{mode}} ############################################################################ # @@ -141,23 +143,15 @@ darwin-rollback: use {{utils_nu}} *; darwin-rollback -# Depoly to fern(macOS host) +# Deploy the darwinConfiguration by hostname match [macos] [group('desktop')] -fe mode="default": +local mode="default": #!/usr/bin/env nu use {{utils_nu}} *; - darwin-build "fern" {{mode}}; - darwin-switch "fern" {{mode}} + darwin-build (hostname) {{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 [macos] @@ -178,13 +172,6 @@ reset-launchpad: col tag: 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 [linux] [group('homelab')] @@ -204,37 +191,16 @@ lab: shoryu: 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] [group('homelab')] shushou: 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] [group('homelab')] youko: 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 @@ -256,37 +222,16 @@ upload-idols mode="default": aqua: 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] [group('homelab')] ruby: 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] [group('homelab')] kana: 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 diff --git a/README.md b/README.md index f21f8759..083798af 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,8 @@ For NixOS: sudo nixos-rebuild switch --flake .#ai-hyprland # 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 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. # 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) -just fr +# Deploy the darwinConfiguration by hostname match +just local # 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) diff --git a/utils.nu b/utils.nu index d1ec56b3..df43da98 100644 --- a/utils.nu +++ b/utils.nu @@ -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