rework cache build

This commit is contained in:
Daylin Morgan 2024-10-30 17:12:52 -05:00
parent 4a5cae6ee1
commit 3c730fb6f1
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -245,31 +245,28 @@ 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
var outs: seq[string]
for drv in drvs: for drv in drvs:
var cmd = "nix build" var cmd = "nix build"
cmd.addArg drv cmd.addArg drv
cmd.addArg "--no-link"
cmd.addArg "--print-out-paths"
cmd.addArgs rest cmd.addArgs rest
let buildErr = runCmd(cmd) let (path, _, buildCode) = runCmdCapt(cmd)
if buildErr != 0: if buildCode != 0:
error "failed to build: " & drv error "failed to build: " & drv
continue continue
outs.add path
# TODO: propagate errors using nix log?
let results = collect( var cmd = service
for k, p in walkDir(".", relative = true):
if k in { pcLinkToDir, pcLinkToFile} and p.startsWith("result"):
p
)
cmd = service
cmd.addArg "push" cmd.addArg "push"
cmd.addArg name cmd.addArg name
cmd.addArg "--jobs" cmd.addArg "--jobs"
cmd.addArg $jobs cmd.addArg $jobs
cmd.addArgs results cmd.addArgs outs
let pushErr = runCmd(cmd) let pushErr = runCmd(cmd)
if pushErr != 0: if pushErr != 0:
errorQuit "failed to push build to cache" errorQuit "failed to push build to cache"
for p in results:
removeFile p