Skip to content

Instantly share code, notes, and snippets.

@tokudan
Created May 9, 2016 23:52
Show Gist options
  • Select an option

  • Save tokudan/ff3d11cac2ebe8318e24be76a6d87343 to your computer and use it in GitHub Desktop.

Select an option

Save tokudan/ff3d11cac2ebe8318e24be76a6d87343 to your computer and use it in GitHub Desktop.
#!/run/current-system/sw/bin/gawk -f
function enumerate(option, cmd, value, o) {
cmd = "nixos-option " option " 2>/dev/null"
#print cmd
value = ""
while(cmd | getline && (value == "")) {
if($0 == "Value:") {
cmd | getline value
print option " = " substr(value, 1, 50)
} else {
o = option "." $1
#print o
enumerate(o)
}
}
close(cmd)
}
BEGIN {
while("nixos-option 2>/dev/null" | getline) {
option = $1
#print option
enumerate(option)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment