package: cleanup of all intermediaries

Change-Id: I0da5182de6b01c192cfcba407959d659d70c6dc9
This commit is contained in:
Qyriad 2024-03-09 01:22:06 -07:00
parent 529a01ade2
commit 36a8d151e1
2 changed files with 25 additions and 151 deletions

158
flake.nix
View file

@ -48,50 +48,6 @@
}) })
stdenvs); stdenvs);
baseFiles =
# .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.
fileset.fileFilter (f: f.name != ".gitignore") ./.;
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)
];
nixSrc = fileset.toSource {
root = ./.;
fileset = fileset.intersection baseFiles (fileset.unions [
configureFiles
topLevelBuildFiles
./boehmgc-coroutine-sp-fallback.diff
./doc
./misc
./precompiled-headers.h
./src
./unit-test-data
./COPYING
./scripts/local.mk
functionalTestFiles
]);
};
# Memoize nixpkgs for different platforms for efficiency. # Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems nixpkgsFor = forAllSystems
(system: let (system: let
@ -118,97 +74,6 @@
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv"); cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv");
}); });
commonDeps = {
pkgs,
isStatic ? pkgs.stdenv.hostPlatform.isStatic
}: let
inherit (pkgs) stdenv buildPackages
busybox curl bzip2 xz brotli editline openssl sqlite libarchive boost
libseccomp libsodium libcpuid gtest rapidcheck aws-sdk-cpp boehmgc nlohmann_json
lowdown;
changelog-d = pkgs.buildPackages.callPackage ./misc/changelog-d.nix { };
boehmgc-nix = (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
];
});
in rec {
calledPackage = pkgs.callPackage ./package.nix {
inherit stdenv versionSuffix fileset changelog-d officialRelease buildUnreleasedNotes lowdown;
boehmgc = boehmgc-nix;
busybox-sandbox-shell = sh;
};
inherit boehmgc-nix;
# Use "busybox-sandbox-shell" if present,
# if not (legacy) fallback and hope it's sufficient.
sh = pkgs.busybox-sandbox-shell or (busybox.override {
useMusl = true;
enableStatic = true;
enableMinimal = true;
extraConfig = ''
CONFIG_FEATURE_FANCY_ECHO y
CONFIG_FEATURE_SH_MATH y
CONFIG_FEATURE_SH_MATH_64 y
CONFIG_ASH y
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
CONFIG_ASH_ALIAS y
CONFIG_ASH_BASH_COMPAT y
CONFIG_ASH_CMDCMD y
CONFIG_ASH_ECHO y
CONFIG_ASH_GETOPTS y
CONFIG_ASH_INTERNAL_GLOB y
CONFIG_ASH_JOB_CONTROL y
CONFIG_ASH_PRINTF y
CONFIG_ASH_TEST y
'';
});
configureFlags =
lib.optionals stdenv.isLinux [
"--with-boost=${boost}/lib"
"--with-sandbox-shell=${sh}/bin/busybox"
]
++ lib.optionals (stdenv.isLinux && !(isStatic && stdenv.system == "aarch64-linux")) [
"LDFLAGS=-fuse-ld=gold"
];
testConfigureFlags = [
"RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include"
];
internalApiDocsConfigureFlags = [
"--enable-internal-api-docs"
];
inherit changelog-d;
nativeBuildDeps = calledPackage.nativeBuildInputs;
buildDeps = calledPackage.buildInputs;
checkDeps = calledPackage.finalAttrs.passthru._checkInputs;
internalApiDocsDeps = [
buildPackages.doxygen
];
awsDeps = lib.optional (stdenv.isLinux || stdenv.isDarwin)
(aws-sdk-cpp.override {
apis = ["s3" "transfer"];
customMemoryManagement = false;
});
propagatedDeps = calledPackage.propagatedBuildInputs;
};
installScriptFor = systems: installScriptFor = systems:
with nixpkgsFor.x86_64-linux.native; with nixpkgsFor.x86_64-linux.native;
runCommand "installer-script" runCommand "installer-script"
@ -365,7 +230,17 @@
# Forward from the previous stage as we dont want it to pick the lowdown override # Forward from the previous stage as we dont want it to pick the lowdown override
nixUnstable = prev.nixUnstable; nixUnstable = prev.nixUnstable;
inherit (comDeps) boehmgc-nix; changelog-d = final.buildPackages.callPackage ./misc/changelog-d.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;
@ -424,14 +299,13 @@
internal-api-docs = let internal-api-docs = let
nixpkgs = nixpkgsFor.x86_64-linux.native; nixpkgs = nixpkgsFor.x86_64-linux.native;
inherit (nixpkgs) pkgs; inherit (nixpkgs) pkgs;
comDeps = commonDeps { inherit pkgs; };
nix = nixpkgs.pkgs.callPackage ./package.nix { nix = pkgs.callPackage ./package.nix {
inherit versionSuffix fileset officialRelease buildUnreleasedNotes; inherit versionSuffix fileset officialRelease buildUnreleasedNotes;
inherit (comDeps) changelog-d; inherit (pkgs) changelog-d;
internalApiDocs = true; internalApiDocs = true;
boehmgc = comDeps.boehmgc-nix; boehmgc = pkgs.boehmgc-nix;
busybox-sandbox-shell = comDeps.sh; busybox-sandbox-shell = pkgs.busybox-sandbox-shell;
}; };
in in
nix.overrideAttrs (prev: { nix.overrideAttrs (prev: {
@ -490,7 +364,7 @@
rl-next = rl-next =
let pkgs = nixpkgsFor.${system}.native; let pkgs = nixpkgsFor.${system}.native;
in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } '' in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
LANG=C.UTF-8 ${(commonDeps { inherit pkgs; }).changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out LANG=C.UTF-8 ${pkgs.changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out
''; '';
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) { } // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
dockerImage = self.hydraJobs.dockerImage.${system}; dockerImage = self.hydraJobs.dockerImage.${system};

View file

@ -36,7 +36,7 @@
utillinuxMinimal ? null, utillinuxMinimal ? null,
xz, xz,
busybox-sandbox-shell ? null, busybox-sandbox-shell,
pname ? "nix", pname ? "nix",
versionSuffix ? "", versionSuffix ? "",
@ -162,19 +162,14 @@ in stdenv.mkDerivation (finalAttrs: {
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
# There have been issues building these dependencies # There have been issues building these dependencies
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix ++ 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 ++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs
; ;
passthru._checkInputs = [ checkInputs = [
gtest gtest
rapidcheck rapidcheck
]; ];
# FIXME(Qyriad): remove at the end of refactoring.
checkInputs = finalAttrs.passthru._checkInputs;
propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs; propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs;
disallowedReferences = [ disallowedReferences = [
@ -197,6 +192,13 @@ in stdenv.mkDerivation (finalAttrs: {
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
done done
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib 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 = lib.optionals stdenv.isLinux [ configureFlags = lib.optionals stdenv.isLinux [
@ -206,7 +208,6 @@ in stdenv.mkDerivation (finalAttrs: {
"LDFLAGS=-fuse-ld=gold" "LDFLAGS=-fuse-ld=gold"
] ++ [ "--sysconfdir=/etc" ] ] ++ [ "--sysconfdir=/etc" ]
++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" ++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell"
++ [ (lib.enableFeature finalAttrs.doCheck "tests") ]
++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags ++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags
++ lib.optional (!canRunInstalled) "--disable-doc-gen" ++ lib.optional (!canRunInstalled) "--disable-doc-gen"
++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ] ++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ]
@ -254,7 +255,6 @@ in stdenv.mkDerivation (finalAttrs: {
meta.platforms = lib.platforms.unix; meta.platforms = lib.platforms.unix;
passthru.finalAttrs = finalAttrs;
passthru.perl-bindings = pkgs.callPackage ./perl { passthru.perl-bindings = pkgs.callPackage ./perl {
inherit fileset stdenv; inherit fileset stdenv;
}; };