treewide: Remove stdenv.isCross

I *want* cross-specific overrides to be verbose, so I rather not have
this shorthand. This makes the syntactic overhead more proportional to
the maintainence cost. Hopefully this pushes people towards fewer
conditionals and more abstractions.
This commit is contained in:
John Ericson 2018-07-29 16:48:24 -04:00
parent 89a89ddfb3
commit 34da7e2ce2
7 changed files with 48 additions and 34 deletions

View File

@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
++ stdenv.lib.optional stdenv.isDarwin gettext ++ stdenv.lib.optional stdenv.isDarwin gettext
++ stdenv.lib.optional enableCapabilities libcap; ++ stdenv.lib.optional enableCapabilities libcap;
preConfigure = stdenv.lib.optionalString stdenv.isCross '' preConfigure = stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
# This is intentional: gpg-error-config is a shell script that will work during the build # This is intentional: gpg-error-config is a shell script that will work during the build
mkdir -p "$NIX_BUILD_TOP"/bin mkdir -p "$NIX_BUILD_TOP"/bin
ln -s ${libgpgerror.dev}/bin/gpg-error-config "$NIX_BUILD_TOP/bin" ln -s ${libgpgerror.dev}/bin/gpg-error-config "$NIX_BUILD_TOP/bin"

View File

@ -1,7 +1,6 @@
{ lib, python3Packages, stdenv, targetPlatform, writeTextDir, substituteAll }: let { lib, python3Packages, stdenv, targetPlatform, writeTextDir, substituteAll }:
targetPrefix = lib.optionalString stdenv.isCross
(targetPlatform.config + "-"); python3Packages.buildPythonApplication rec {
in python3Packages.buildPythonApplication rec {
version = "0.46.1"; version = "0.46.1";
pname = "meson"; pname = "meson";
@ -48,10 +47,10 @@ in python3Packages.buildPythonApplication rec {
crossFile = writeTextDir "cross-file.conf" '' crossFile = writeTextDir "cross-file.conf" ''
[binaries] [binaries]
c = '${targetPrefix}cc' c = '${stdenv.cc.targetPrefix}cc'
cpp = '${targetPrefix}c++' cpp = '${stdenv.cc.targetPrefix}c++'
ar = '${targetPrefix}ar' ar = '${stdenv.cc.bintools.targetPrefix}ar'
strip = '${targetPrefix}strip' strip = '${stdenv.cc.bintools.targetPrefix}strip'
pkgconfig = 'pkg-config' pkgconfig = 'pkg-config'
[properties] [properties]
@ -69,7 +68,9 @@ in python3Packages.buildPythonApplication rec {
# checkInputs = [ ninja pkgconfig ]; # checkInputs = [ ninja pkgconfig ];
# checkPhase = "python ./run_project_tests.py"; # checkPhase = "python ./run_project_tests.py";
inherit (stdenv) cc isCross; inherit (stdenv) cc;
isCross = stdenv.buildPlatform != stdenv.hostPlatform;
meta = with lib; { meta = with lib; {
homepage = http://mesonbuild.com; homepage = http://mesonbuild.com;

View File

@ -2,9 +2,9 @@
, pkgconfig, which , pkgconfig, which
, flex, bison , flex, bison
, linuxHeaders ? stdenv.cc.libc.linuxHeaders , linuxHeaders ? stdenv.cc.libc.linuxHeaders
, python
, gawk , gawk
, perl , withPerl ? stdenv.hostPlatform == stdenv.buildPlatform && perl.meta.available or false, perl
, withPython ? stdenv.hostPlatform == stdenv.buildPlatform && python.meta.available or false, python
, swig , swig
, ncurses , ncurses
, pam , pam
@ -76,10 +76,9 @@ let
perl perl
]; ];
buildInputs = stdenv.lib.optionals (!stdenv.isCross) [ buildInputs = []
perl ++ stdenv.lib.optional withPerl perl
python ++ stdenv.lib.optional withPython python;
];
# required to build apparmor-parser # required to build apparmor-parser
dontDisableStatic = true; dontDisableStatic = true;
@ -92,11 +91,14 @@ let
postPatch = "cd ./libraries/libapparmor"; postPatch = "cd ./libraries/libapparmor";
# https://gitlab.com/apparmor/apparmor/issues/1 # https://gitlab.com/apparmor/apparmor/issues/1
configureFlags = stdenv.lib.optionalString (!stdenv.isCross) "--with-python --with-perl"; configureFlags = [
(stdenv.lib.withFeature withPerl "perl")
(stdenv.lib.withFeature withPython "python")
];
outputs = if stdenv.isCross then [ "out" ] else [ "out" "python" ]; outputs = [ "out" ] ++ stdenv.lib.optional withPython "python";
postInstall = stdenv.lib.optionalString (!stdenv.isCross) '' postInstall = stdenv.lib.optionalString withPython ''
mkdir -p $python/lib mkdir -p $python/lib
mv $out/lib/python* $python/lib/ mv $out/lib/python* $python/lib/
''; '';
@ -137,7 +139,9 @@ let
inherit doCheck; inherit doCheck;
meta = apparmor-meta "user-land utilities"; meta = apparmor-meta "user-land utilities" // {
broken = !(withPython && withPerl);
};
}; };
apparmor-bin-utils = stdenv.mkDerivation { apparmor-bin-utils = stdenv.mkDerivation {

View File

@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
] ++ stdenv.lib.optional (!stdenv.hostPlatform.isMusl) libidn; ] ++ stdenv.lib.optional (!stdenv.hostPlatform.isMusl) libidn;
# ninfod probably could build on cross, but the Makefile doesn't pass --host etc to the sub configure... # ninfod probably could build on cross, but the Makefile doesn't pass --host etc to the sub configure...
buildFlags = "man all" + stdenv.lib.optionalString (!stdenv.isCross) " ninfod"; buildFlags = "man all" + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) " ninfod";
installPhase = installPhase =
'' ''

View File

@ -141,8 +141,6 @@ let
inherit overrides; inherit overrides;
inherit cc; inherit cc;
isCross = targetPlatform != buildPlatform;
} }
# Propagate any extra attributes. For instance, we use this to # Propagate any extra attributes. For instance, we use this to

View File

@ -11,7 +11,12 @@ stdenv.mkDerivation rec {
sha256 = "0319q59kb8g324wnj7xzbr7vvlx5bcs13lr34j0zb3kqlyjq2fy9"; sha256 = "0319q59kb8g324wnj7xzbr7vvlx5bcs13lr34j0zb3kqlyjq2fy9";
}; };
configureFlags = "CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3" + stdenv.lib.optionalString stdenv.isCross " CXX=${stdenv.cc.targetPrefix}c++"; configureFlags = [
"CPPFLAGS=-DNDEBUG"
"CFLAGS=-O3"
"CXXFLAGS=-O3"
] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
"CXX=${stdenv.cc.targetPrefix}c++";
setupHook = ./lzip-setup-hook.sh; setupHook = ./lzip-setup-hook.sh;

View File

@ -1,7 +1,10 @@
{stdenv, fetchurl, openssl, bison, flex, pam, zlib, usePAM ? stdenv.isLinux { stdenv
, buildPlatform, hostPlatform }: , fetchurl, bison, flex
let useSSL = (openssl != null); , zlib
isCross = ( buildPlatform != hostPlatform ) ; in , usePAM ? stdenv.hostPlatform.isLinux, pam
, useSSL ? true, openssl
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "monit-5.25.2"; name = "monit-5.25.2";
@ -15,15 +18,18 @@ stdenv.mkDerivation rec {
stdenv.lib.optionals useSSL [ openssl ] ++ stdenv.lib.optionals useSSL [ openssl ] ++
stdenv.lib.optionals usePAM [ pam ]; stdenv.lib.optionals usePAM [ pam ];
configureFlags = configureFlags = [
if useSSL then [ (stdenv.lib.withFeature usePAM "pam")
] ++ (if useSSL then [
"--with-ssl-incl-dir=${openssl.dev}/include" "--with-ssl-incl-dir=${openssl.dev}/include"
"--with-ssl-lib-dir=${openssl.out}/lib" "--with-ssl-lib-dir=${openssl.out}/lib"
] else [ "--without-ssl" ] ++ ] else [
stdenv.lib.optionals (! usePAM) [ "--without-pam" ] ++ "--without-ssl"
]) ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# will need to check both these are true for musl # will need to check both these are true for musl
stdenv.lib.optionals isCross [ "libmonit_cv_setjmp_available=yes" "libmonit_cv_setjmp_available=yes"
"libmonit_cv_vsnprintf_c99_conformant=yes"]; "libmonit_cv_vsnprintf_c99_conformant=yes"
];
meta = { meta = {
homepage = http://mmonit.com/monit/; homepage = http://mmonit.com/monit/;