diff --git a/flake.nix b/flake.nix index ed8ca4241..fef117d58 100644 --- a/flake.nix +++ b/flake.nix @@ -194,7 +194,7 @@ buildDeps = calledPackage.buildInputs; - checkDeps = calledPackage.finalAttrs._checkInputs; + checkDeps = calledPackage.finalAttrs.passthru._checkInputs; internalApiDocsDeps = [ buildPackages.doxygen @@ -237,51 +237,40 @@ echo "file installer $out/install" >> $out/nix-support/hydra-build-products ''; - testNixVersions = pkgs: client: daemon: with commonDeps { inherit pkgs; }; with pkgs.lib; pkgs.stdenv.mkDerivation { + testNixVersions = pkgs: client: daemon: let + nix = pkgs.callPackage ./package.nix { + pname = + "nix-tests" + + lib.optionalString + (lib.versionAtLeast daemon.version "2.4pre20211005" && + lib.versionAtLeast client.version "2.4pre20211005") + "-${client.version}-against-${daemon.version}"; + + inherit fileset; + }; + in nix.overrideAttrs (prevAttrs: { NIX_DAEMON_PACKAGE = daemon; NIX_CLIENT_PACKAGE = client; - name = - "nix-tests" - + optionalString - (versionAtLeast daemon.version "2.4pre20211005" && - versionAtLeast client.version "2.4pre20211005") - "-${client.version}-against-${daemon.version}"; - inherit version; - src = fileset.toSource { - root = ./.; - fileset = fileset.intersection baseFiles (fileset.unions [ - configureFiles - topLevelBuildFiles - functionalTestFiles - ]); - }; - - VERSION_SUFFIX = versionSuffix; - - nativeBuildInputs = nativeBuildDeps; - buildInputs = buildDeps ++ awsDeps ++ checkDeps; - propagatedBuildInputs = propagatedDeps; - - enableParallelBuilding = true; - - configureFlags = - testConfigureFlags # otherwise configure fails - ++ [ "--disable-build" ]; dontBuild = true; doInstallCheck = true; + configureFlags = [ + "RAPIDCHECK_HEADERS=${lib.getDev pkgs.rapidcheck}/extras/gtest/include" + "--disable-build" + ]; + installPhase = '' mkdir -p $out ''; - installCheckPhase = (optionalString pkgs.stdenv.hostPlatform.isDarwin '' + installCheckPhase = (lib.optionalString pkgs.stdenv.hostPlatform.isDarwin '' export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES '') + '' mkdir -p src/nix-channel make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES ''; - }; + }); binaryTarball = nix: pkgs: let diff --git a/package.nix b/package.nix index 15c683cfe..f526f5867 100644 --- a/package.nix +++ b/package.nix @@ -88,24 +88,63 @@ customMemoryManagement = false; }; - testConfigureFlags = [ - "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" + testConfigureFlags = [ + "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" + ]; + + configureFiles = fileset.unions [ + ./.version + ./configure.ac + ./m4 + # TODO: do we really need README.md? It doesn't seem used in the build. + ./README.md + ]; + + topLevelBuildFiles = fileset.unions [ + ./local.mk + ./Makefile + ./Makefile.config.in + ./mk + ]; + + functionalTestFiles = fileset.unions [ + ./tests/functional + ./tests/unit + (fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts) ]; in stdenv.mkDerivation (finalAttrs: { inherit pname version; - inherit src; + src = fileset.toSource { + root = ./.; + fileset = fileset.intersection baseFiles (fileset.unions ([ + configureFiles + topLevelBuildFiles + functionalTestFiles + ./unit-test-data + ] ++ lib.optionals finalAttrs.doBuild [ + ./boehmgc-coroutine-sp-fallback.diff + ./doc + ./misc + ./precompiled-headers.h + ./src + ./COPYING + ./scripts/local.mk + ])); + }; VERSION_SUFFIX = versionSuffix; - outputs = [ "out" "dev" "doc" ]; + outputs = [ "out" ] + ++ lib.optionals finalAttrs.doBuild [ "dev" "doc" ]; doBuild = !(finalAttrs.dontBuild or false); nativeBuildInputs = [ bison flex + ] ++ [ (lib.getBin lowdown) mdbook mdbook-linkcheck @@ -149,6 +188,9 @@ in stdenv.mkDerivation (finalAttrs: { rapidcheck ]; + # FIXME(Qyriad): remove at the end of refactoring. + checkInputs = finalAttrs.passthru._checkInputs; + propagatedBuildInputs = [ boehmgc nlohmann_json @@ -158,7 +200,7 @@ in stdenv.mkDerivation (finalAttrs: { boost ]; - preConfigure = lib.optionalString (! stdenv.hostPlatform.isStatic) '' + preConfigure = lib.optionalString (finalAttrs.doBuild && (! stdenv.hostPlatform.isStatic)) '' # Copy libboost_context so we don't get all of Boost in our closure. # https://github.com/NixOS/nixpkgs/issues/45462 mkdir -p $out/lib @@ -221,7 +263,7 @@ in stdenv.mkDerivation (finalAttrs: { export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ''; - separateDebugInfo = !stdenv.hostPlatform.isStatic; + separateDebugInfo = !stdenv.hostPlatform.isStatic && finalAttrs.doBuild; strictDeps = true;