mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 18:30:43 -06:00
implement cache
This commit is contained in:
parent
dba9b0c0e1
commit
af28544102
3 changed files with 38 additions and 5 deletions
|
@ -40,9 +40,9 @@ overlay:
|
||||||
## nix build
|
## nix build
|
||||||
nixBuild(minimal, rest)
|
nixBuild(minimal, rest)
|
||||||
|
|
||||||
proc cache(name: string = "daylin") =
|
proc cache(minimal: bool = false, name: string = "daylin") =
|
||||||
## *TBI* build and push to cachix
|
## build and push to cachix
|
||||||
fatal "not implemented"
|
nixBuildWithCache(minimal, name, rest)
|
||||||
|
|
||||||
proc osCmd() =
|
proc osCmd() =
|
||||||
## nixos-rebuild
|
## nixos-rebuild
|
||||||
|
@ -56,7 +56,7 @@ overlay:
|
||||||
nixosRebuild(subcmd, rest[1..^1])
|
nixosRebuild(subcmd, rest[1..^1])
|
||||||
|
|
||||||
proc ci(`ref`: string = "main") =
|
proc ci(`ref`: string = "main") =
|
||||||
## *TBD* trigger GHA update flow
|
## trigger GHA update flow
|
||||||
if rest.len == 0:
|
if rest.len == 0:
|
||||||
fatal "expected workflow file name"; quit QuitFailure
|
fatal "expected workflow file name"; quit QuitFailure
|
||||||
createDispatch(rest[0], `ref`)
|
createDispatch(rest[0], `ref`)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import std/[
|
||||||
import ./spin
|
import ./spin
|
||||||
|
|
||||||
|
|
||||||
func addArgs*(cmd: var string, args: seq[string]) =
|
func addArgs*(cmd: var string, args: openArray[string]) =
|
||||||
cmd &= " " & args.join(" ")
|
cmd &= " " & args.join(" ")
|
||||||
|
|
||||||
func addArg*(cmd: var string, arg: string) =
|
func addArg*(cmd: var string, arg: string) =
|
||||||
|
|
|
@ -203,10 +203,12 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
||||||
quit "exiting...", QuitSuccess
|
quit "exiting...", QuitSuccess
|
||||||
cmd.addArgs drvs
|
cmd.addArgs drvs
|
||||||
cmd.addArg "--no-link"
|
cmd.addArg "--no-link"
|
||||||
|
|
||||||
if isCi():
|
if isCi():
|
||||||
writeDervationsToStepSummary drvs
|
writeDervationsToStepSummary drvs
|
||||||
else:
|
else:
|
||||||
cmd.addArgs nixosConfigAttrs()
|
cmd.addArgs nixosConfigAttrs()
|
||||||
|
|
||||||
cmd.addArg "--dry-run"
|
cmd.addArg "--dry-run"
|
||||||
cmd.addArgs rest
|
cmd.addArgs rest
|
||||||
let (_, err) =
|
let (_, err) =
|
||||||
|
@ -214,4 +216,35 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
||||||
let output = parseDryRunOutput err
|
let output = parseDryRunOutput err
|
||||||
display output
|
display output
|
||||||
|
|
||||||
|
# TODO: Add to bbansi
|
||||||
|
template `bbfmt`(pattern: static string): untyped =
|
||||||
|
bb(fmt(pattern))
|
||||||
|
|
||||||
|
proc nixBuildWithCache*(minimal: bool, name: string, rest:seq[string]) =
|
||||||
|
if findExe("cachix") == "":
|
||||||
|
fatal "is cachix installed?"; quit QuitFailure
|
||||||
|
info bbfmt"building and pushing to cache: [b]{name}"
|
||||||
|
var cmd = "cachix"
|
||||||
|
cmd.addArgs ["watch-exec","--"]
|
||||||
|
cmd.addArg "nix build"
|
||||||
|
if minimal:
|
||||||
|
debug "populating args with derivations not built/cached"
|
||||||
|
let drvs = systemPathDrvsToBuild()
|
||||||
|
if drvs.len == 0:
|
||||||
|
info "nothing to build"
|
||||||
|
quit "exiting...", QuitSuccess
|
||||||
|
cmd.addArgs drvs
|
||||||
|
cmd.addArg "--no-link"
|
||||||
|
else:
|
||||||
|
cmd.addArgs nixosConfigAttrs()
|
||||||
|
cmd.addArgs rest
|
||||||
|
debug cmd
|
||||||
|
quit QuitSuccess
|
||||||
|
let err = runCmd(cmd)
|
||||||
|
quit err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue