invoke monitor directly
This commit is contained in:
parent
9b2604da81
commit
9ba2fe405b
1 changed files with 38 additions and 11 deletions
49
meat.nu
49
meat.nu
|
|
@ -42,19 +42,42 @@ def nix-conf-attr []: nothing -> string {
|
|||
$"nixosConfigurations.(hn).config.environment.etc.\"nix/nix.conf\""
|
||||
}
|
||||
|
||||
def nix-build-nom [out: string, build_args: list<string>] {
|
||||
if ($env.MONITOR? | is-empty) {
|
||||
^nix-build --out-link $out ...$build_args
|
||||
} else {
|
||||
^nix-build --log-format internal-json --out-link $out ...$build_args out+err>| ^$env.MONITOR --json
|
||||
def monitor-available []: nothing -> bool {
|
||||
let monitor = $env.MONITOR? | default ""
|
||||
(not ($monitor | is-empty)) and (not (which $monitor | is-empty))
|
||||
}
|
||||
|
||||
def monitor-build-args [build_args: list<string>]: nothing -> list<string> {
|
||||
$build_args | each { |arg|
|
||||
if ($arg | str ends-with ".drv") { $"($arg)^*" } else { $arg }
|
||||
}
|
||||
}
|
||||
|
||||
def nix-build-monitored [out: string, build_args: list<string>] {
|
||||
if (monitor-available) {
|
||||
let monitor_args = monitor-build-args $build_args
|
||||
match ($env.MONITOR | path basename) {
|
||||
"nom" => { ^$env.MONITOR build ...$monitor_args --out-link $out }
|
||||
"rom" => { ^$env.MONITOR build ...$monitor_args -- --out-link $out }
|
||||
$name => {
|
||||
error make { msg: $"unsupported Nix build monitor '($name)'; expected nom or rom" }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
^nix-build ...$build_args --out-link $out
|
||||
}
|
||||
# Piping to MONITOR masks nix-build's exit code, so detect failure by the
|
||||
# absence of the out-link.
|
||||
if not ($out | path exists) {
|
||||
error make { msg: "nix-build produced no output" }
|
||||
}
|
||||
}
|
||||
|
||||
def ensure-system-build [build: string] {
|
||||
let switch = $"($build)/bin/switch-to-configuration"
|
||||
if not ($switch | path exists) {
|
||||
error make { msg: $"build output is not a NixOS system closure: missing ($switch)" }
|
||||
}
|
||||
}
|
||||
|
||||
def differ-step [build: string] {
|
||||
if ($env.DIFFER? | is-empty) {
|
||||
meat-print " (no DIFFER set; skipping diff)"
|
||||
|
|
@ -74,7 +97,8 @@ def do-build [extras: list<string> = []] {
|
|||
let start = date now
|
||||
let drv = ^nix-instantiate $"($env.MEATS)/entry.nix" -A (system-attr) ...$extras | lines | last | str trim
|
||||
meat-print $"MASTICATION TAKING ((date now) - $start)"
|
||||
nix-build-nom $build [$drv]
|
||||
nix-build-monitored $build [$drv]
|
||||
ensure-system-build $build
|
||||
differ-step $build
|
||||
activate $build
|
||||
try { rm $build }
|
||||
|
|
@ -241,12 +265,15 @@ def cmd-ritual [] {
|
|||
let build = $"($tmpdir)/build"
|
||||
try {
|
||||
warm-pins
|
||||
nix-build-nom $nix_conf [$"($meats)/entry.nix" "-A" (nix-conf-attr)]
|
||||
let nix_conf_drv = ^nix-instantiate $"($meats)/entry.nix" -A (nix-conf-attr) | lines | last | str trim
|
||||
nix-build-monitored $nix_conf [$nix_conf_drv]
|
||||
meat-print "CONSUMING MEATS.."
|
||||
with-env { NIX_USER_CONF_FILES: $nix_conf } {
|
||||
nix-build-nom $build [$"($meats)/entry.nix" "-A" (system-attr)]
|
||||
let build_drv = ^nix-instantiate $"($meats)/entry.nix" -A (system-attr) | lines | last | str trim
|
||||
nix-build-monitored $build [$build_drv]
|
||||
}
|
||||
^$env.DIFFER /nix/var/nix/profiles/system $build
|
||||
ensure-system-build $build
|
||||
differ-step $build
|
||||
activate $build
|
||||
try { rm $nix_conf }
|
||||
try { rm $build }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue