Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate our many package.nix a bit #11175

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ let

# Work around weird `--as-needed` linker behavior with BSD, see
# https://github.com/mesonbuild/meson/issues/3593
bsdNoLinkAsNeeded = finalAttrs: prevAttrs: lib.optionalAttrs stdenv.hostPlatform.isBSD {
mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or [];
};
bsdNoLinkAsNeeded = finalAttrs: prevAttrs:
lib.optionalAttrs stdenv.hostPlatform.isBSD {
mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or [];
};

miscGoodPractice = finalAttrs: prevAttrs:
{
strictDeps = prevAttrs.strictDeps or true;
enableParallelBuilding = true;
};

in
scope: {
Expand Down Expand Up @@ -136,8 +143,14 @@ scope: {

inherit resolvePath filesetToSource;

mkMesonDerivation = f: stdenv.mkDerivation
(lib.extends
(lib.composeExtensions bsdNoLinkAsNeeded localSourceLayer)
f);
mkMesonDerivation = f: let
exts = [
miscGoodPractice
bsdNoLinkAsNeeded
localSourceLayer
];
in stdenv.mkDerivation
(lib.extends
(lib.foldr lib.composeExtensions (_: _: {}) exts)
f);
Comment on lines +153 to +155
Copy link
Member Author

@Ericson2314 Ericson2314 Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time: composeManyExtensions

}
4 changes: 0 additions & 4 deletions src/external-api-docs/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ mkMesonDerivation (finalAttrs: {
echo "doc external-api-docs $out/share/doc/nix/external-api/html" >> ''${!outputDoc}/nix-support/hydra-build-products
'';

enableParallelBuilding = true;

strictDeps = true;

meta = {
platforms = lib.platforms.all;
};
Expand Down
4 changes: 0 additions & 4 deletions src/internal-api-docs/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ mkMesonDerivation (finalAttrs: {
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> ''${!outputDoc}/nix-support/hydra-build-products
'';

enableParallelBuilding = true;

strictDeps = true;

meta = {
platforms = lib.platforms.all;
};
Expand Down
6 changes: 0 additions & 6 deletions src/libcmd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

# TODO `releaseTools.coverageAnalysis` in Nixpkgs needs to be updated
# to work with `strictDeps`.
strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libexpr-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libexpr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
6 changes: 0 additions & 6 deletions src/libfetchers/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

# TODO `releaseTools.coverageAnalysis` in Nixpkgs needs to be updated
# to work with `strictDeps`.
Comment on lines -74 to -75
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of date comment

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
6 changes: 0 additions & 6 deletions src/libflake/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

# TODO `releaseTools.coverageAnalysis` in Nixpkgs needs to be updated
# to work with `strictDeps`.
strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libmain-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
6 changes: 0 additions & 6 deletions src/libmain/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

# TODO `releaseTools.coverageAnalysis` in Nixpkgs needs to be updated
# to work with `strictDeps`.
strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libstore-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libstore/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libutil-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions src/libutil/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
6 changes: 0 additions & 6 deletions src/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ mkMesonDerivation (finalAttrs: {
]
);

outputs = [ "out" "dev" ];

nativeBuildInputs = [
meson
ninja
Expand Down Expand Up @@ -114,12 +112,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
2 changes: 1 addition & 1 deletion src/perl/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ perl.pkgs.toPerlModule (mkMesonDerivation (finalAttrs: {
"--print-errorlogs"
];

enableParallelBuilding = true;
strictDeps = false;
}))
4 changes: 0 additions & 4 deletions tests/unit/libexpr-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libexpr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

passthru = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libfetchers/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

passthru = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libflake/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

passthru = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libstore-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libstore/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

passthru = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libutil-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

meta = {
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/libutil/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};

enableParallelBuilding = true;

separateDebugInfo = !stdenv.hostPlatform.isStatic;

strictDeps = true;

hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

passthru = {
Expand Down
Loading