package: use pname, version, and doBuild (first change with diff hash)

The src fileset, preConfigure, and separateDebugInfo also respond to doBuild if its overridden

This commit is logically just a continuation of the previous commit's
refactor, but exists separately to delineate when the core Nix
derivation hash changed (this commit).

Change-Id: I67a61bc9608d91b6a833ebc5c3894b2d2e694050
This commit is contained in:
Qyriad 2024-03-05 13:51:49 -07:00
parent f8efdea4a2
commit 1b8f5bb870

View file

@ -53,36 +53,6 @@
version = lib.fileContents ./.version + versionSuffix;
# .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.
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
src = fileset.toSource {
root = ./.;
fileset = fileset.intersection baseFiles (fileset.unions [
./.version
./boehmgc-coroutine-sp-fallback.diff
./configure.ac
./doc
./local.mk
./m4
./Makefile
./Makefile.config.in
./misc
./mk
./precompiled-headers.h
./src
./tests/functional
./tests/unit
./unit-test-data
./COPYING
./scripts/local.mk
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
# TODO: do we really need README.md? It doesn't seem used in the build.
./README.md
]);
};
aws-sdk-cpp-nix = aws-sdk-cpp.override {
apis = [ "s3" "transfer" ];
customMemoryManagement = false;
@ -92,19 +62,65 @@
"RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include"
];
in stdenv.mkDerivation (finalAttrs: {
name = "nix-${version}";
inherit version;
# .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.
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
inherit src;
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;
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" ];
# dontBuild isn't specified most of the time, where it is implicitly false.
doBuild = !(finalAttrs.dontBuild or false);
nativeBuildInputs = [
bison
flex
] ++ [
(lib.getBin lowdown)
mdbook
mdbook-linkcheck
@ -145,6 +161,9 @@ in stdenv.mkDerivation (finalAttrs: {
rapidcheck
];
# FIXME(Qyriad): remove at the end of refactoring.
checkInputs = finalAttrs.passthru._checkInputs;
propagatedBuildInputs = [
boehmgc
nlohmann_json
@ -154,7 +173,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
@ -217,7 +236,7 @@ in stdenv.mkDerivation (finalAttrs: {
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
'';
separateDebugInfo = !stdenv.hostPlatform.isStatic;
separateDebugInfo = !stdenv.hostPlatform.isStatic && finalAttrs.doBuild;
strictDeps = true;