1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

fix darwin-option descriptions

Also drops the eval hacks in favour of jq.
This commit is contained in:
Daiderd Jordan 2023-06-25 13:03:49 +02:00
parent 53c6748f98
commit cb37c35e33
No known key found for this signature in database
GPG key ID: 373D8D8DF3FDA129
2 changed files with 11 additions and 14 deletions

View file

@ -16,8 +16,8 @@ let
darwin-option = writeProgram "darwin-option"
{
inherit (config.system) profile;
inherit (stdenv) shell;
path = "${extraPath}:${config.environment.systemPath}";
}
../../pkgs/nix-tools/darwin-option.sh;

View file

@ -4,26 +4,24 @@ set -o pipefail
export PATH=@path@:$PATH
evalNix() {
nix-instantiate --eval --strict "${extraEvalFlags[@]}" -E "with import <darwin> {}; $*"
}
evalAttrs() {
evalNix "builtins.concatStringsSep \"\\n\" (builtins.attrNames $*)"
nix-instantiate --eval --strict "${extraEvalFlags[@]}" -E "with import <darwin> {}; $*" 2>/dev/null
}
evalOpt() {
evalNix "options.$option.$*" 2>/dev/null
evalNix "options.$option.$*"
}
evalOptAttrs() {
evalNix "builtins.concatStringsSep \"\\n\" (builtins.attrNames $*)" | jq -r .
}
evalOptText() {
eval printf "$(evalNix "options.$option.$*" 2>/dev/null)" 2>/dev/null
echo
evalNix "options.$option.$*" | jq -r .
}
showSyntax() {
echo "$0: [-I path] <option>" >&2
eval printf "$(evalAttrs "options")"
echo
evalOptAttrs "options"
exit 1
}
@ -69,9 +67,8 @@ if [ "$(evalOpt "_type")" = '"option"' ]; then
fi
echo
echo "Description:"
evalOptText "description" || echo "no description"
evalOptText "description.text" || echo "no description"
echo
else
eval printf "$(evalAttrs "options.$option")" 2>/dev/null
echo
evalOptAttrs "options.$option"
fi