Skip to content

stdenv: fix succeedOnFailure#200917

Merged
roberth merged 2 commits intoNixOS:stagingfrom
SuperSandro2000:succeedOnFailure
Nov 15, 2022
Merged

stdenv: fix succeedOnFailure#200917
roberth merged 2 commits intoNixOS:stagingfrom
SuperSandro2000:succeedOnFailure

Conversation

@SuperSandro2000
Copy link
Member

@SuperSandro2000 SuperSandro2000 commented Nov 12, 2022

Description of changes

Closes #200663

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: stdenv Standard environment label Nov 12, 2022
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Nov 12, 2022
@roberth
Copy link
Member

roberth commented Nov 12, 2022

I believe this effect is better achieved via #196251
Otherwise lgtm.

Copy link
Member

@knedlsepp knedlsepp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used the following to confirm that it works as intended:

let
  pkgs = import ./. { };
in pkgs.runCommand "foo" {
  succeedOnFailure = true;
  } ''
    mkdir $out
    echo foo > $out/foo
    exit 1
  ''

Thank you! :-)

@roberth
Copy link
Member

roberth commented Nov 14, 2022

Apparently ofborg is quick enough to test a stdenv rebuild, so I've added @knedlsepp's test to the tests attribute.

@knedlsepp
Copy link
Member

@roberth thanks for adding a test. One note: Due to the nature of succeedOnFailure this test might show up on hydra as failed, which might be confusing. I'm not quite sure how to address that though.

@roberth
Copy link
Member

roberth commented Nov 15, 2022

@knedlsepp as far as I know, succeedOnFailure is just a stdenv concept that does not need anything beyond a normal derivation build to work correctly. Nix does not have a special interpretation of it, and I don't expect Hydra to have it either. (If it does, it will just succeed on Hydra, but still be useful on ofborg and all the other tools)

It does not invert the exit status either, like #196251 would.

@roberth roberth merged commit a9bd291 into NixOS:staging Nov 15, 2022
@SuperSandro2000 SuperSandro2000 deleted the succeedOnFailure branch November 15, 2022 20:52
@knedlsepp
Copy link
Member

knedlsepp commented Nov 16, 2022

@roberth

Nix does not have a special interpretation of it, and I don't expect Hydra to have it either.

It's true that nix itself does not have any special interpretation, but hydra does. It renders these outputs with a red cross as I'd they failed, but offers downloads in nix-support/hydra-build-products.
It is used in release-tools in nixpkgs such as coverageReport.

NixOS/hydra@039d1be

Anyway, I couldn't find the test that you added in the most recent hydra evaluation, so it doesn't really matter. 😄

Edit: Just noticed that I didn't look at the staging evaluation, but trunk. 🤔

@roberth
Copy link
Member

roberth commented Nov 16, 2022

That's a bad hack for something that should be solved by Nix itself, but alright then. By default the package tests attribute doesn't get built on Hydra, so it's probably fine.

tests = {
succeedOnFailure = import ../tests/succeedOnFailure.nix { inherit stdenv; };
};
passthru.tests = lib.warn "Use `stdenv.tests` instead. `passthru` is a `mkDerivation` detail." stdenv.tests;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be triggered by nix eval? I have encountered this on my system and other peoples and I am unsure if the issue is here or in nix eval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: stdenv Standard environment 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants