2024-06-30 08:12:46 +00:00
|
|
|
/*
|
|
|
|
The top-level package collection of nixpkgs.
|
|
|
|
It is sorted by categories corresponding to the folder names in the /pkgs
|
|
|
|
folder. Inside the categories packages are roughly sorted by alphabet, but
|
|
|
|
strict sorting has been long lost due to merges. Please use the full-text
|
|
|
|
search of your editor. ;)
|
|
|
|
Hint: ### starts category names.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
lib,
|
|
|
|
noSysDirs,
|
|
|
|
config,
|
|
|
|
overlays,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
res: pkgs: super:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
{
|
|
|
|
# A module system style type tag
|
|
|
|
#
|
|
|
|
# Allows the nixpkgs fixpoint, usually known as `pkgs` to be distinguished
|
|
|
|
# nominally.
|
|
|
|
#
|
|
|
|
# pkgs._type == "pkgs"
|
|
|
|
# pkgs.pkgsStatic._type == "pkgs"
|
|
|
|
#
|
|
|
|
# Design note:
|
|
|
|
# While earlier stages of nixpkgs fixpoint construction are supertypes of this
|
|
|
|
# stage, they're generally not usable in places where a `pkgs` is expected.
|
|
|
|
# (earlier stages being the various `super` variables that precede
|
|
|
|
# all-packages.nix)
|
|
|
|
_type = "pkgs";
|
|
|
|
|
|
|
|
# A stdenv capable of building 32-bit binaries.
|
|
|
|
# On x86_64-linux, it uses GCC compiled with multilib support; on i686-linux,
|
|
|
|
# it's just the plain stdenv.
|
|
|
|
stdenv_32bit = lowPrio (if stdenv.hostPlatform.is32bit then stdenv else multiStdenv);
|
|
|
|
|
|
|
|
stdenvNoCC = stdenv.override (
|
2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
cc = null;
|
|
|
|
hasCC = false;
|
2024-05-02 00:46:19 +00:00
|
|
|
}
|
2024-06-30 08:12:46 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
lib.optionalAttrs (stdenv.hostPlatform.isDarwin && (stdenv.hostPlatform != stdenv.buildPlatform))
|
|
|
|
{
|
|
|
|
# TODO: This is a hack to use stdenvNoCC to produce a CF when cross
|
|
|
|
# compiling. It's not very sound. The cross stdenv has:
|
|
|
|
# extraBuildInputs = [ targetPackages.darwin.apple_sdks.frameworks.CoreFoundation ]
|
|
|
|
# and uses stdenvNoCC. In order to make this not infinitely recursive, we
|
|
|
|
# need to exclude this extraBuildInput.
|
|
|
|
extraBuildInputs = [ ];
|
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
);
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
mkStdenvNoLibs =
|
|
|
|
stdenv:
|
2024-05-02 00:46:19 +00:00
|
|
|
let
|
|
|
|
bintools = stdenv.cc.bintools.override {
|
|
|
|
libc = null;
|
|
|
|
noLibc = true;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.override {
|
|
|
|
cc = stdenv.cc.override {
|
|
|
|
libc = null;
|
|
|
|
noLibc = true;
|
|
|
|
extraPackages = [ ];
|
|
|
|
inherit bintools;
|
|
|
|
};
|
2024-06-30 08:12:46 +00:00
|
|
|
allowedRequisites = lib.mapNullable (rs: rs ++ [ bintools ]) (stdenv.allowedRequisites or null);
|
2024-05-02 00:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
stdenvNoLibs =
|
2024-06-30 08:12:46 +00:00
|
|
|
if
|
|
|
|
stdenv.hostPlatform != stdenv.buildPlatform
|
|
|
|
&& (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.useLLVM or false)
|
2024-05-02 00:46:19 +00:00
|
|
|
then
|
2024-06-30 08:12:46 +00:00
|
|
|
# We cannot touch binutils or cc themselves, because that will cause
|
|
|
|
# infinite recursion. So instead, we just choose a libc based on the
|
|
|
|
# current platform. That means we won't respect whatever compiler was
|
|
|
|
# passed in with the stdenv stage argument.
|
|
|
|
#
|
|
|
|
# TODO It would be much better to pass the `stdenvNoCC` and *unwrapped*
|
|
|
|
# cc, bintools, compiler-rt equivalent, etc. and create all final stdenvs
|
|
|
|
# as part of the stage. Then we would never be tempted to override a later
|
|
|
|
# thing to to create an earlier thing (leading to infinite recursion) and
|
|
|
|
# we also would still respect the stage arguments choices for these
|
|
|
|
# things.
|
2024-05-02 00:46:19 +00:00
|
|
|
overrideCC stdenv buildPackages.llvmPackages.clangNoCompilerRt
|
2024-06-30 08:12:46 +00:00
|
|
|
else
|
|
|
|
mkStdenvNoLibs stdenv;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
gccStdenvNoLibs = mkStdenvNoLibs gccStdenv;
|
|
|
|
clangStdenvNoLibs = mkStdenvNoLibs clangStdenv;
|
|
|
|
|
|
|
|
# For convenience, allow callers to get the path to Nixpkgs.
|
|
|
|
path = ../..;
|
|
|
|
|
|
|
|
### Helper functions.
|
|
|
|
inherit lib config overlays;
|
|
|
|
|
|
|
|
# do not import 'appendToName' to get consistent package-names with the same
|
|
|
|
# set of package-parameters: https://github.com/NixOS/nixpkgs/issues/68519
|
|
|
|
inherit (lib) lowPrio hiPrio makeOverridable;
|
|
|
|
|
|
|
|
inherit (lib) recurseIntoAttrs;
|
|
|
|
|
|
|
|
# This is intended to be the reverse of recurseIntoAttrs, as it is
|
|
|
|
# defined now it exists mainly for documentation purposes, but you
|
|
|
|
# can also override this with recurseIntoAttrs to recurseInto all
|
|
|
|
# the Attrs which is useful for testing massive changes. Ideally,
|
|
|
|
# every package subset not marked with recurseIntoAttrs should be
|
|
|
|
# marked with this.
|
|
|
|
inherit (lib) dontRecurseIntoAttrs;
|
|
|
|
|
|
|
|
stringsWithDeps = lib.stringsWithDeps;
|
|
|
|
|
|
|
|
tests = callPackages ../test { };
|
|
|
|
|
|
|
|
# These are used when buiding compiler-rt / libgcc, prior to building libc.
|
|
|
|
preLibcCrossHeaders =
|
|
|
|
let
|
|
|
|
inherit (stdenv.targetPlatform) libc;
|
|
|
|
in
|
2024-06-30 08:12:46 +00:00
|
|
|
if stdenv.targetPlatform.isMinGW then
|
|
|
|
targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers
|
|
|
|
else if libc == "nblibc" then
|
|
|
|
targetPackages.netbsdCross.headers or netbsdCross.headers
|
|
|
|
else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then
|
|
|
|
targetPackages.darwin.LibsystemCross or darwin.LibsystemCross
|
|
|
|
else
|
|
|
|
null;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
# We can choose:
|
2024-06-30 08:12:46 +00:00
|
|
|
libcCrossChooser =
|
|
|
|
name:
|
2024-05-02 00:46:19 +00:00
|
|
|
# libc is hackily often used from the previous stage. This `or`
|
|
|
|
# hack fixes the hack, *sigh*.
|
2024-06-30 08:12:46 +00:00
|
|
|
if name == null then
|
|
|
|
null
|
|
|
|
else if name == "glibc" then
|
|
|
|
targetPackages.glibcCross or glibcCross
|
|
|
|
else if name == "bionic" then
|
|
|
|
targetPackages.bionic or bionic
|
|
|
|
else if name == "uclibc" then
|
|
|
|
targetPackages.uclibcCross or uclibcCross
|
|
|
|
else if name == "avrlibc" then
|
|
|
|
targetPackages.avrlibcCross or avrlibcCross
|
|
|
|
else if name == "newlib" && stdenv.targetPlatform.isMsp430 then
|
|
|
|
targetPackages.msp430NewlibCross or msp430NewlibCross
|
|
|
|
else if name == "newlib" && stdenv.targetPlatform.isVc4 then
|
|
|
|
targetPackages.vc4-newlib or vc4-newlib
|
|
|
|
else if name == "newlib" && stdenv.targetPlatform.isOr1k then
|
|
|
|
targetPackages.or1k-newlib or or1k-newlib
|
|
|
|
else if name == "newlib" then
|
|
|
|
targetPackages.newlibCross or newlibCross
|
|
|
|
else if name == "newlib-nano" then
|
|
|
|
targetPackages.newlib-nanoCross or newlib-nanoCross
|
|
|
|
else if name == "musl" then
|
|
|
|
targetPackages.muslCross or muslCross
|
|
|
|
else if name == "msvcrt" then
|
|
|
|
targetPackages.windows.mingw_w64 or windows.mingw_w64
|
|
|
|
else if name == "ucrt" then
|
|
|
|
targetPackages.windows.mingw_w64 or windows.mingw_w64
|
2024-05-02 00:46:19 +00:00
|
|
|
else if name == "libSystem" then
|
2024-06-30 08:12:46 +00:00
|
|
|
if stdenv.targetPlatform.useiOSPrebuilt then
|
|
|
|
targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries
|
|
|
|
else
|
|
|
|
targetPackages.darwin.LibsystemCross
|
|
|
|
or (throw "don't yet have a `targetPackages.darwin.LibsystemCross for ${stdenv.targetPlatform.config}`")
|
|
|
|
else if name == "fblibc" then
|
|
|
|
targetPackages.freebsdCross.libc or freebsdCross.libc
|
|
|
|
else if name == "nblibc" then
|
|
|
|
targetPackages.netbsdCross.libc or netbsdCross.libc
|
|
|
|
else if name == "wasilibc" then
|
|
|
|
targetPackages.wasilibc or wasilibc
|
|
|
|
else if name == "relibc" then
|
|
|
|
targetPackages.relibc or relibc
|
|
|
|
else
|
|
|
|
throw "Unknown libc ${name}";
|
|
|
|
|
|
|
|
libcCross =
|
|
|
|
assert stdenv.targetPlatform != stdenv.buildPlatform;
|
|
|
|
libcCrossChooser stdenv.targetPlatform.libc;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
threadsCross = threadsCrossFor null;
|
2024-06-30 08:12:46 +00:00
|
|
|
threadsCrossFor =
|
|
|
|
cc_version:
|
2024-05-02 00:46:19 +00:00
|
|
|
lib.optionalAttrs (stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false)) {
|
|
|
|
# other possible values: win32 or posix
|
|
|
|
model = "mcf";
|
|
|
|
# For win32 or posix set this to null
|
|
|
|
package =
|
2024-06-30 08:12:46 +00:00
|
|
|
if cc_version == null || lib.versionAtLeast cc_version "13" then
|
|
|
|
targetPackages.windows.mcfgthreads or windows.mcfgthreads
|
|
|
|
else
|
|
|
|
targetPackages.windows.mcfgthreads_pre_gcc_13 or windows.mcfgthreads_pre_gcc_13;
|
2024-05-02 00:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
multiStdenv = if stdenv.cc.isClang then clangMultiStdenv else gccMultiStdenv;
|
|
|
|
|
|
|
|
crossLibcStdenv =
|
2024-06-30 08:12:46 +00:00
|
|
|
if stdenv.hostPlatform.useLLVM or false || stdenv.hostPlatform.isDarwin then
|
|
|
|
overrideCC stdenv buildPackages.llvmPackages.clangNoLibc
|
|
|
|
else
|
|
|
|
gccCrossLibcStdenv;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
runtimeShell = "${runtimeShellPackage}${runtimeShellPackage.shellPath}";
|
|
|
|
runtimeShellPackage = bash;
|
|
|
|
}
|