diff options
Diffstat (limited to 'package.nix')
-rw-r--r-- | package.nix | 300 |
1 files changed, 158 insertions, 142 deletions
diff --git a/package.nix b/package.nix index d096b5c73..e1d3cfcd5 100644 --- a/package.nix +++ b/package.nix @@ -69,9 +69,7 @@ __forDefaults ? { canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform; - boehmgc-nix = (boehmgc.override { - enableLargeConfig = true; - }).overrideAttrs { + boehmgc-nix = (boehmgc.override { enableLargeConfig = true; }).overrideAttrs { patches = [ # We do *not* include prev.patches (which doesn't exist in normal pkgs.boehmgc anyway) # because if the caller of this package passed a patched boehm as `boehmgc` instead of @@ -85,20 +83,22 @@ lix-doc = pkgs.callPackage ./lix-doc/package.nix { }; }, -}: let +}: +let inherit (__forDefaults) canRunInstalled; inherit (lib) fileset; version = lib.fileContents ./.version + versionSuffix; aws-sdk-cpp-nix = aws-sdk-cpp.override { - apis = [ "s3" "transfer" ]; + apis = [ + "s3" + "transfer" + ]; customMemoryManagement = false; }; - testConfigureFlags = [ - "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" - ]; + testConfigureFlags = [ "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. @@ -120,48 +120,60 @@ ./README.md ]; - topLevelBuildFiles = fileset.unions ([ - ./local.mk - ./Makefile - ./Makefile.config.in - ./mk - ] ++ lib.optionals buildWithMeson [ - ./meson.build - ./meson.options - ./meson - ./scripts/meson.build - ]); - - functionalTestFiles = fileset.unions [ + topLevelBuildFiles = fileset.unions ( + [ + ./local.mk + ./Makefile + ./Makefile.config.in + ./mk + ] + ++ lib.optionals buildWithMeson [ + ./meson.build + ./meson.options + ./meson + ./scripts/meson.build + ] + ); + + functionalTestFiles = fileset.unions [ ./tests/functional ./tests/unit (fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts) - ]; - -in stdenv.mkDerivation (finalAttrs: { + ]; +in +stdenv.mkDerivation (finalAttrs: { inherit pname version; src = fileset.toSource { root = ./.; - fileset = fileset.intersection baseFiles (fileset.unions ([ - configureFiles - topLevelBuildFiles - functionalTestFiles - ] ++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [ - ./boehmgc-coroutine-sp-fallback.diff - ./doc - ./misc - ./precompiled-headers.h - ./src - ./COPYING - ./scripts/local.mk - ])); + fileset = fileset.intersection baseFiles ( + fileset.unions ( + [ + configureFiles + topLevelBuildFiles + functionalTestFiles + ] + ++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [ + ./boehmgc-coroutine-sp-fallback.diff + ./doc + ./misc + ./precompiled-headers.h + ./src + ./COPYING + ./scripts/local.mk + ] + ) + ); }; VERSION_SUFFIX = versionSuffix; - outputs = [ "out" ] - ++ lib.optionals (!finalAttrs.dontBuild) [ "dev" "doc" ]; + outputs = + [ "out" ] + ++ lib.optionals (!finalAttrs.dontBuild) [ + "dev" + "doc" + ]; dontBuild = false; @@ -173,53 +185,61 @@ in stdenv.mkDerivation (finalAttrs: { # We only include CMake so that Meson can locate toml11, which only ships CMake dependency metadata. dontUseCmakeConfigure = true; - nativeBuildInputs = [ - bison - flex - python3 - ] ++ [ - (lib.getBin lowdown) - mdbook - mdbook-linkcheck - autoconf-archive - ] ++ lib.optional (!buildWithMeson) autoreconfHook ++ [ - pkg-config - - # Tests - git - mercurial - jq - lsof - ] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal + nativeBuildInputs = + [ + bison + flex + python3 + ] + ++ [ + (lib.getBin lowdown) + mdbook + mdbook-linkcheck + autoconf-archive + ] + ++ lib.optional (!buildWithMeson) autoreconfHook + ++ [ + pkg-config + + # Tests + git + mercurial + jq + lsof + ] + ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal ++ lib.optional (!officialRelease && buildUnreleasedNotes) build-release-notes ++ lib.optional internalApiDocs doxygen ++ lib.optionals buildWithMeson [ meson ninja cmake - ]; + ]; - buildInputs = [ - curl - bzip2 - xz - brotli - editline - openssl - sqlite - libarchive - boost - lowdown - libsodium - toml11 - lix-doc - ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ libseccomp busybox-sandbox-shell ] + buildInputs = + [ + curl + bzip2 + xz + brotli + editline + openssl + sqlite + libarchive + boost + lowdown + libsodium + toml11 + lix-doc + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + libseccomp + busybox-sandbox-shell + ] ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid # There have been issues building these dependencies ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix - ++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs - ; + ++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs; checkInputs = [ gtest @@ -228,9 +248,7 @@ in stdenv.mkDerivation (finalAttrs: { propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs; - disallowedReferences = [ - boost - ]; + disallowedReferences = [ boost ]; # Needed for Meson to find Boost. # https://github.com/NixOS/nixpkgs/issues/86131. @@ -239,46 +257,47 @@ in stdenv.mkDerivation (finalAttrs: { BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; }; - preConfigure = lib.optionalString (!finalAttrs.dontBuild && !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 - cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib - rm -f $out/lib/*.a - '' + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isLinux) '' - chmod u+w $out/lib/*.so.* - patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.* - '' + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isDarwin) '' - for LIB in $out/lib/*.dylib; do - chmod u+w $LIB - install_name_tool -id $LIB $LIB - install_name_tool -delete_rpath ${boost}/lib/ $LIB || true - done - install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib - '' + '' - # Workaround https://github.com/NixOS/nixpkgs/issues/294890. - if [[ -n "''${doCheck:-}" ]]; then - appendToVar configureFlags "--enable-tests" - else - appendToVar configureFlags "--disable-tests" - fi - ''; - - configureFlags = [ - "--with-boost=${boost}/lib" - ] ++ lib.optionals stdenv.isLinux [ - "--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox" - ] ++ lib.optionals (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) [ - "LDFLAGS=-fuse-ld=gold" - ] + preConfigure = + lib.optionalString (!finalAttrs.dontBuild && !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 + cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib + rm -f $out/lib/*.a + '' + + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isLinux) '' + chmod u+w $out/lib/*.so.* + patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.* + '' + + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isDarwin) '' + for LIB in $out/lib/*.dylib; do + chmod u+w $LIB + install_name_tool -id $LIB $LIB + install_name_tool -delete_rpath ${boost}/lib/ $LIB || true + done + install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib + '' + + '' + # Workaround https://github.com/NixOS/nixpkgs/issues/294890. + if [[ -n "''${doCheck:-}" ]]; then + appendToVar configureFlags "--enable-tests" + else + appendToVar configureFlags "--disable-tests" + fi + ''; + + configureFlags = + [ "--with-boost=${boost}/lib" ] + ++ lib.optionals stdenv.isLinux [ "--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox" ] + ++ lib.optionals ( + stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux") + ) [ "LDFLAGS=-fuse-ld=gold" ] ++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" ++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags ++ lib.optional (!canRunInstalled) "--disable-doc-gen" ++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ] ++ lib.optional (!forDevShell) "--sysconfdir=/etc" - ++ [ - "TOML11_HEADERS=${lib.getDev toml11}/include" - ]; + ++ [ "TOML11_HEADERS=${lib.getDev toml11}/include" ]; mesonBuildType = lib.optional (buildWithMeson || forDevShell) "debugoptimized"; @@ -290,37 +309,37 @@ in stdenv.mkDerivation (finalAttrs: { doCheck = true; - mesonCheckFlags = lib.optionals (buildWithMeson || forDevShell) [ - "--suite=check" - ]; + mesonCheckFlags = lib.optionals (buildWithMeson || forDevShell) [ "--suite=check" ]; installFlags = "sysconfdir=$(out)/etc"; - 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 '' - for lib in libnixutil.dylib libnixexpr.dylib; do - install_name_tool \ - -change "${lib.getLib boost}/lib/libboost_context.dylib" \ - "$out/lib/libboost_context.dylib" \ - "$out/lib/$lib" - done - '' + 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" - ''; + 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 '' + for lib in libnixutil.dylib libnixexpr.dylib; do + install_name_tool \ + -change "${lib.getLib boost}/lib/libboost_context.dylib" \ + "$out/lib/libboost_context.dylib" \ + "$out/lib/$lib" + done + '' + + 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; installCheckFlags = "sysconfdir=$(out)/etc"; installCheckTarget = "installcheck"; # work around buggy detection in stdenv - mesonInstallCheckFlags = [ - "--suite=installcheck" - ]; + mesonInstallCheckFlags = [ "--suite=installcheck" ]; preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin '' export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES @@ -338,14 +357,11 @@ in stdenv.mkDerivation (finalAttrs: { strictDeps = true; # strictoverflow is disabled because we trap on signed overflow instead - hardeningDisable = [ "strictoverflow" ] - ++ lib.optional stdenv.hostPlatform.isStatic "pie"; + hardeningDisable = [ "strictoverflow" ] ++ lib.optional stdenv.hostPlatform.isStatic "pie"; meta.platforms = lib.platforms.unix; - passthru.perl-bindings = pkgs.callPackage ./perl { - inherit fileset stdenv buildWithMeson; - }; + passthru.perl-bindings = pkgs.callPackage ./perl { inherit fileset stdenv buildWithMeson; }; # Export the patched version of boehmgc. # flake.nix exports that into its overlay. |