Skip to content

Commit

Permalink
Fix cross eval issues (#362546)
Browse files Browse the repository at this point in the history
  • Loading branch information
sternenseemann authored Dec 14, 2024
2 parents d6b7f32 + 276fe40 commit a0a35b6
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion doc/doc-support/lib-function-docs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ stdenvNoCC.mkDerivation {
fileset = ../../lib;
};

buildInputs = [
nativeBuildInputs = [
nixdoc
nix
];
Expand Down
2 changes: 1 addition & 1 deletion doc/tests/manpage-urls.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ invalidateFetcherByDrvHash (
{
nativeBuildInputs = [
cacert
(python3.withPackages (p: [
(python3.pythonOnBuildForHost.withPackages (p: [
p.aiohttp
p.rich
p.structlog
Expand Down
11 changes: 8 additions & 3 deletions lib/tests/release.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{ # The pkgs used for dependencies for the testing itself
# Don't test properties of pkgs.lib, but rather the lib in the parent directory
pkgs ? import ../.. {} // { lib = throw "pkgs.lib accessed, but the lib tests should use nixpkgs' lib path directly!"; },
# For testing someone may edit impure.nix to return cross pkgs, use `pkgsBuildBuild` directly so everything here works.
pkgsBB ? pkgs.pkgsBuildBuild,
nix ? pkgs-nixVersions.stable,
nixVersions ? [ pkgs-nixVersions.minimum nix pkgs-nixVersions.latest ],
pkgs-nixVersions ? import ./nix-for-tests.nix { inherit pkgs; },
pkgs-nixVersions ? import ./nix-for-tests.nix { pkgs = pkgsBB; },
}:

let
lib = import ../.;
testWithNix = nix:
import ./test-with-nix.nix { inherit lib nix pkgs; };
import ./test-with-nix.nix {
inherit lib nix;
pkgs = pkgsBB;
};

in
pkgs.symlinkJoin {
pkgsBB.symlinkJoin {
name = "nixpkgs-lib-tests";
paths = map testWithNix nixVersions;
}
8 changes: 4 additions & 4 deletions pkgs/applications/networking/cluster/k3s/builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,25 @@ let
s:
mutFirstChar lib.toLower (lib.concatMapStrings (mutFirstChar lib.toUpper) (lib.splitString "-" s));

# finds the images archive for the desired architecture, aborts in case no suitable archive is found
# finds the images archive for the desired architecture, throws in case no suitable archive is found
findImagesArchive =
arch:
let
imagesVersionsNames = builtins.attrNames imagesVersions;
in
lib.findFirst (
n: lib.hasInfix arch n
) (abort "k3s: no airgap images for ${arch} available") imagesVersionsNames;
) (throw "k3s: no airgap images for ${arch} available") imagesVersionsNames;

# a shortcut that provides the images archive for the host platform. Currently only supports
# aarch64 (arm64) and x86_64 (amd64), aborts on other architectures.
# aarch64 (arm64) and x86_64 (amd64), throws on other architectures.
airgapImages = fetchurl (
if stdenv.hostPlatform.isAarch64 then
imagesVersions.${findImagesArchive "arm64"}
else if stdenv.hostPlatform.isx86_64 then
imagesVersions.${findImagesArchive "amd64"}
else
abort "k3s: airgap images cannot be found automatically for architecture ${stdenv.hostPlatform.linuxArch}, consider using an image archive with an explicit architecture."
throw "k3s: airgap images cannot be found automatically for architecture ${stdenv.hostPlatform.linuxArch}, consider using an image archive with an explicit architecture."
);

# so, k3s is a complicated thing to package
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/de/debase/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ stdenv.mkDerivation rec {
else if stdenv.hostPlatform.isAarch64 then
"arm64"
else
abort "unsupported system: ${stdenv.system}"
throw "unsupported system: ${stdenv.system}"
}"
];

Expand Down
18 changes: 6 additions & 12 deletions pkgs/by-name/fr/frr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@
, nettools
, nixosTests

# FRR's configure.ac gets SNMP options by executing net-snmp-config on the build host
# This leads to compilation errors when cross compiling.
# E.g. net-snmp-config for x86_64 does not return the ARM64 paths.
#
# SNMP_LIBS="`${NETSNMP_CONFIG} --agent-libs`"
# SNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags`"
, snmpSupport ? stdenv.buildPlatform.canExecute stdenv.hostPlatform

# other general options besides snmp support

# general options
, snmpSupport ? true
, rpkiSupport ? true
, numMultipath ? 64
, watchfrrSupport ? true
Expand Down Expand Up @@ -81,9 +75,6 @@
, ospfApi ? true
}:

lib.warnIf (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform))
"cannot enable SNMP support due to cross-compilation issues with net-snmp-config"

stdenv.mkDerivation (finalAttrs: {
pname = "frr";
version = "10.1";
Expand Down Expand Up @@ -194,6 +185,9 @@ stdenv.mkDerivation (finalAttrs: {
(lib.strings.enableFeature ospfApi "ospfapi")
# Cumulus options
(lib.strings.enableFeature cumulusSupport "cumulus")
] ++ lib.optionals snmpSupport [
# Used during build for paths, `dev` has build shebangs so can be run during build.
"NETSNMP_CONFIG=${lib.getDev net-snmp}/bin/net-snmp-config"
];

postPatch = ''
Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/ni/nim-unwrapped-2_2/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let
else if isx86_64 then
"amd64"
else
abort "no Nim CPU support known for ${config}";
throw "no Nim CPU support known for ${config}";

parseOs =
platform:
Expand All @@ -72,7 +72,7 @@ let
else if isiOS then
"iOS"
else
abort "no Nim OS support known for ${config}";
throw "no Nim OS support known for ${config}";

parsePlatform = p: {
cpu = parseCpu p;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/re/reposilite/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
makeScopeWithSplicing',
}:
makeScopeWithSplicing' {
otherSplices = generateSplicesForMkScope;
otherSplices = generateSplicesForMkScope "reposilitePlugins";
f =
self:
{
Expand Down
4 changes: 1 addition & 3 deletions pkgs/by-name/sa/saleae-logic/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ let

in

assert stdenv.hostPlatform.system == "x86_64-linux";

stdenv.mkDerivation rec {
pname = "saleae-logic";
version = "1.2.18";
Expand Down Expand Up @@ -92,7 +90,7 @@ stdenv.mkDerivation rec {
homepage = "https://www.saleae.com/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;
platforms = platforms.linux;
platforms = intersectLists platforms.x86_64 platforms.linux;
maintainers = [ maintainers.bjornfor ];
};
}
2 changes: 1 addition & 1 deletion pkgs/by-name/vi/virtual-ans/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
startScript = if stdenv.hostPlatform.isx86_32 then "START_LINUX_X86"
else if stdenv.hostPlatform.isx86_64 then "START_LINUX_X86_64"
#else if stdenv.hostPlatform.isDarwin then "START_MACOS.app" # disabled because I cannot test on Darwin
else abort "Unsupported platform: ${stdenv.hostPlatform.linuxArch}.";
else throw "Unsupported platform: ${stdenv.hostPlatform.linuxArch}.";

linuxExecutable = if stdenv.hostPlatform.isx86_32 then "pixilang_linux_x86"
else if stdenv.hostPlatform.isx86_64 then "pixilang_linux_x86_64"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/swift/compiler/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ in stdenv.mkDerivation {
";
buildProject lldb llvm-project/lldb
${lib.optionalString stdenv.hostPlatform.isDarwin ''
${lib.optionalString stdenv.targetPlatform.isDarwin ''
# Need to do a standalone build of concurrency for Darwin back deployment.
# Based on: utils/swift_build_support/swift_build_support/products/backdeployconcurrency.py
cmakeFlags="
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ stdenv.mkDerivation ({
buildInputs =
otherBuildInputsSystem;
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${buildPackages.glibcLocales}/lib/locale/locale-archive";
LOCALE_ARCHIVE = lib.optionalString (stdenv.buildPlatform.libc == "glibc") "${buildPackages.glibcLocales}/lib/locale/locale-archive";
"NIX_${ghcCommandCaps}" = "${ghcEnv}/bin/${ghcCommand}";
"NIX_${ghcCommandCaps}PKG" = "${ghcEnv}/bin/${ghcCommand}-pkg";
# TODO: is this still valid?
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/interpreters/python/cpython/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ let
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"--disable-toolbox-glue"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"PYTHON_FOR_BUILD=${lib.getBin buildPackages.python}/bin/python"
"PYTHON_FOR_BUILD=${lib.getBin buildPackages.python27}/bin/python"
"ac_cv_buggy_getaddrinfo=no"
# Assume little-endian IEEE 754 floating point when cross compiling
"ac_cv_little_endian_double=yes"
Expand Down Expand Up @@ -239,7 +239,7 @@ let
nativeBuildInputs =
[ autoreconfHook ]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform)
[ buildPackages.stdenv.cc buildPackages.python ];
[ buildPackages.stdenv.cc buildPackages.python27 ];

mkPaths = paths: {
C_INCLUDE_PATH = lib.makeSearchPathOutput "dev" "include" paths;
Expand Down
5 changes: 4 additions & 1 deletion pkgs/test/stdenv/gcc-stageCompare.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}:

assert stdenv.cc.isGNU;

with pkgs;
# rebuild gcc using the "final" stdenv
let gcc-stageCompare = (gcc-unwrapped.override {
Expand All @@ -25,7 +26,9 @@ let gcc-stageCompare = (gcc-unwrapped.override {
}).overrideAttrs(_: {
NIX_OUTPATH_USED_AS_RANDOM_SEED = stdenv.cc.cc.out;
});
in (runCommand "gcc-stageCompare" {} ''
in
assert lib.assertMsg (gcc-stageCompare ? checksum) "tests-stdenv-gcc-stageCompare: No `checksum` output in `gcc-stageCompare` see conditional in `gcc/common/checksum.nix`";
(runCommand "gcc-stageCompare" {} ''
diff -sr ${pkgs.gcc-unwrapped.checksum}/checksums ${gcc-stageCompare.checksum}/checksums && touch $out
'').overrideAttrs (a: {
meta = (a.meta or { }) // { platforms = lib.platforms.linux; };
Expand Down

0 comments on commit a0a35b6

Please sign in to comment.