change to bootstrap mode

This commit is contained in:
Daylin Morgan 2025-02-17 14:01:43 -06:00
parent d78a333192
commit 50207f639a
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 13 additions and 14 deletions

View file

@ -28,10 +28,9 @@ hwylCli:
`reset-cache`: `reset-cache`:
? "set cache timeout to 0" ? "set cache timeout to 0"
ident resetCache ident resetCache
substitute: bootstrap:
? "use builtin substituter" ? "enable bootstrap mode"
- s - b
[misc] [misc]
yes: yes:
- y - y
@ -41,7 +40,7 @@ hwylCli:
- m - m
preSub: preSub:
setupLoggers() setupLoggers()
updateContext(host, flake, verbose, resetCache, substitute) updateContext(host, flake, verbose, resetCache, bootstrap)
subcommands: subcommands:
[build] [build]

View file

@ -12,7 +12,7 @@ type
ci: bool ci: bool
verbose: Count verbose: Count
resetCache: bool resetCache: bool
substitute: bool bootstrap: bool
let currentHost* = getHostName() let currentHost* = getHostName()
@ -36,7 +36,7 @@ proc getFlake*(): string = return oc.flake
proc isResetCache*(): bool = return oc.resetCache proc isResetCache*(): bool = return oc.resetCache
proc isCi*(): bool = return oc.ci proc isCi*(): bool = return oc.ci
proc isLocal*(): bool = return oc.flake.dirExists proc isLocal*(): bool = return oc.flake.dirExists
proc isSubstitute*(): bool = return oc.substitute proc isBootstrap*(): bool = return oc.bootstrap
@ -50,22 +50,21 @@ proc updateContext*(
flake: string, flake: string,
verbose: Count, verbose: Count,
resetCache: bool, resetCache: bool,
substitute: bool bootstrap: bool,
) = ) =
oc.verbose = verbose oc.verbose = verbose
oc.substitute = substitute oc.bootstrap = bootstrap
if host.len > 0: oc.hosts = host if host.len > 0: oc.hosts = host
if verbose.val > 1: if verbose.val > 1:
consoleLogger.levelThreshold = lvlAll consoleLogger.levelThreshold = lvlAll
oc.resetCache = resetCache oc.resetCache = resetCache
if flake != "": if flake != "":
oc.flake = oc.flake =
if flake.startsWith("github") or flake.startsWith("git+"): flake if bootstrap: oc.flake
elif flake.startsWith("github") or flake.startsWith("git+"): flake
else: checkPath(flake.normalizedPath().absolutePath()) else: checkPath(flake.normalizedPath().absolutePath())
debug bb(fmt"""[b]flake[/]: {oc.flake}, [b]hosts[/]: {oc.hosts.join(" ")}""") debug bb(fmt"""[b]flake[/]: {oc.flake}, [b]hosts[/]: {oc.hosts.join(" ")}""")
if not isLocal(): if not (isLocal() and isBootstrap()):
warn "not using local directory for flake" warn "not using local directory for flake"

View file

@ -22,6 +22,7 @@ type
`extra-substituters`: seq[string] `extra-substituters`: seq[string]
`extra-trusted-public-keys`: seq[string] `extra-trusted-public-keys`: seq[string]
# TODO: replace with nim string defines?
func makeSubFlags(): seq[string] = func makeSubFlags(): seq[string] =
let subs = slurp("substituters.json").fromJson(Substituters) let subs = slurp("substituters.json").fromJson(Substituters)
for k, v in subs.fieldPairs(): for k, v in subs.fieldPairs():
@ -43,7 +44,7 @@ proc nixCommand*(cmd: string, nom: bool = false): string =
result.addArg "--narinfo-cache-negative-ttl 0" result.addArg "--narinfo-cache-negative-ttl 0"
if not (nom or isCi()): if not (nom or isCi()):
result.addArg "--log-format multiline" result.addArg "--log-format multiline"
if isSubstitute(): if isBootstrap():
result.addArgs subFlags result.addArgs subFlags
proc nixosConfigAttr(host: string): string = proc nixosConfigAttr(host: string): string =