packaging: Add mkMeson{Library,Executable}

and:
- move pkg-config out of mkMesonDerivation, for components that don't
  produce any executable code
This commit is contained in:
Robert Hensing 2024-10-13 23:17:54 +02:00
parent e10ff893e5
commit 15e3e1543b
23 changed files with 73 additions and 151 deletions

View File

@ -69,10 +69,23 @@ let
nativeBuildInputs = [
pkgs.buildPackages.meson
pkgs.buildPackages.ninja
pkgs.buildPackages.pkg-config
] ++ prevAttrs.nativeBuildInputs or [];
};
mesonBuildLayer = finalAttrs: prevAttrs:
{
nativeBuildInputs = prevAttrs.nativeBuildInputs or [] ++ [
pkgs.buildPackages.pkg-config
];
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
};
mesonLibraryLayer = finalAttrs: prevAttrs:
{
outputs = prevAttrs.outputs or [ "out" ] ++ [ "dev" ];
};
# Work around weird `--as-needed` linker behavior with BSD, see
# https://github.com/mesonbuild/meson/issues/3593
bsdNoLinkAsNeeded = finalAttrs: prevAttrs:
@ -188,8 +201,24 @@ scope: {
mkMesonDerivation =
mkPackageBuilder [
miscGoodPractice
bsdNoLinkAsNeeded
localSourceLayer
mesonLayer
];
mkMesonExecutable =
mkPackageBuilder [
miscGoodPractice
bsdNoLinkAsNeeded
localSourceLayer
mesonLayer
mesonBuildLayer
];
mkMesonLibrary =
mkPackageBuilder [
miscGoodPractice
bsdNoLinkAsNeeded
localSourceLayer
mesonLayer
mesonBuildLayer
mesonLibraryLayer
];
}

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util
, nix-store
@ -33,7 +33,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-cmd";
inherit version;
@ -49,8 +49,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
buildInputs = [
({ inherit editline readline; }.${readlineFlavor})
] ++ lib.optional enableMarkdown lowdown;
@ -82,10 +80,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-store-c
, nix-expr
@ -14,7 +14,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-expr-c";
inherit version;
@ -31,8 +31,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-store-c
nix-expr
@ -53,10 +51,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, bison
, flex
@ -34,7 +34,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-expr";
inherit version;
@ -57,8 +57,6 @@ mkMesonDerivation (finalAttrs: {
)
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [
bison
flex
@ -98,10 +96,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util
, nix-store
@ -16,7 +16,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-fetchers";
inherit version;
@ -31,8 +31,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
buildInputs = [
libgit2
];
@ -55,10 +53,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util
, nix-store
@ -17,7 +17,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-flake";
inherit version;
@ -32,8 +32,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-store
nix-util
@ -54,10 +52,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util-c
, nix-store
@ -16,7 +16,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-main-c";
inherit version;
@ -33,8 +33,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-util-c
nix-store
@ -57,10 +55,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, openssl
@ -16,7 +16,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-main";
inherit version;
@ -31,8 +31,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-util
nix-store
@ -51,10 +49,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util-c
, nix-store
@ -14,7 +14,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-store-c";
inherit version;
@ -31,8 +31,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-util-c
nix-store
@ -53,10 +51,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, unixtools
@ -25,7 +25,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-store";
inherit version;
@ -47,8 +47,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "sql") ./.)
];
outputs = [ "out" "dev" ];
nativeBuildInputs =
lib.optional embeddedSandboxShell unixtools.hexdump;
@ -91,10 +89,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util
@ -13,7 +13,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-util-c";
inherit version;
@ -30,8 +30,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-util
];
@ -51,10 +49,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, boost
, brotli
@ -19,7 +19,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-util";
inherit version;
@ -38,8 +38,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
buildInputs = [
brotli
libsodium
@ -77,10 +75,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonExecutable
, nix-store
, nix-expr
@ -16,7 +16,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonExecutable (finalAttrs: {
pname = "nix";
inherit version;
@ -103,10 +103,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,6 +1,7 @@
{ lib
, stdenv
, mkMesonDerivation
, pkg-config
, perl
, perlPackages
, nix-store
@ -32,6 +33,7 @@ perl.pkgs.toPerlModule (mkMesonDerivation (finalAttrs: {
]);
nativeBuildInputs = [
pkg-config
perl
curl
];

View File

@ -75,7 +75,6 @@ mkMesonDerivation (finalAttrs: {
nix-expr
];
preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-store-test-support
, nix-expr
@ -16,7 +16,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-util-test-support";
inherit version;
@ -32,8 +32,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-store-test-support
nix-expr
@ -55,10 +53,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,7 +1,7 @@
{ lib
, buildPackages
, stdenv
, mkMesonDerivation
, mkMesonExecutable
, nix-expr
, nix-expr-c
@ -21,7 +21,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonExecutable (finalAttrs: {
pname = "nix-expr-tests";
inherit version;
@ -60,10 +60,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {

View File

@ -1,7 +1,7 @@
{ lib
, buildPackages
, stdenv
, mkMesonDerivation
, mkMesonExecutable
, nix-fetchers
, nix-store-test-support
@ -20,7 +20,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonExecutable (finalAttrs: {
pname = "nix-fetchers-tests";
inherit version;
@ -58,10 +58,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {

View File

@ -1,7 +1,7 @@
{ lib
, buildPackages
, stdenv
, mkMesonDerivation
, mkMesonExecutable
, nix-flake
, nix-expr-test-support
@ -20,7 +20,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonExecutable (finalAttrs: {
pname = "nix-flake-tests";
inherit version;
@ -58,10 +58,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util-test-support
, nix-store
@ -16,7 +16,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-store-test-support";
inherit version;
@ -32,8 +32,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-util-test-support
nix-store
@ -55,10 +53,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,7 +1,7 @@
{ lib
, buildPackages
, stdenv
, mkMesonDerivation
, mkMesonExecutable
, nix-store
, nix-store-c
@ -22,7 +22,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonExecutable (finalAttrs: {
pname = "nix-store-tests";
inherit version;
@ -62,10 +62,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = let

View File

@ -1,6 +1,6 @@
{ lib
, stdenv
, mkMesonDerivation
, mkMesonLibrary
, nix-util
@ -15,7 +15,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonLibrary (finalAttrs: {
pname = "nix-util-test-support";
inherit version;
@ -31,8 +31,6 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" "dev" ];
propagatedBuildInputs = [
nix-util
rapidcheck
@ -53,10 +51,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

View File

@ -1,7 +1,7 @@
{ lib
, buildPackages
, stdenv
, mkMesonDerivation
, mkMesonExecutable
, nix-util
, nix-util-c
@ -20,7 +20,7 @@ let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
mkMesonExecutable (finalAttrs: {
pname = "nix-util-tests";
inherit version;
@ -59,10 +59,6 @@ mkMesonDerivation (finalAttrs: {
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
passthru = {
tests = {
run = runCommand "${finalAttrs.pname}-run" {