mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 01:50:44 -06:00
fix caching outputs
This commit is contained in:
parent
3ea645aa20
commit
916856c8c3
2 changed files with 18 additions and 15 deletions
|
@ -34,6 +34,7 @@ hwylCli:
|
|||
flags:
|
||||
minimal:
|
||||
T bool
|
||||
? "set minimal"
|
||||
- m
|
||||
run:
|
||||
nixBuild(minimal, args)
|
||||
|
@ -45,11 +46,13 @@ hwylCli:
|
|||
* "oizys"
|
||||
? "name of binary cache"
|
||||
service:
|
||||
? "name of cache service"
|
||||
* "attic"
|
||||
jobs:
|
||||
* countProcessors()
|
||||
? "jobs when pushing paths"
|
||||
T int
|
||||
- j
|
||||
run:
|
||||
nixBuildWithCache(name, args, service, jobs)
|
||||
|
||||
|
@ -68,6 +71,8 @@ hwylCli:
|
|||
flags:
|
||||
minimal:
|
||||
T bool
|
||||
? "set minimal"
|
||||
- m
|
||||
run:
|
||||
nixBuildHostDry(minimal, args)
|
||||
|
||||
|
|
|
@ -119,15 +119,14 @@ proc toBuildNixosConfiguration(): seq[string] =
|
|||
return output.toBuild.mapIt(it.storePath)
|
||||
|
||||
type
|
||||
DerivationOutputsOut = object
|
||||
DerivationOutput = object
|
||||
path: string
|
||||
DerivationOutputs = object
|
||||
`out`: DerivationOutputsOut
|
||||
# hashAlgo: string
|
||||
# hash: string
|
||||
NixDerivation = object
|
||||
inputDrvs: Table[string, JsonNode]
|
||||
name: string
|
||||
outputs: DerivationOutputs
|
||||
|
||||
outputs: Table[string, DerivationOutput]
|
||||
|
||||
proc evaluateDerivations(drvs: seq[string]): Table[string, NixDerivation] =
|
||||
var cmd = "nix derivation show -r"
|
||||
|
@ -180,8 +179,7 @@ func isIgnored(drv: string): bool =
|
|||
|
||||
type
|
||||
OizysDerivation = object
|
||||
drv: NixDerivation # do i need this ?
|
||||
output: string
|
||||
drv: NixDerivation
|
||||
name: string
|
||||
|
||||
proc getSystemPathDrvs(): seq[string] =
|
||||
|
@ -203,7 +201,6 @@ proc getOizysDerivations(): seq[OizysDerivation] =
|
|||
for name, drv in nixDerivationShow(toActullyBuildDrvs):
|
||||
result.add OizysDerivation(
|
||||
name: name,
|
||||
output: drv.outputs.`out`.path,
|
||||
drv: drv,
|
||||
)
|
||||
|
||||
|
@ -280,7 +277,6 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
|||
display output
|
||||
|
||||
|
||||
|
||||
type
|
||||
BuildResult = object
|
||||
duration*: Duration
|
||||
|
@ -297,6 +293,10 @@ proc build(drv: OizysDerivation, rest: seq[string]): BuildResult =
|
|||
result.duration = now() - startTime
|
||||
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) =
|
||||
## build individual derivations not cached and push to cache
|
||||
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))
|
||||
|
||||
# TODO: add back reporting to GITHUB SUMMARY
|
||||
|
||||
let outs =
|
||||
collect:
|
||||
for (drv, res) in results:
|
||||
if res.successful:
|
||||
drv.output
|
||||
var outs: seq[string]
|
||||
for (drv, res) in results:
|
||||
if res.successful:
|
||||
outs &= drv.outputsPaths
|
||||
|
||||
# TODO: push after build not at once?
|
||||
var cmd = service
|
||||
|
|
Loading…
Reference in a new issue