From ca2ca8b194d619e8ab050831463b04a5472abbd5 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 6 Jul 2022 06:05:48 +0300 Subject: [PATCH 1/2] stdenv: start deprecating non-list mesonFlags the motivation for this is to simplify stdenv and ease the job of reviewers due to them needing to tell contributors about the defacto rule that mesonFlags should be a list of strings --- pkgs/stdenv/generic/make-derivation.nix | 60 +++++++++++++++---------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 3cf34e785eb1..871aed59e35e 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -361,6 +361,43 @@ else let in explicitFlags ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) crossFlags; + mesonFlags = + let + explicitFlags = + if lib.isString mesonFlags then lib.warn + "String 'mesonFlags' is deprecated and will be removed in release 23.05. Please use a list of strings. Derivation name: ${derivationArg.name}, file: ${pos.file or "unknown file"}" + [mesonFlags] + else if mesonFlags == null then + lib.warn + "Null 'mesonFlags' is deprecated and will be removed in release 23.05. Please use a empty list instead '[]'. Derivation name: ${derivationArg.name}, file: ${pos.file or "unknown file"}" + [] + else + mesonFlags; + + # See https://mesonbuild.com/Reference-tables.html#cpu-families + cpuFamily = platform: with platform; + /**/ if isAarch32 then "arm" + else if isAarch64 then "aarch64" + else if isx86_32 then "x86" + else if isx86_64 then "x86_64" + else platform.parsed.cpu.family + builtins.toString platform.parsed.cpu.bits; + + crossFile = builtins.toFile "cross-file.conf" '' + [properties] + needs_exe_wrapper = true + + [host_machine] + system = '${stdenv.targetPlatform.parsed.kernel.name}' + cpu_family = '${cpuFamily stdenv.targetPlatform}' + cpu = '${stdenv.targetPlatform.parsed.cpu.name}' + endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"} + + [binaries] + llvm-config = 'llvm-config-native' + ''; + crossFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "--cross-file=${crossFile}" ]; + in crossFlags ++ explicitFlags; + inherit patches; inherit doCheck doInstallCheck; @@ -372,29 +409,6 @@ else let # most people won't care about these anyways outputHashAlgo = attrs.outputHashAlgo or "sha256"; outputHashMode = attrs.outputHashMode or "recursive"; - } // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) { - mesonFlags = if mesonFlags == null then null else let - # See https://mesonbuild.com/Reference-tables.html#cpu-families - cpuFamily = platform: with platform; - /**/ if isAarch32 then "arm" - else if isAarch64 then "aarch64" - else if isx86_32 then "x86" - else if isx86_64 then "x86_64" - else platform.parsed.cpu.family + builtins.toString platform.parsed.cpu.bits; - crossFile = builtins.toFile "cross-file.conf" '' - [properties] - needs_exe_wrapper = true - - [host_machine] - system = '${stdenv.targetPlatform.parsed.kernel.name}' - cpu_family = '${cpuFamily stdenv.targetPlatform}' - cpu = '${stdenv.targetPlatform.parsed.cpu.name}' - endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"} - - [binaries] - llvm-config = 'llvm-config-native' - ''; - in [ "--cross-file=${crossFile}" ] ++ mesonFlags; } // lib.optionalAttrs (enableParallelBuilding) { enableParallelChecking = attrs.enableParallelChecking or true; } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != [] || stdenv.hostPlatform.isMusl) { From c57fb11a5050ea78ba23e3a185323b8cd7d94170 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 6 Jul 2022 15:24:48 +0300 Subject: [PATCH 2/2] treewide: convert string mesonFlags to list of strings --- pkgs/applications/audio/speech-denoiser/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/audio/speech-denoiser/default.nix b/pkgs/applications/audio/speech-denoiser/default.nix index 466457c607dc..8bce5c83a691 100644 --- a/pkgs/applications/audio/speech-denoiser/default.nix +++ b/pkgs/applications/audio/speech-denoiser/default.nix @@ -27,7 +27,7 @@ stdenv.mkDerivation { nativeBuildInputs = [ pkg-config meson ninja ]; buildInputs = [ lv2 rnnoise-nu ]; - mesonFlags = ("--prefix=${placeholder "out"}/lib/lv2"); + mesonFlags = [ "--prefix=${placeholder "out"}/lib/lv2" ]; postPatch = '' substituteInPlace meson.build \