Compare commits

...

3 commits

Author SHA1 Message Date
912be37cc0
freeze it up 2024-09-03 15:01:16 -05:00
af28544102
implement cache 2024-09-03 12:17:01 -05:00
dba9b0c0e1
semantics 2024-09-03 12:01:32 -05:00
5 changed files with 45 additions and 12 deletions

View file

@ -8,5 +8,6 @@
cachix cachix
graphviz graphviz
typst typst
charm-freeze
]); ]);
} }

View file

@ -33,16 +33,16 @@ overlay:
echo nixosConfigAttrs().join(" ") echo nixosConfigAttrs().join(" ")
proc update(yes: bool = false) = proc update(yes: bool = false) =
## *TBD* update and run nixos-rebuild ## *TBI* update and run nixos-rebuild
fatal "not implemented" fatal "not implemented"
proc build(minimal: bool = false) = proc build(minimal: bool = false) =
## nix build ## nix build
nixBuild(minimal, rest) nixBuild(minimal, rest)
proc cache(name: string = "daylin") = proc cache(minimal: bool = false, name: string = "daylin") =
## *TBD* 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
@ -52,12 +52,11 @@ overlay:
error ( error (
&"unknown nixos-rebuild subcmd: {subcmd}\nexpected one of: \n" & &"unknown nixos-rebuild subcmd: {subcmd}\nexpected one of: \n" &
nixosSubcmds.mapIt(" " & it).join("\n") nixosSubcmds.mapIt(" " & it).join("\n")
) ); quit QuitFailure
quit QuitFailure
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`)
@ -67,7 +66,7 @@ proc checkExes() =
quit("oizys requires nix", QuitFailure) quit("oizys requires nix", QuitFailure)
proc `//`(t1: Table[string, string], t2: Table[string, string]): Table[string, string] = proc `//`(t1: Table[string, string], t2: Table[string, string]): Table[string, string] =
# nix style table merge # nix style shallow table merge
for k, v in t1.pairs(): result[k] = v for k, v in t1.pairs(): result[k] = v
for k, v in t2.pairs(): result[k] = v for k, v in t2.pairs(): result[k] = v

View file

@ -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) =

View file

@ -38,7 +38,7 @@ const defaultFlushThreshold = lvlAll
proc genFmtStr( proc genFmtStr(
fmtPrefix, fmtSep, fmtSuffix, levelBb: string, fmtPrefix, fmtSep, fmtSuffix, levelBb: string,
level: Level level: Level
): string = ): string =
var parts: seq[string] var parts: seq[string]
if fmtPrefix != "": parts.add fmtPrefix if fmtPrefix != "": parts.add fmtPrefix
parts.add $LevelNames[level].bb(levelBb) parts.add $LevelNames[level].bb(levelBb)
@ -58,8 +58,8 @@ proc newFancyConsoleLogger*(
warnBb: string = "bold yellow", warnBb: string = "bold yellow",
errorBb: string = "bold red", errorBb: string = "bold red",
fatalBb: string = "bold red" fatalBb: string = "bold red"
): FancyConsoleLogger = ): FancyConsoleLogger =
## Creates a new `ColoredConsoleLogger<#ConsoleLogger>`_. ## Creates a new `FancyConsoleLogger<#ConsoleLogger>`_.
new result new result
let fmtStrs: array[Level, string] = [ let fmtStrs: array[Level, string] = [
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, "", lvlAll), genFmtStr(fmtPrefix,fmtSep, fmtSuffix, "", lvlAll),

View file

@ -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