mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-08-24 12:13:57 +02:00
feat(deployment): add configurable NixOS deployment modes
This commit is contained in:
@@ -7,17 +7,23 @@ def repeat-str [s: string, n: int] {
|
||||
export def nixos-switch [
|
||||
name: string
|
||||
mode: string
|
||||
verbosity: string
|
||||
] {
|
||||
print $"nixos-switch '($name)' in '($mode)' mode..."
|
||||
if $mode not-in ["switch" "boot"] {
|
||||
error make { msg: $"unsupported deployment mode '($mode)'; expected switch or boot" }
|
||||
}
|
||||
if $verbosity not-in ["normal" "debug"] {
|
||||
error make { msg: $"unsupported verbosity '($verbosity)'; expected normal or debug" }
|
||||
}
|
||||
|
||||
print $"nixos-switch '($name)' in '($mode)' mode with '($verbosity)' verbosity..."
|
||||
print (repeat-str "=" 50)
|
||||
if "debug" == $mode {
|
||||
if $verbosity == "debug" {
|
||||
# show details via nix-output-monitor
|
||||
nom build $".#nixosConfigurations.($name).config.system.build.toplevel" --accept-flake-config --show-trace --verbose
|
||||
nixos-rebuild switch --sudo --flake $".#($name)" --accept-flake-config --show-trace --verbose
|
||||
} else if "boot" == $mode {
|
||||
nixos-rebuild boot --sudo --flake $".#($name)" --accept-flake-config
|
||||
nixos-rebuild $mode --sudo --flake $".#($name)" --accept-flake-config --show-trace --verbose
|
||||
} else {
|
||||
nixos-rebuild switch --sudo --flake $".#($name)" --accept-flake-config
|
||||
nixos-rebuild $mode --sudo --flake $".#($name)" --accept-flake-config
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +44,12 @@ export def make-editable [
|
||||
|
||||
export def darwin-build [
|
||||
name: string
|
||||
mode: string
|
||||
verbosity: string
|
||||
] {
|
||||
print $"darwin-build '($name)' in '($mode)' mode..."
|
||||
print $"darwin-build '($name)' with '($verbosity)' verbosity..."
|
||||
print (repeat-str "=" 50)
|
||||
let target = $".#darwinConfigurations.($name).system"
|
||||
if "debug" == $mode {
|
||||
if "debug" == $verbosity {
|
||||
nom build $target --extra-experimental-features "nix-command flakes" --show-trace --verbose
|
||||
} else {
|
||||
nix build $target --extra-experimental-features "nix-command flakes"
|
||||
@@ -52,11 +58,11 @@ export def darwin-build [
|
||||
|
||||
export def darwin-switch [
|
||||
name: string
|
||||
mode: string
|
||||
verbosity: string
|
||||
] {
|
||||
print $"darwin-switch '($name)' in '($mode)' mode..."
|
||||
print $"darwin-switch '($name)' with '($verbosity)' verbosity..."
|
||||
print (repeat-str "=" 50)
|
||||
if "debug" == $mode {
|
||||
if "debug" == $verbosity {
|
||||
sudo -E ./result/sw/bin/darwin-rebuild switch --flake $".#($name)" --show-trace --verbose
|
||||
} else {
|
||||
sudo -E ./result/sw/bin/darwin-rebuild switch --flake $".#($name)"
|
||||
@@ -72,12 +78,12 @@ export def darwin-rollback [] {
|
||||
# Build and upload a VM image
|
||||
export def upload-vm [
|
||||
name: string
|
||||
mode: string
|
||||
verbosity: string
|
||||
] {
|
||||
print $"upload-vm '($name)' in '($mode)' mode..."
|
||||
print $"upload-vm '($name)' with '($verbosity)' verbosity..."
|
||||
print (repeat-str "=" 50)
|
||||
let target = $".#($name)"
|
||||
if "debug" == $mode {
|
||||
if "debug" == $verbosity {
|
||||
nom build $target --show-trace --verbose
|
||||
} else {
|
||||
nix build $target
|
||||
|
||||
Reference in New Issue
Block a user