From 3173c3b6b61cd06620bda26ac8f0b674866d6101 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 4 Jul 2022 04:25:04 +0300 Subject: [PATCH 1/2] stdenv: start deprecating non-list cmakeFlags 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 cmakeFlags should be a list of strings --- pkgs/stdenv/generic/make-derivation.nix | 44 +++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index bde8735642d8..3cf34e785eb1 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -330,6 +330,37 @@ else let ++ optional (elem "host" configurePlatforms) "--host=${stdenv.hostPlatform.config}" ++ optional (elem "target" configurePlatforms) "--target=${stdenv.targetPlatform.config}"; + cmakeFlags = + let + explicitFlags = + if lib.isString cmakeFlags then lib.warn + "String 'cmakeFlags' 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"}" + [cmakeFlags] + else if cmakeFlags == null then + lib.warn + "Null 'cmakeFlags' 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 + cmakeFlags; + + crossFlags = [ + "-DCMAKE_SYSTEM_NAME=${lib.findFirst lib.isString "Generic" (lib.optional (!stdenv.hostPlatform.isRedox) stdenv.hostPlatform.uname.system)}" + ] ++ lib.optionals (stdenv.hostPlatform.uname.processor != null) [ + "-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}" + ] ++ lib.optionals (stdenv.hostPlatform.uname.release != null) [ + "-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.uname.release}" + ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ + "-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}" + ] ++ lib.optionals (stdenv.buildPlatform.uname.system != null) [ + "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}" + ] ++ lib.optionals (stdenv.buildPlatform.uname.processor != null) [ + "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}" + ] ++ lib.optionals (stdenv.buildPlatform.uname.release != null) [ + "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}" + ]; + in + explicitFlags ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) crossFlags; + inherit patches; inherit doCheck doInstallCheck; @@ -342,19 +373,6 @@ else let outputHashAlgo = attrs.outputHashAlgo or "sha256"; outputHashMode = attrs.outputHashMode or "recursive"; } // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) { - cmakeFlags = - (/**/ if lib.isString cmakeFlags then [cmakeFlags] - else if cmakeFlags == null then [] - else cmakeFlags) - ++ [ "-DCMAKE_SYSTEM_NAME=${lib.findFirst lib.isString "Generic" ( - lib.optional (!stdenv.hostPlatform.isRedox) stdenv.hostPlatform.uname.system)}"] - ++ lib.optional (stdenv.hostPlatform.uname.processor != null) "-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}" - ++ lib.optional (stdenv.hostPlatform.uname.release != null) "-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.uname.release}" - ++ lib.optional (stdenv.hostPlatform.isDarwin) "-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}" - ++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}" - ++ lib.optional (stdenv.buildPlatform.uname.processor != null) "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}" - ++ lib.optional (stdenv.buildPlatform.uname.release != null) "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}"; - mesonFlags = if mesonFlags == null then null else let # See https://mesonbuild.com/Reference-tables.html#cpu-families cpuFamily = platform: with platform; From 732f1d8142f7ea873fd38255db1ab1b4d07a8cc3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 4 Jul 2022 04:26:36 +0300 Subject: [PATCH 2/2] treewide: convert string cmakeFlags to list of strings --- pkgs/applications/audio/faust/faust2.nix | 7 ++++--- pkgs/applications/office/PageEdit/default.nix | 2 +- pkgs/applications/video/rtabmap/default.nix | 2 +- pkgs/development/libraries/libcef/default.nix | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/audio/faust/faust2.nix b/pkgs/applications/audio/faust/faust2.nix index 2ad98d3d6d8d..9bc200ef16ec 100644 --- a/pkgs/applications/audio/faust/faust2.nix +++ b/pkgs/applications/audio/faust/faust2.nix @@ -58,9 +58,10 @@ let cd build ''; - cmakeFlags = '' - -C ../backends/all.cmake -C ../targets/all.cmake .. - ''; + cmakeFlags = [ + "-C../backends/all.cmake" + "-C../targets/all.cmake" + ]; postInstall = '' # syntax error when eval'd directly diff --git a/pkgs/applications/office/PageEdit/default.nix b/pkgs/applications/office/PageEdit/default.nix index e003c3a0e516..02a69a0fe15c 100644 --- a/pkgs/applications/office/PageEdit/default.nix +++ b/pkgs/applications/office/PageEdit/default.nix @@ -13,7 +13,7 @@ mkDerivation rec { nativeBuildInputs = [ cmake qttranslations ]; propagatedBuildInputs = [ qtsvg qtwebengine ]; - cmakeFlags = "-DINSTALL_BUNDLED_DICTS=0"; + cmakeFlags = [ "-DINSTALL_BUNDLED_DICTS=0" ]; meta = with lib; { description = "ePub XHTML Visual Editor"; diff --git a/pkgs/applications/video/rtabmap/default.nix b/pkgs/applications/video/rtabmap/default.nix index c6429b093486..3dce0123d1be 100644 --- a/pkgs/applications/video/rtabmap/default.nix +++ b/pkgs/applications/video/rtabmap/default.nix @@ -40,7 +40,7 @@ stdenv.mkDerivation rec { ]; # Disable warnings that are irrelevant to us as packagers - cmakeFlags = "-Wno-dev"; + cmakeFlags = [ "-Wno-dev" ]; # We run one of the executables we build while the build is # still running (and patchelf hasn't been invoked) which means diff --git a/pkgs/development/libraries/libcef/default.nix b/pkgs/development/libraries/libcef/default.nix index 87471114a87b..96f53a33b1eb 100644 --- a/pkgs/development/libraries/libcef/default.nix +++ b/pkgs/development/libraries/libcef/default.nix @@ -88,7 +88,7 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ cmake ]; - cmakeFlags = "-DPROJECT_ARCH=${platformInfo.projectArch}"; + cmakeFlags = [ "-DPROJECT_ARCH=${platformInfo.projectArch}" ]; makeFlags = [ "libcef_dll_wrapper" ]; dontStrip = true; dontPatchELF = true;