nix flake check do not exit non zero if errors are ignored
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 17.7k
- Forks
- 2k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 80
Description
Is your feature request related to a problem? Please describe.
We want to lint 100% of our nix in CI without building everyting.
Describe the solution you'd like
Lint command should exit with zero if not blocking error happened
Describe alternatives you've considered
I tried to find some good linter with selector, not found.
Additional context
-
clone https://github.com/ComposableFi/composable/blob/main/.github/workflows/check-nix-long.sh
-
run in root (ignores some yarn errors - errors are here, but when these build - all is okey - so these are false positive)
NIX_DEBUG_COMMAND="" && [[ $ACTIONS_RUNNER_DEBUG = "true" ]] && NIX_DEBUG_COMMAND='--print-build-logs --debug --show-trace --verbose'
set -o pipefail -o errexit
NIXPKGS_ALLOW_BROKEN=1 nix flake check --keep-going --no-build --allow-import-from-derivation --no-update-lock-file --fallback -L ${NIX_DEBUG_COMMAND} --impure --option sandbox relaxed --impure 2>&1 | tee "nix.check.log" || true
set +o pipefail +o errexit
echo "exited with(https://github.com/NixOS/nix/issues/7464) ${$?}"
cat "nix.check.log" | grep --invert-match "error: path [']/nix/store/[a-zA-Z0-9]\+-[a-zA-Z0-9\.-]\+['] is not valid" \
| grep --invert-match "error: cannot substitute path [']/nix/store/[a-zA-Z0-9]\+-[a-zA-Z0-9\.-]\+['] \- no write access to the Nix store" \
| grep --invert-match '^error: some errors were encountered during the evaluation' > "filtered.nix.check.log"
RESULT=$(cat "filtered.nix.check.log" | grep -c 'error:')
echo "Got errors $RESULT"
if [[ $RESULT != 0 ]]; then exit $RESULT; fi
- it will produce
warning: Git tree '/home/dz/github.com/ComposableFi/composable' is dirty
evaluating flake...
error (ignored): error: cannot substitute path '/nix/store/17gk3kdfgwslrj1mrw7nfhmx23d4ra4c-source' - no write access to the Nix store
....
error (ignored): error: cannot substitute path '/nix/store/17gk3kdfgwslrj1mrw7nfhmx23d4ra4c-source' - no write access to the Nix
error (ignored): error: cannot substitute path '/nix/store/17gk3kdfgwslrj1mrw7nfhmx23d4ra4c-source' - no write access to the Nix store
error (ignored): error: path '/nix/store/rgh7b0ja0id7l97aqhws1b8lgdl633bj-source.drv' is not valid
warning: unknown flake output 'darwinModules'
warning: unknown flake output 'nixopsConfigurations'
error: some errors were encountered during the evaluation
Actual
nix flake check will exit with non zero code
Expected
Zero exit code if ALL errors are ignored like error (ignored):, so these can be considered warnings.
Alternative some flag to treat such errors as warnings.
Priorities
Add 👍 to issues you find important.
This is one of 3+ other issues I found regarding nix shell error handling(nix lang error handling other topic) which will make nix more friendly.
Also this is """compiles""" flakes, which is great as nix moves toward """compilation"""
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using .github/workflows/check-nix-long.sh and the shown nix flake check command. Trace the nix flake check entry point and its handling of ignored errors; done means a check containing only errors marked ignored exits successfully, while non-ignored errors still produce a nonzero status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, shell
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100