fix caching outputs

This commit is contained in:
Daylin Morgan 2024-11-07 14:36:45 -06:00
parent 3ea645aa20
commit 916856c8c3
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 18 additions and 15 deletions

View file

@ -34,6 +34,7 @@ hwylCli:
flags: flags:
minimal: minimal:
T bool T bool
? "set minimal"
- m - m
run: run:
nixBuild(minimal, args) nixBuild(minimal, args)
@ -45,11 +46,13 @@ hwylCli:
* "oizys" * "oizys"
? "name of binary cache" ? "name of binary cache"
service: service:
? "name of cache service"
* "attic" * "attic"
jobs: jobs:
* countProcessors() * countProcessors()
? "jobs when pushing paths" ? "jobs when pushing paths"
T int T int
- j
run: run:
nixBuildWithCache(name, args, service, jobs) nixBuildWithCache(name, args, service, jobs)
@ -68,6 +71,8 @@ hwylCli:
flags: flags:
minimal: minimal:
T bool T bool
? "set minimal"
- m
run: run:
nixBuildHostDry(minimal, args) nixBuildHostDry(minimal, args)

View file

@ -119,15 +119,14 @@ proc toBuildNixosConfiguration(): seq[string] =
return output.toBuild.mapIt(it.storePath) return output.toBuild.mapIt(it.storePath)
type type
DerivationOutputsOut = object DerivationOutput = object
path: string path: string
DerivationOutputs = object # hashAlgo: string
`out`: DerivationOutputsOut # hash: string
NixDerivation = object NixDerivation = object
inputDrvs: Table[string, JsonNode] inputDrvs: Table[string, JsonNode]
name: string name: string
outputs: DerivationOutputs outputs: Table[string, DerivationOutput]
proc evaluateDerivations(drvs: seq[string]): Table[string, NixDerivation] = proc evaluateDerivations(drvs: seq[string]): Table[string, NixDerivation] =
var cmd = "nix derivation show -r" var cmd = "nix derivation show -r"
@ -180,8 +179,7 @@ func isIgnored(drv: string): bool =
type type
OizysDerivation = object OizysDerivation = object
drv: NixDerivation # do i need this ? drv: NixDerivation
output: string
name: string name: string
proc getSystemPathDrvs(): seq[string] = proc getSystemPathDrvs(): seq[string] =
@ -203,7 +201,6 @@ proc getOizysDerivations(): seq[OizysDerivation] =
for name, drv in nixDerivationShow(toActullyBuildDrvs): for name, drv in nixDerivationShow(toActullyBuildDrvs):
result.add OizysDerivation( result.add OizysDerivation(
name: name, name: name,
output: drv.outputs.`out`.path,
drv: drv, drv: drv,
) )
@ -280,7 +277,6 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
display output display output
type type
BuildResult = object BuildResult = object
duration*: Duration duration*: Duration
@ -297,6 +293,10 @@ proc build(drv: OizysDerivation, rest: seq[string]): BuildResult =
result.duration = now() - startTime result.duration = now() - startTime
debug "build duration: " & $result.duration debug "build duration: " & $result.duration
func outputsPaths(o: OizysDerivation): seq[string] =
for _, output in o.drv.outputs:
result.add output.path
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?"
@ -313,12 +313,10 @@ proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: i
(drv, build(drv, rest)) (drv, build(drv, rest))
# TODO: add back reporting to GITHUB SUMMARY # TODO: add back reporting to GITHUB SUMMARY
var outs: seq[string]
let outs =
collect:
for (drv, res) in results: for (drv, res) in results:
if res.successful: if res.successful:
drv.output outs &= drv.outputsPaths
# TODO: push after build not at once? # TODO: push after build not at once?
var cmd = service var cmd = service