add --system to oizys output

This commit is contained in:
Daylin Morgan 2025-02-17 12:33:15 -06:00
parent cbe0f41e6c
commit 244992f35b
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 15 additions and 4 deletions

View file

@ -138,12 +138,17 @@ hwylCli:
... "nixos config attr"
flags:
^minimal
system:
? "show system path"
run:
if not minimal:
echo nixosConfigAttrs().join(" ")
else:
if minimal and system:
echo "--minimal and --system are mutually exclusive"
elif minimal:
showOizysDerivations()
elif system:
echo getSystemPaths().mapIt(it & "^*").join(" ")
else:
echo nixosConfigAttrs().join(" ")
[update]
... "update and run nixos-rebuild"
flags:

View file

@ -198,6 +198,7 @@ proc nixDerivationShow*(drvs: openArray[string]): Table[string, NixDerivation] =
runCmdCaptWithSpinner(cmd, "evaluating " & drvs.join(" "))
fromJson(output, Table[string, NixDerivation])
# TODO: replace asserts in this proc, would be easier with results type
proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] =
let hosts = getHosts()
@ -214,6 +215,10 @@ proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] =
assert len(hosts) == len(result)
# NOTE: is find system paths always called after a nixDerivationShow?
proc getSystemPaths*(): seq[string] =
let systemDrvs = nixDerivationShow(nixosConfigAttrs())
result = findSystemPaths(systemDrvs)
proc filterSeq(
drvs: seq[string],
@ -240,6 +245,7 @@ func isIgnored(drv: string): bool =
proc getSystemPathDrvs*(): seq[string] =
let systemDrvs = nixDerivationShow(nixosConfigAttrs())
let systemPathDrvs = findSystemPaths(systemDrvs)
result =
collect:
for k, drv in nixDerivationShow(systemPathDrvs):