mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-05 01:53:15 -06:00
abstract build step
This commit is contained in:
parent
732b403697
commit
253f289421
1 changed files with 30 additions and 14 deletions
|
@ -280,6 +280,23 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
||||||
display output
|
display output
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
BuildResult = object
|
||||||
|
duration*: Duration
|
||||||
|
successful*: bool
|
||||||
|
|
||||||
|
proc build(drv: OizysDerivation, rest: seq[string]): BuildResult =
|
||||||
|
let startTime = now()
|
||||||
|
var cmd = "nix build"
|
||||||
|
cmd.addArg drv.name & "^*"
|
||||||
|
cmd.addArg "--no-link"
|
||||||
|
cmd.addArgs rest
|
||||||
|
let buildCode = runCmd(cmd)
|
||||||
|
result.successful = buildCode == 0
|
||||||
|
result.duration = now() - startTime
|
||||||
|
debug "build duration: " & $result.duration
|
||||||
|
|
||||||
proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: int) =
|
proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: int) =
|
||||||
## build individual derivations not cached and push to cache
|
## build individual derivations not cached and push to cache
|
||||||
if findExe(service) == "": fatalQuit fmt"is {service} installed?"
|
if findExe(service) == "": fatalQuit fmt"is {service} installed?"
|
||||||
|
@ -290,21 +307,20 @@ proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: i
|
||||||
info "nothing to build"
|
info "nothing to build"
|
||||||
quit "exiting...", QuitSuccess
|
quit "exiting...", QuitSuccess
|
||||||
|
|
||||||
# TODO: add back reporting to GITHUB SUMMARY
|
let results =
|
||||||
var outs: seq[string]
|
collect:
|
||||||
for drv in drvs:
|
for drv in drvs:
|
||||||
let startTime = now()
|
(drv, build(drv, rest))
|
||||||
var cmd = "nix build"
|
|
||||||
cmd.addArg drv.name & "^*"
|
|
||||||
cmd.addArg "--no-link"
|
|
||||||
cmd.addArgs rest
|
|
||||||
let buildCode = runCmd(cmd)
|
|
||||||
if buildCode != 0:
|
|
||||||
error "failed to build: " & drv.name
|
|
||||||
continue
|
|
||||||
info "build duration: " & $(now() - startTime)
|
|
||||||
outs &= drv.output
|
|
||||||
|
|
||||||
|
# TODO: add back reporting to GITHUB SUMMARY
|
||||||
|
|
||||||
|
let outs =
|
||||||
|
collect:
|
||||||
|
for (drv, res) in results:
|
||||||
|
if res.successful:
|
||||||
|
drv.output
|
||||||
|
|
||||||
|
# TODO: push after build not at once?
|
||||||
var cmd = service
|
var cmd = service
|
||||||
cmd.addArg "push"
|
cmd.addArg "push"
|
||||||
cmd.addArg name
|
cmd.addArg name
|
||||||
|
|
Loading…
Reference in a new issue