home-manager: Prevent pipe failure when reading news
On my system (Fedora 43 with Nix 2.31.3) `home-manager news` exits from `SIGPIPE` and never writes `~/.local/share/home-manager/news-read-ids`, resulting in news items to never be marked read. This is caused by piping `(import ./news.nix).news.all` through `jq` and `less` failing with an error as soon as `less` exits, which triggers `set -o pipefail` to exit the shell running `home-manager` itself. Avoiding the pipe into `$PAGER` avoids the problem. Closes: https://github.com/nix-community/home-manager/issues/8690 References: https://github.com/jqlang/jq/issues/1017 References: https://www.greenend.org.uk/rjk/tech/shellmistakes.html#pipeerrors
This commit is contained in:
parent
984708c34d
commit
36349274d7
1 changed files with 3 additions and 1 deletions
|
|
@ -998,9 +998,11 @@ function doShowNews() {
|
|||
return 1
|
||||
esac
|
||||
|
||||
local formattedNewsFile="$WORK_DIR/news.txt"
|
||||
nix-instantiate --quiet --eval --json --expr "(import ${newsNixFile}).news.$newsAttr" \
|
||||
| jq -r . \
|
||||
| ${PAGER:-less}
|
||||
> "$formattedNewsFile"
|
||||
${PAGER:-less} "$formattedNewsFile"
|
||||
|
||||
local allIds
|
||||
allIds="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).meta.ids")"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue