From b072c069b741d5939baf0350d53392197da3b2d7 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Fri, 8 Mar 2024 21:09:11 -0700 Subject: [PATCH] package: migrate internal-api-docs Change-Id: I344d73a412c2c6e4bb2eb14bd4859056324f1ba7 --- flake.nix | 41 ++++++++++++++++++----------------------- package.nix | 53 +++++++++++++++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/flake.nix b/flake.nix index e547846f8..f991e4d46 100644 --- a/flake.nix +++ b/flake.nix @@ -421,31 +421,26 @@ dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage); # API docs for Nix's unstable internal C++ interfaces. - internal-api-docs = - with nixpkgsFor.x86_64-linux.native; - with commonDeps { inherit pkgs; }; + internal-api-docs = let + nixpkgs = nixpkgsFor.x86_64-linux.native; + inherit (nixpkgs) pkgs; + comDeps = commonDeps { inherit pkgs; }; - stdenv.mkDerivation { - pname = "nix-internal-api-docs"; - inherit version; - - src = nixSrc; - - configureFlags = testConfigureFlags ++ internalApiDocsConfigureFlags; - - nativeBuildInputs = nativeBuildDeps; - buildInputs = buildDeps ++ propagatedDeps - ++ awsDeps ++ checkDeps ++ internalApiDocsDeps; - - dontBuild = true; - - installTargets = [ "internal-api-html" ]; - - postInstall = '' - mkdir -p $out/nix-support - echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> $out/nix-support/hydra-build-products - ''; + nix = nixpkgs.pkgs.callPackage ./package.nix { + inherit versionSuffix fileset officialRelease buildUnreleasedNotes; + inherit (comDeps) changelog-d; + internalApiDocs = true; + boehmgc = comDeps.boehmgc-nix; + busybox-sandbox-shell = comDeps.sh; }; + in + nix.overrideAttrs (prev: { + # This Hydra job is just for the internal API docs. + # We don't need the build artifacts here. + dontBuild = true; + doCheck = false; + doInstallCheck = false; + }); # System tests. tests = import ./tests/nixos { inherit lib nixpkgs nixpkgsFor; } // { diff --git a/package.nix b/package.nix index a6933b0ab..73e887d8d 100644 --- a/package.nix +++ b/package.nix @@ -13,6 +13,7 @@ brotli, bzip2, curl, + doxygen, editline, fileset, flex, @@ -42,6 +43,7 @@ officialRelease ? true, # Set to true to build the release notes for the next release. buildUnreleasedNotes ? false, + internalApiDocs ? false, # Not a real argument, just the only way to approximate let-binding some # stuff for argument defaults. @@ -62,6 +64,13 @@ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ]; + # The internal API docs need these for the build, but if we're not building + # Nix itself, then these don't need to be propagated. + maybePropagatedInputs = [ + boehmgc + nlohmann_json + ]; + # .gitignore has already been processed, so any changes in it are irrelevant # at this point. It is not represented verbatim for test purposes because # that would interfere with repo semantics. @@ -98,7 +107,7 @@ in stdenv.mkDerivation (finalAttrs: { topLevelBuildFiles functionalTestFiles ./unit-test-data - ] ++ lib.optionals (!finalAttrs.dontBuild) [ + ] ++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [ ./boehmgc-coroutine-sp-fallback.diff ./doc ./misc @@ -132,7 +141,9 @@ in stdenv.mkDerivation (finalAttrs: { mercurial jq ] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal - ++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d; + ++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d + ++ lib.optional internalApiDocs doxygen + ; buildInputs = [ curl @@ -153,6 +164,7 @@ in stdenv.mkDerivation (finalAttrs: { ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix # FIXME(Qyriad): This is how the flake.nix version does it, but this is cursed. ++ lib.optionals (finalAttrs.doCheck) finalAttrs.passthru._checkInputs + ++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs ; passthru._checkInputs = [ @@ -163,10 +175,7 @@ in stdenv.mkDerivation (finalAttrs: { # FIXME(Qyriad): remove at the end of refactoring. checkInputs = finalAttrs.passthru._checkInputs; - propagatedBuildInputs = [ - boehmgc - nlohmann_json - ]; + propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs; disallowedReferences = [ boost @@ -198,10 +207,13 @@ in stdenv.mkDerivation (finalAttrs: { ] ++ [ "--sysconfdir=/etc" ] ++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" ++ [ (lib.enableFeature finalAttrs.doCheck "tests") ] - ++ lib.optionals finalAttrs.doCheck testConfigureFlags + ++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags ++ lib.optional (!canRunInstalled) "--disable-doc-gen" + ++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ] ; + installTargets = lib.optional internalApiDocs "internal-api-html"; + enableParallelBuilding = true; makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1"; @@ -210,19 +222,20 @@ in stdenv.mkDerivation (finalAttrs: { installFlags = "sysconfdir=$(out)/etc"; - postInstall = '' - mkdir -p $doc/nix-support - echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products - ${lib.optionalString stdenv.hostPlatform.isStatic '' - mkdir -p $out/nix-support - echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products - ''} - ${lib.optionalString stdenv.isDarwin '' - install_name_tool \ - -change ${boost}/lib/libboost_context.dylib \ - $out/lib/libboost_context.dylib \ - $out/lib/libnixutil.dylib - ''} + postInstall = lib.optionalString (!finalAttrs.dontBuild) '' + mkdir -p $doc/nix-support + echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products + '' + lib.optionalString stdenv.hostPlatform.isStatic '' + mkdir -p $out/nix-support + echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products + '' + lib.optionalString stdenv.isDarwin '' + install_name_tool \ + -change ${boost}/lib/libboost_context.dylib \ + $out/lib/libboost_context.dylib \ + $out/lib/libnixutil.dylib + '' + lib.optionalString internalApiDocs '' + mkdir -p $out/nix-support + echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> "$out/nix-support/hydra-build-products" ''; doInstallCheck = finalAttrs.doCheck;