Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for nix-build to have a flag that disables the checkPhase. #55425

Closed
CMCDragonkai opened this issue Feb 8, 2019 · 9 comments
Closed

Comments

@CMCDragonkai
Copy link
Member

This is a feature request. I would find it quite useful to have a flag with nix-build to skip the checkPhase. I know this is possible by overriding the derivation, wouldn't having a flag for this be way more convenient so that it can be done on the command line instead.

The main reason for this is that in some cases tests cannot be run on the machine where the build is occurring. For example I have an application that has a checkPhase running tests that involve the GPU. But on machines without the GPU they can still build the output, but cannot run the tests.

@matthewbauer
Copy link
Member

This will probably require changing how Nix works. Right now if you set doCheck = false everywhere, Nix will try to rebuild all of your packages with doCheck = true and you can't use the binary cache. We need a way to tell Nix that some attrs are "impure" and to not put them in the .drv file.

@FRidh
Copy link
Member

FRidh commented Feb 8, 2019

Probably best then to move the tests into a separate derivation and use requiredSystemFeatures in that one.

Anyway, this is a Nix issue, not Nixpkgs, so closing.

@FRidh FRidh closed this as completed Feb 8, 2019
@CMCDragonkai
Copy link
Member Author

What do you mean requiredSystemFeatures?

@FRidh
Copy link
Member

FRidh commented Mar 5, 2019

@CMCDragonkai please check the Nix manual...

@danbst
Copy link
Contributor

danbst commented Mar 7, 2019

btw, there is also config.doCheckByDefault

@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented Mar 26, 2019

@FRidh So I see that requiredSystemFeatures can be used in conjunction with system-features of the nix.conf. This basically allows us to state that a derivation can only run on a system with given set of features. Are these features just arbitrary strings? Is there a way to say nvidia and for something to actually check if an NVIDIA GPU exists? Or is that something I need to code into the configuration.nix by checking for the existence of /dev/nvidiactl?

@FRidh
Copy link
Member

FRidh commented Mar 26, 2019

These are indeed just strings. No, there is no way to check for this, it's all declarative.

@raboof
Copy link
Member

raboof commented Sep 25, 2023

(sorry to revive such an old issue, but it seems it's still well-indexed by search engines)

I have an application that has a checkPhase running tests that involve the GPU. But on machines without the GPU they can still build the output, but cannot run the tests.

Where possible it's preferable to move those from checkPhase (or installCheckPhase) to passthru.tests - more details in https://nixos.org/manual/nixpkgs/unstable/#var-meta-tests

@hraban
Copy link
Member

hraban commented May 19, 2024

Anyway, this is a Nix issue, not Nixpkgs, so closing.

I thought the very concept of the checkPhase, or just phases in general, was not just nixpkgs but stdenv specific. How is it a nix issue?

A work-around for anyone who needs to rebuild an entire system from stdenv as fast as possible without checks:

nix build --impure --expr '
let
  disableCheckIfDeriv = deriv: (deriv.overrideAttrs or (_: deriv)) {doCheck = false; doInstallCheck = false;};
  p = import /your/nixpkgs {
    config = {replaceStdenv = {pkgs}: pkgs.fastStdenv; };
    overlays = [(self: builtins.mapAttrs (name: disableCheckIfDeriv))];
  };
in
  p.hello
'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants