This commit is contained in:
John Ericson 2023-12-03 16:48:50 -05:00
parent ce598bae14
commit 3d47e02483
2 changed files with 56 additions and 43 deletions

View File

@ -153,7 +153,7 @@
then "" then ""
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}"; else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}";
sh = final.busybox-sandbox-shell or (final.busybox.override { default-busybox-sandbox-shell = final.busybox.override {
useMusl = true; useMusl = true;
enableStatic = true; enableStatic = true;
enableMinimal = true; enableMinimal = true;
@ -175,7 +175,7 @@
CONFIG_ASH_PRINTF y CONFIG_ASH_PRINTF y
CONFIG_ASH_TEST y CONFIG_ASH_TEST y
''; '';
}); };
boehmgc = (final.boehmgc.override { boehmgc = (final.boehmgc.override {
enableLargeConfig = true; enableLargeConfig = true;
@ -192,10 +192,10 @@
inherit inherit
boehmgc boehmgc
fileset fileset
sh
stdenv stdenv
versionSuffix versionSuffix
; ;
busybox-sandbox-shell = final.busybox-sandbox-shell or default-busybox-sandbox-shell;
boost = final.boost.override { enableIcu = false; }; boost = final.boost.override { enableIcu = false; };
libgit2 = final.libgit2.overrideAttrs (attrs: { libgit2 = final.libgit2.overrideAttrs (attrs: {
src = libgit2; src = libgit2;
@ -277,9 +277,8 @@
# API docs for Nix's unstable internal C++ interfaces. # API docs for Nix's unstable internal C++ interfaces.
internal-api-docs = nixpkgsFor.x86_64-linux.native.callPackage ./package.nix { internal-api-docs = nixpkgsFor.x86_64-linux.native.callPackage ./package.nix {
inherit fileset;
doBuild = false; doBuild = false;
doCheck = false;
doInstallCheck = false;
enableInternalAPIDocs = true; enableInternalAPIDocs = true;
}; };

View File

@ -36,11 +36,12 @@
, openssl , openssl
, pkg-config , pkg-config
, rapidcheck , rapidcheck
, sh
, sqlite , sqlite
, util-linux , util-linux
, xz , xz
, busybox-sandbox-shell ? null
# Configuration Options # Configuration Options
# #
# This probably seems like too many degrees of freedom, but it # This probably seems like too many degrees of freedom, but it
@ -50,11 +51,13 @@
, pname ? "nix" , pname ? "nix"
, doBuild ? true , doBuild ? true
, doCheck ? stdenv.buildPlatform.canExecute stdenv.hostPlatform , doCheck ? __forDefaults.canRunInstalled
, doInstallCheck ? stdenv.buildPlatform.canExecute stdenv.hostPlatform , doInstallCheck ? __forDefaults.canRunInstalled
, withCoverageChecks ? false , withCoverageChecks ? false
# Whether to build the regular manual
, enableManual ? __forDefaults.canRunInstalled
# Whether to build the internal API docs, can be done separately from # Whether to build the internal API docs, can be done separately from
# everything else. # everything else.
, enableInternalAPIDocs ? false , enableInternalAPIDocs ? false
@ -62,16 +65,26 @@
# Whether to install unit tests. This is useful when cross compiling # Whether to install unit tests. This is useful when cross compiling
# since we cannot run them natively during the build, but can do so # since we cannot run them natively during the build, but can do so
# later. # later.
, installUnitTests ? stdenv.hostPlatform != stdenv.buildPlatform , installUnitTests ? __forDefaults.canRunInstalled
# For running the functional tests against a pre-built Nix. Probably
# want to use in conjunction with `doBuild = false;`.
, test-daemon ? null , test-daemon ? null
, test-client ? null , test-client ? null
}:
# Not a real argument, just the only way to approximate let-binding some
# stuff for argument defaults.
, __forDefaults ? {
canRunInstalled = doBuild && stdenv.buildPlatform.canExecute stdenv.hostPlatform;
}
} @ attrs0:
let let
version = lib.fileContents ./.version + versionSuffix; version = lib.fileContents ./.version + versionSuffix;
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
# selected attributes with defaults, will be used to define some
# things which should instead be gotten via `finalAttrs` in order to
# work with overriding.
attrs = { attrs = {
inherit doBuild doCheck doInstallCheck; inherit doBuild doCheck doInstallCheck;
}; };
@ -149,7 +162,11 @@ in {
VERSION_SUFFIX = versionSuffix; VERSION_SUFFIX = versionSuffix;
outputs = [ "out" "dev" "doc" ] outputs = [ "out" ]
++ lib.optional doBuild "dev"
# If we are doing just build or just docs, the one thing will use
# "out". We only need additional outputs if we are doing both.
++ lib.optional (doBuild && (enableManual || enableInternalAPIDocs)) "doc"
++ lib.optional installUnitTests "check"; ++ lib.optional installUnitTests "check";
nativeBuildInputs = [ nativeBuildInputs = [
@ -164,10 +181,11 @@ in {
pkg-config pkg-config
] ]
++ lib.optional stdenv.hostPlatform.isLinux util-linux ++ lib.optional stdenv.hostPlatform.isLinux util-linux
# Official releases don't have rl-next, so we don't need to compile a changelog # Official releases don't have rl-next, so we don't need to compile a
# changelog
++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d; ++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d;
buildInputs = [ buildInputs = lib.optionals doBuild [
boost boost
brotli brotli
bzip2 bzip2
@ -180,19 +198,14 @@ in {
openssl openssl
sqlite sqlite
xz xz
] ++ lib.optional stdenv.isLinux libseccomp
# These could be checkInputs but the configure phase fails w/o them ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
gtest # There have been issues building these dependencies
rapidcheck ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin))
] (aws-sdk-cpp.override {
++ lib.optional stdenv.isLinux libseccomp apis = ["s3" "transfer"];
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid customMemoryManagement = false;
# There have been issues building these dependencies })
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin))
(aws-sdk-cpp.override {
apis = ["s3" "transfer"];
customMemoryManagement = false;
})
; ;
propagatedBuildInputs = [ propagatedBuildInputs = [
@ -204,7 +217,8 @@ in {
doCheck = attrs.doCheck; doCheck = attrs.doCheck;
checkInputs = [ checkInputs = [
# see buildInputs. The configure script always wants its test libs gtest
rapidcheck
]; ];
nativeCheckInputs = [ nativeCheckInputs = [
@ -242,17 +256,17 @@ in {
(lib.enableFeature doBuild "build") (lib.enableFeature doBuild "build")
(lib.enableFeature anySortOfTesting "test") (lib.enableFeature anySortOfTesting "test")
(lib.enableFeature enableInternalAPIDocs "internal-api-docs") (lib.enableFeature enableInternalAPIDocs "internal-api-docs")
(lib.enableFeature canRunInstalled "doc-gen") (lib.enableFeature enableManual "doc-gen")
(lib.enableFeature installUnitTests "install-unit-tests") (lib.enableFeature installUnitTests "install-unit-tests")
] ++ lib.optionals installUnitTests [ ] ++ lib.optionals installUnitTests [
"--with-check-bin-dir=${builtins.placeholder "check"}/bin" "--with-check-bin-dir=${builtins.placeholder "check"}/bin"
"--with-check-lib-dir=${builtins.placeholder "check"}/lib" "--with-check-lib-dir=${builtins.placeholder "check"}/lib"
] ++ lib.optionals stdenv.isLinux [ ] ++ lib.optionals (doBuild && stdenv.isLinux) [
"--with-boost=${boost}/lib" "--with-boost=${boost}/lib"
"--with-sandbox-shell=${sh}/bin/busybox" "--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox"
] ++ lib.optional (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) ] ++ lib.optional (doBuild && stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
"LDFLAGS=-fuse-ld=gold" "LDFLAGS=-fuse-ld=gold"
++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" ++ lib.optional (doBuild && stdenv.hostPlatform.isStatic) "--enable-embedded-sandbox-shell"
++ lib.optional buildUnitTests "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include"; ++ lib.optional buildUnitTests "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include";
enableParallelBuilding = true; enableParallelBuilding = true;
@ -271,14 +285,14 @@ in {
mkdir -p $out mkdir -p $out
''; '';
postInstall = lib.optionalString doBuild '' postInstall = lib.optionalString doBuild (
mkdir -p $doc/nix-support ''
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products mkdir -p $doc/nix-support
${lib.optionalString stdenv.hostPlatform.isStatic '' echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
'' + lib.optionalString stdenv.hostPlatform.isStatic ''
mkdir -p $out/nix-support mkdir -p $out/nix-support
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
''} '' + lib.optionalString stdenv.isDarwin ''
${lib.optionalString stdenv.isDarwin ''
install_name_tool \ install_name_tool \
-change ${boost}/lib/libboost_context.dylib \ -change ${boost}/lib/libboost_context.dylib \
$out/lib/libboost_context.dylib \ $out/lib/libboost_context.dylib \
@ -287,10 +301,10 @@ in {
-change ${boost}/lib/libboost_regex.dylib \ -change ${boost}/lib/libboost_regex.dylib \
$out/lib/libboost_regex.dylib \ $out/lib/libboost_regex.dylib \
$out/lib/libnixexpr.dylib $out/lib/libnixexpr.dylib
''} ''
'' + lib.optionalString enableInternalAPIDocs '' ) + lib.optionalString enableInternalAPIDocs ''
mkdir -p $out/nix-support mkdir -p ''${!outputDoc}/nix-support
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> $out/nix-support/hydra-build-products echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> ''${!outputDoc}/nix-support/hydra-build-products
''; '';
doInstallCheck = attrs.doInstallCheck; doInstallCheck = attrs.doInstallCheck;