mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-13 19:27:53 -06:00
Compare commits
3 commits
0b0132ee6d
...
912be37cc0
Author | SHA1 | Date | |
---|---|---|---|
912be37cc0 | |||
af28544102 | |||
dba9b0c0e1 |
5 changed files with 45 additions and 12 deletions
|
@ -8,5 +8,6 @@
|
|||
cachix
|
||||
graphviz
|
||||
typst
|
||||
charm-freeze
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -33,16 +33,16 @@ overlay:
|
|||
echo nixosConfigAttrs().join(" ")
|
||||
|
||||
proc update(yes: bool = false) =
|
||||
## *TBD* update and run nixos-rebuild
|
||||
## *TBI* update and run nixos-rebuild
|
||||
fatal "not implemented"
|
||||
|
||||
proc build(minimal: bool = false) =
|
||||
## nix build
|
||||
nixBuild(minimal, rest)
|
||||
|
||||
proc cache(name: string = "daylin") =
|
||||
## *TBD* build and push to cachix
|
||||
fatal "not implemented"
|
||||
proc cache(minimal: bool = false, name: string = "daylin") =
|
||||
## build and push to cachix
|
||||
nixBuildWithCache(minimal, name, rest)
|
||||
|
||||
proc osCmd() =
|
||||
## nixos-rebuild
|
||||
|
@ -52,12 +52,11 @@ overlay:
|
|||
error (
|
||||
&"unknown nixos-rebuild subcmd: {subcmd}\nexpected one of: \n" &
|
||||
nixosSubcmds.mapIt(" " & it).join("\n")
|
||||
)
|
||||
quit QuitFailure
|
||||
); quit QuitFailure
|
||||
nixosRebuild(subcmd, rest[1..^1])
|
||||
|
||||
proc ci(`ref`: string = "main") =
|
||||
## *TBD* trigger GHA update flow
|
||||
## trigger GHA update flow
|
||||
if rest.len == 0:
|
||||
fatal "expected workflow file name"; quit QuitFailure
|
||||
createDispatch(rest[0], `ref`)
|
||||
|
@ -67,7 +66,7 @@ proc checkExes() =
|
|||
quit("oizys requires nix", QuitFailure)
|
||||
|
||||
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 t2.pairs(): result[k] = v
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import std/[
|
|||
import ./spin
|
||||
|
||||
|
||||
func addArgs*(cmd: var string, args: seq[string]) =
|
||||
func addArgs*(cmd: var string, args: openArray[string]) =
|
||||
cmd &= " " & args.join(" ")
|
||||
|
||||
func addArg*(cmd: var string, arg: string) =
|
||||
|
|
|
@ -38,7 +38,7 @@ const defaultFlushThreshold = lvlAll
|
|||
proc genFmtStr(
|
||||
fmtPrefix, fmtSep, fmtSuffix, levelBb: string,
|
||||
level: Level
|
||||
): string =
|
||||
): string =
|
||||
var parts: seq[string]
|
||||
if fmtPrefix != "": parts.add fmtPrefix
|
||||
parts.add $LevelNames[level].bb(levelBb)
|
||||
|
@ -58,8 +58,8 @@ proc newFancyConsoleLogger*(
|
|||
warnBb: string = "bold yellow",
|
||||
errorBb: string = "bold red",
|
||||
fatalBb: string = "bold red"
|
||||
): FancyConsoleLogger =
|
||||
## Creates a new `ColoredConsoleLogger<#ConsoleLogger>`_.
|
||||
): FancyConsoleLogger =
|
||||
## Creates a new `FancyConsoleLogger<#ConsoleLogger>`_.
|
||||
new result
|
||||
let fmtStrs: array[Level, string] = [
|
||||
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, "", lvlAll),
|
||||
|
|
|
@ -203,10 +203,12 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
|||
quit "exiting...", QuitSuccess
|
||||
cmd.addArgs drvs
|
||||
cmd.addArg "--no-link"
|
||||
|
||||
if isCi():
|
||||
writeDervationsToStepSummary drvs
|
||||
else:
|
||||
cmd.addArgs nixosConfigAttrs()
|
||||
|
||||
cmd.addArg "--dry-run"
|
||||
cmd.addArgs rest
|
||||
let (_, err) =
|
||||
|
@ -214,4 +216,35 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
|||
let output = parseDryRunOutput err
|
||||
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