mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
pkgs/top-level: refactor mkHybridPkgs
This commit is contained in:
parent
ba6262f2eb
commit
69775e2deb
1 changed files with 23 additions and 29 deletions
|
@ -191,7 +191,13 @@ let
|
|||
});
|
||||
# This is always cross.
|
||||
mkCrossPkgs = name: crossAttrs: mkPkgs name (prevArgs: {
|
||||
crossSystem = (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // crossAttrs;
|
||||
crossSystem =
|
||||
(lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // crossAttrs;
|
||||
});
|
||||
# This is only cross when we are already cross, otherwise local.
|
||||
mkHybridPkgs = name: hybridAttrs: mkPkgs name (prevArgs: {
|
||||
${if stdenv.hostPlatform == stdenv.buildPlatform then "localSystem" else "crossSystem"} =
|
||||
(lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // hybridAttrs;
|
||||
});
|
||||
in self: super: {
|
||||
# This maps each entry in lib.systems.examples to its own package
|
||||
|
@ -234,33 +240,24 @@ let
|
|||
# All packages built with the Musl libc. This will override the
|
||||
# default GNU libc on Linux systems. Non-Linux systems are not
|
||||
# supported. 32-bit is also not supported.
|
||||
pkgsMusl = if stdenv.hostPlatform.isLinux && stdenv.buildPlatform.is64bit then mkPkgs "pkgsMusl" (prevArgs: {
|
||||
${if stdenv.hostPlatform == stdenv.buildPlatform
|
||||
then "localSystem" else "crossSystem"} = (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // {
|
||||
config = lib.systems.parse.tripleFromSystem (makeMuslParsedPlatform stdenv.hostPlatform.parsed);
|
||||
};
|
||||
}) else throw "Musl libc only supports 64-bit Linux systems.";
|
||||
pkgsMusl = if stdenv.hostPlatform.isLinux && stdenv.buildPlatform.is64bit then mkHybridPkgs "pkgsMusl" {
|
||||
config = lib.systems.parse.tripleFromSystem (makeMuslParsedPlatform stdenv.hostPlatform.parsed);
|
||||
} else throw "Musl libc only supports 64-bit Linux systems.";
|
||||
|
||||
# All packages built for i686 Linux.
|
||||
# Used by wine, firefox with debugging version of Flash, ...
|
||||
pkgsi686Linux = if stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86 then mkPkgs "pkgsi686Linux" (prevArgs: {
|
||||
${if stdenv.hostPlatform == stdenv.buildPlatform
|
||||
then "localSystem" else "crossSystem"} = (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // {
|
||||
config = lib.systems.parse.tripleFromSystem (stdenv.hostPlatform.parsed // {
|
||||
cpu = lib.systems.parse.cpuTypes.i686;
|
||||
});
|
||||
};
|
||||
}) else throw "i686 Linux package set can only be used with the x86 family.";
|
||||
pkgsi686Linux = if stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86 then mkHybridPkgs "pkgsi686Linux" {
|
||||
config = lib.systems.parse.tripleFromSystem (stdenv.hostPlatform.parsed // {
|
||||
cpu = lib.systems.parse.cpuTypes.i686;
|
||||
});
|
||||
} else throw "i686 Linux package set can only be used with the x86 family.";
|
||||
|
||||
# x86_64-darwin packages for aarch64-darwin users to use with Rosetta for incompatible packages
|
||||
pkgsx86_64Darwin = if stdenv.hostPlatform.isDarwin then mkPkgs "pkgsx86_64Darwin" (prevArgs: {
|
||||
${if stdenv.hostPlatform == stdenv.buildPlatform
|
||||
then "localSystem" else "crossSystem"} = (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // {
|
||||
config = lib.systems.parse.tripleFromSystem (stdenv.hostPlatform.parsed // {
|
||||
cpu = lib.systems.parse.cpuTypes.x86_64;
|
||||
});
|
||||
};
|
||||
}) else throw "x86_64 Darwin package set can only be used on Darwin systems.";
|
||||
pkgsx86_64Darwin = if stdenv.hostPlatform.isDarwin then mkHybridPkgs "pkgsx86_64Darwin" {
|
||||
config = lib.systems.parse.tripleFromSystem (stdenv.hostPlatform.parsed // {
|
||||
cpu = lib.systems.parse.cpuTypes.x86_64;
|
||||
});
|
||||
} else throw "x86_64 Darwin package set can only be used on Darwin systems.";
|
||||
|
||||
# If already linux: the same package set unaltered
|
||||
# Otherwise, return a linux package set for the current cpu architecture string.
|
||||
|
@ -268,12 +265,9 @@ let
|
|||
pkgsLinux =
|
||||
if stdenv.hostPlatform.isLinux
|
||||
then self
|
||||
else mkPkgs "pkgsLinux" (prevArgs: {
|
||||
${if stdenv.hostPlatform == stdenv.buildPlatform
|
||||
then "localSystem" else "crossSystem"} = (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // {
|
||||
config = lib.systems.parse.tripleFromSystem (lib.systems.elaborate "${stdenv.hostPlatform.parsed.cpu.name}-linux").parsed;
|
||||
};
|
||||
});
|
||||
else mkHybridPkgs "pkgsLinux" {
|
||||
config = lib.systems.parse.tripleFromSystem (lib.systems.elaborate "${stdenv.hostPlatform.parsed.cpu.name}-linux").parsed;
|
||||
};
|
||||
|
||||
# Fully static packages.
|
||||
# Currently uses Musl on Linux (couldn’t get static glibc to work).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue