mirror of
https://github.com/h7x4/nix-attr-search.git
synced 2025-01-15 22:44:47 +01:00
h7x4
f6217e4c54
The project has grown quite a bit without me remembering to make any commits... Here's a summary of what has happened: - Make the project friendly towards non-flake users - Add searchers to be created: `nur-package-search`, `nix-lib-search` - Add misc util scripts for formatting and testing code. - Split templates into their own directory, as they get quite large after a while. - Add colorized templates. - Replace some of the xml tags with optionally colorized output. - Add `--no-color` option - Add json2nix script, which will convert the json-converted nix code back into nix.
18 lines
637 B
Nix
18 lines
637 B
Nix
{ pkgs, home-manager-options, json2nix }:
|
|
pkgs.writers.writeBash "nix-attrs-search-test-json2nix" ''
|
|
ELEMENT_COUNT=$(${jq} 'keys | length' ${home-manager-options}/share/doc/home-manager/options.json)
|
|
echo "Trying $(($ELEMENT_COUNT - 1)) elements"
|
|
for i in $(seq 0 $(($ELEMENT_COUNT - 1))); do
|
|
if ! (($i % 100)); then
|
|
echo "$i..."
|
|
fi
|
|
DEFAULT_VAL=$(${jq} "[.[]][$i].default" ${home-manager-options}/share/doc/home-manager/options.json)
|
|
ERROR_MESSAGE=$( { echo $DEFAULT_VAL | ${json2nix} | ${nixfmt} } 2>&1 )
|
|
if [ $? != 0 ]; then
|
|
echo "[$i] ERROR:"
|
|
echo $DEFAULT_VAL
|
|
echo $ERROR_MESSAGE
|
|
fi
|
|
done
|
|
''
|