mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 22:30:25 +01:00
refactor: justfile - nixos-swtich/darwin-switch (#211)
This commit is contained in:
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 =========================
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user