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" ... "nixos config attr"
flags: flags:
^minimal ^minimal
system:
? "show system path"
run: run:
if not minimal: if minimal and system:
echo nixosConfigAttrs().join(" ") echo "--minimal and --system are mutually exclusive"
else: elif minimal:
showOizysDerivations() showOizysDerivations()
elif system:
echo getSystemPaths().mapIt(it & "^*").join(" ")
else:
echo nixosConfigAttrs().join(" ")
[update] [update]
... "update and run nixos-rebuild" ... "update and run nixos-rebuild"
flags: flags:

View file

@ -198,6 +198,7 @@ proc nixDerivationShow*(drvs: openArray[string]): Table[string, NixDerivation] =
runCmdCaptWithSpinner(cmd, "evaluating " & drvs.join(" ")) runCmdCaptWithSpinner(cmd, "evaluating " & drvs.join(" "))
fromJson(output, Table[string, NixDerivation]) fromJson(output, Table[string, NixDerivation])
# TODO: replace asserts in this proc, would be easier with results type # TODO: replace asserts in this proc, would be easier with results type
proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] = proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] =
let hosts = getHosts() let hosts = getHosts()
@ -214,6 +215,10 @@ proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] =
assert len(hosts) == len(result) 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( proc filterSeq(
drvs: seq[string], drvs: seq[string],
@ -240,6 +245,7 @@ func isIgnored(drv: string): bool =
proc getSystemPathDrvs*(): seq[string] = proc getSystemPathDrvs*(): seq[string] =
let systemDrvs = nixDerivationShow(nixosConfigAttrs()) let systemDrvs = nixDerivationShow(nixosConfigAttrs())
let systemPathDrvs = findSystemPaths(systemDrvs) let systemPathDrvs = findSystemPaths(systemDrvs)
result = result =
collect: collect:
for k, drv in nixDerivationShow(systemPathDrvs): for k, drv in nixDerivationShow(systemPathDrvs):