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

Nix build issue #7809

Open
NaN-git opened this issue Feb 11, 2023 · 8 comments
Open

Nix build issue #7809

NaN-git opened this issue Feb 11, 2023 · 8 comments
Assignees
Labels
bug build-problem Nix fails to compile or test; also improvements to build process

Comments

@NaN-git
Copy link

NaN-git commented Feb 11, 2023

Describe the bug

Since the inclusion of rapidcheck the configure and make flow does not work anymore in a build shell.

Steps To Reproduce

  1. Run a build shell nix develop .#nix
  2. Then execute ./bootstrap.sh and ./configure
  3. Finally make aborts with
src/libutil/tests/hash.cc:5:10: fatal error: rapidcheck/gtest.h: No such file or directory
    5 | #include <rapidcheck/gtest.h>

Expected behavior

The build should work without applying additional flags to ./configure. Otherwise hacking on nix becomes very annoying.

Additional context

The issue is caused by non-standard include directories of rapidcheck and the workaround in the flake is

configureFlags = [
  "CXXFLAGS=-I${lib.getDev pkgs.rapidcheck}/extras/gtest/include"
];

Either the rapidcheck package should be modified so that the header is in a standard path or configure.ac should be modified to support rapidcheck specific arguments, which can be set by the flake instead of modifying configureFlags. Also a proper check for the library is missing in configure.ac.

I can write a patch for configure.ac, if I get the OK for such a change.

@NaN-git NaN-git added the bug label Feb 11, 2023
@alerque
Copy link

alerque commented Mar 1, 2023

Just ran into this error and this was the ONLY Google search result.

My case is not building a flake, but building the nix client itself from Arch Linux (for packaging in official repos).

@roberth roberth added the build-problem Nix fails to compile or test; also improvements to build process label Mar 16, 2023
@roberth
Copy link
Member

roberth commented Mar 16, 2023

It was changed to a separate variable in #7896. Is that an improvement?
The hacking instructions are up to date, but that's for users with a working nix. This seems to be about building from source, doc/manual/src/installation/building-source.md.
cc @Ericson2314

@Ericson2314 Ericson2314 self-assigned this Mar 16, 2023
@Ericson2314
Copy link
Member

Hi @NaN-git

Either the rapidcheck package should be modified so that the header is in a standard path

I opened emil-e/rapidcheck#302 to help with this. There could be both rapidcheck and rapidcheck-extras pkg-config modules, and then this issue would go away nicely.

Crickets on that issue; maybe the thing to do is just open a PR (and apply a patch in Nixpkgs ;)).

or configure.ac should be modified to support rapidcheck specific arguments, which can be set by the flake instead of modifying configureFlags.

See the separate variable as @roberth pointed out.

The build should work without applying additional flags to ./configure.

Perhaps we can also make --enable-tests have clever "auto" mode by default, based on what is present.

Also a proper check for the library is missing in configure.ac.

Note that AC_CHECK_LIBS will not work because C++. But I suppose there either other ways.

I can write a patch for configure.ac, if I get the OK for such a change.

I cannot unilaterally say "idea approved", but I personally will certainly review what you do if you open a PR. Please do!

@roberth
Copy link
Member

roberth commented Mar 16, 2023

If your environment is different, ie not our devshell or the nixpkgs build, that's all the more reason to run the tests.
It must not be possible for an otherwise normal looking package definition in a distro to build Nix without testing by accident. It should be fail safe. If a package definition opts out of testing for whatever reason, that should leave a "paper trail" so that others can discover that tests aren't run.

With this in mind, perhaps the autodetection could still produce a make check, but one that always fails, saying which dependency is missing. That way @NaN-git's request to configure without flags could be honored.

For our hacking setup such automatic behavior isn't great, so we could explicitly enable tests through our development shell.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-17-nix-team-meeting-minutes-41/26614/1

@NaN-git
Copy link
Author

NaN-git commented Apr 8, 2023

Sorry for the late reply. With the updated flake, documentation and configure.ac the build succeeds.
RAPIDCHECK_HEADERS looks a bit unfortunate though because it has to be set additionally, when nix is not built with nix.

@noamraph
Copy link

Since it took me some time to realize the workaround, I want to share it explicitly. Run:

./configure --disable-tests

YorikSar added a commit to YorikSar/nix that referenced this issue Aug 16, 2023
Allows to run `./configure` in `nix-shell` environment without
additional workarounds. See NixOS#7809
for more context.

Related to NixOS#7809 (but doesn't fix it)
@YorikSar
Copy link
Contributor

Ran into this issue while trying to run ./configure directly from nix-shell. Here's what I ended up using to reproduce workaround from flake:

./configure RAPIDCHECK_HEADERS=$(nix path-info --inputs-from . nixpkgs#rapidcheck)/extras/gtest/include

Posted #8834 to add this environment variable to all shells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug build-problem Nix fails to compile or test; also improvements to build process
Projects
None yet
Development

No branches or pull requests

7 participants