From d49948eae39ee3b03e7b43eaab08016ff579c65f Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 13 Jan 2025 10:15:46 -0600 Subject: [PATCH] make duration more readable --- pkgs/oizys/src/oizys/nix.nim | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pkgs/oizys/src/oizys/nix.nim b/pkgs/oizys/src/oizys/nix.nim index a76a5c0..accf977 100644 --- a/pkgs/oizys/src/oizys/nix.nim +++ b/pkgs/oizys/src/oizys/nix.nim @@ -324,7 +324,13 @@ type duration*: Duration successful*: bool - +func formatDuration(d: Duration): string = + ## convert duration to: X minutes and Y seconds + let seconds = d.inSeconds + if seconds > 60: + result.add $(seconds div 60) & " minutes" + result.add " and " + result.add $(seconds mod 60) & " seconds" proc build(drv: OizysDerivation, rest: seq[string]): BuildResult = let startTime = now() @@ -337,7 +343,7 @@ proc build(drv: OizysDerivation, rest: seq[string]): BuildResult = result.duration = now() - startTime # TODO: make splitDrv more ergonmic? info "succesfully built: " & splitDrv(drv.name).name - info "-> duration: " & $result.duration + info "-> duration: " & formatDuration(result.duration) func outputsPaths(o: OizysDerivation): seq[string] = for _, output in o.drv.outputs: @@ -403,12 +409,12 @@ proc getUpdatedLockFile() = # probably duplicating logic above ¯\_(ツ)_/¯ proc buildSystem(host: string, rest: seq[string]) = - var cmd = nixCommand("build") - cmd.addArg nixosConfigAttr(host) - cmd.addArgs rest - let code = runCmd cmd - if code != 0: - fatalQuit "build failed" + var cmd = nixCommand("build") + cmd.addArg nixosConfigAttr(host) + cmd.addArgs rest + let code = runCmd cmd + if code != 0: + fatalQuit "build failed" proc ciUpdate*(rest: seq[string]) = for host in getHosts():