package: put boehmgc patch logic in package.nix

In our view it really doesn't make sense to not have this in in
package.nix in some way. These patches aren't just for performance or
something -- Lix flat out doesn't build without these patches.

(Arguably that makes them a buildsystem responsibility as well, but that
can wait for when we're ready to start adding subproject fallback
dependency resolution to Meson.)

This is a step towards making `package.nix` more self-sufficient and
`callPackage`able without excessive external logic.

With this change the following command is enough to build Lix from out
of the flake:

nix-build -E 'let pkgs = import <nixpkgs> { }; in pkgs.callPackage
./package.nix { build-release-notes = false; inherit (pkgs.lib) fileset;
nix-doc = pkgs.callPackage ./nix-doc/package.nix { }; }'

Change-Id: Ia37fe8171f87d3293033de8be07d9bab12716f1d
This commit is contained in:
Qyriad 2024-04-06 15:44:27 -06:00 committed by jade
parent 06e11778b5
commit 3ac2dd0613
2 changed files with 28 additions and 14 deletions

View file

@ -163,16 +163,6 @@
build-release-notes = build-release-notes =
final.buildPackages.callPackage ./maintainers/build-release-notes.nix { }; final.buildPackages.callPackage ./maintainers/build-release-notes.nix { };
clangbuildanalyzer = final.buildPackages.callPackage ./misc/clangbuildanalyzer.nix { }; clangbuildanalyzer = final.buildPackages.callPackage ./misc/clangbuildanalyzer.nix { };
boehmgc-nix = (final.boehmgc.override {
enableLargeConfig = true;
}).overrideAttrs (o: {
patches = (o.patches or [ ]) ++ [
./boehmgc-coroutine-sp-fallback.diff
# https://github.com/ivmai/bdwgc/pull/586
./boehmgc-traceable_allocator-public.diff
];
});
default-busybox-sandbox-shell = final.busybox.override { default-busybox-sandbox-shell = final.busybox.override {
useMusl = true; useMusl = true;
@ -203,10 +193,13 @@
nix = final.callPackage ./package.nix { nix = final.callPackage ./package.nix {
inherit versionSuffix fileset; inherit versionSuffix fileset;
stdenv = currentStdenv; stdenv = currentStdenv;
boehmgc = final.boehmgc-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell; busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
nix-doc = final.nix-doc; nix-doc = final.nix-doc;
}; };
# Export the patched version of boehmgc that Lix uses into the overlay
# for consumers of this flake.
boehmgc-nix = final.nix.boehmgc-nix;
}; };
in { in {
@ -268,7 +261,6 @@
inherit versionSuffix fileset officialRelease buildUnreleasedNotes; inherit versionSuffix fileset officialRelease buildUnreleasedNotes;
inherit (pkgs) build-release-notes; inherit (pkgs) build-release-notes;
internalApiDocs = true; internalApiDocs = true;
boehmgc = pkgs.boehmgc-nix;
busybox-sandbox-shell = pkgs.busybox-sandbox-shell; busybox-sandbox-shell = pkgs.busybox-sandbox-shell;
}; };
in in
@ -406,7 +398,6 @@
let let
nix = pkgs.callPackage ./package.nix { nix = pkgs.callPackage ./package.nix {
inherit stdenv versionSuffix fileset; inherit stdenv versionSuffix fileset;
boehmgc = pkgs.boehmgc-nix;
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox; busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox;
forDevShell = true; forDevShell = true;
}; };

View file

@ -5,6 +5,11 @@
autoconf-archive, autoconf-archive,
autoreconfHook, autoreconfHook,
aws-sdk-cpp, aws-sdk-cpp,
# If the patched version of Boehm isn't passed, then patch it based off of
# pkgs.boehmgc. This allows `callPackage`ing this file without needing to
# to implement behavior that this package flat out doesn't build without
# anyway, but also allows easily overriding the patch logic.
boehmgc-nix ? __forDefaults.boehmgc-nix,
boehmgc, boehmgc,
nlohmann_json, nlohmann_json,
bison, bison,
@ -63,6 +68,20 @@
# stuff for argument defaults. # stuff for argument defaults.
__forDefaults ? { __forDefaults ? {
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform; canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
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
# `boehmgc-nix` then this will almost certainly have duplicate patches, which means
# the patches won't apply and we'll get a build failure.
./boehmgc-coroutine-sp-fallback.diff
# https://github.com/ivmai/bdwgc/pull/586
./boehmgc-traceable_allocator-public.diff
];
};
}, },
}: let }: let
inherit (__forDefaults) canRunInstalled; inherit (__forDefaults) canRunInstalled;
@ -81,7 +100,7 @@
# The internal API docs need these for the build, but if we're not building # 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. # Nix itself, then these don't need to be propagated.
maybePropagatedInputs = [ maybePropagatedInputs = [
boehmgc boehmgc-nix
nlohmann_json nlohmann_json
]; ];
@ -324,4 +343,8 @@ in stdenv.mkDerivation (finalAttrs: {
passthru.perl-bindings = pkgs.callPackage ./perl { passthru.perl-bindings = pkgs.callPackage ./perl {
inherit fileset stdenv buildWithMeson; inherit fileset stdenv buildWithMeson;
}; };
# Export the patched version of boehmgc.
# flake.nix exports that into its overlay.
passthru.boehmgc-nix = __forDefaults.boehmgc-nix;
}) })