1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-25 18:35:01 +01:00

home-manager: make show news a bit more robust

This commit is contained in:
Robert Helgesson 2025-01-01 15:58:01 +01:00
parent 59a4c43e9b
commit 5518f9d439
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -807,23 +807,23 @@ function doShowNews() {
local readIdsFile
readIdsFile="$(newsReadIdsFile)"
local news
local newsAttr
# shellcheck disable=2154,2046
case $1 in
--all)
news="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).news.all")"
newsAttr="all"
;;
--unread)
news="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).news.unread")"
newsAttr="unread"
;;
*)
_i 'Unknown argument %s' "$1"
return 1
esac
# Prints the news without surrounding quotes.
echo -e "${news:1:-1}" | ${PAGER:-less}
nix-instantiate --quiet --eval --json --expr "(import ${newsNixFile}).news.$newsAttr" \
| jq -r . \
| ${PAGER:-less}
local allIds
allIds="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).meta.ids")"