lib: Clean up how linux and gcc config is specified

Second attempt of 8929989614589ee3acd070a6409b2b9700c92d65; see that
commit for details.

This reverts commit 0bc275e634.
This commit is contained in:
John Ericson 2021-01-22 20:33:55 -05:00
parent 2bc16b381e
commit 9c213398b3
38 changed files with 440 additions and 434 deletions

View file

@ -1,7 +1,7 @@
{ lib }: { lib }:
rec { rec {
# platform.gcc.arch to its features (as in /proc/cpuinfo) # gcc.arch to its features (as in /proc/cpuinfo)
features = { features = {
default = [ ]; default = [ ];
# x86_64 Intel # x86_64 Intel

View file

@ -24,8 +24,6 @@ rec {
# Either of these can be losslessly-extracted from `parsed` iff parsing succeeds. # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.
system = parse.doubleFromSystem final.parsed; system = parse.doubleFromSystem final.parsed;
config = parse.tripleFromSystem final.parsed; config = parse.tripleFromSystem final.parsed;
# Just a guess, based on `system`
platform = platforms.select final;
# Determine whether we are compatible with the provided CPU # Determine whether we are compatible with the provided CPU
isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu; isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu;
# Derived meta-data # Derived meta-data
@ -79,11 +77,20 @@ rec {
}; };
isStatic = final.isWasm || final.isRedox; isStatic = final.isWasm || final.isRedox;
kernelArch = # Just a guess, based on `system`
inherit
({
linux-kernel = args.linux-kernel or {};
gcc = args.gcc or {};
rustc = args.rust or {};
} // platforms.select final)
linux-kernel gcc rustc;
linuxArch =
if final.isAarch32 then "arm" if final.isAarch32 then "arm"
else if final.isAarch64 then "arm64" else if final.isAarch64 then "arm64"
else if final.isx86_32 then "x86" else if final.isx86_32 then "i386"
else if final.isx86_64 then "x86" else if final.isx86_64 then "x86_64"
else if final.isMips then "mips" else if final.isMips then "mips"
else final.parsed.cpu.name; else final.parsed.cpu.name;
@ -129,7 +136,7 @@ rec {
else throw "Don't know how to run ${final.config} executables."; else throw "Don't know how to run ${final.config} executables.";
} // mapAttrs (n: v: v final.parsed) inspect.predicates } // mapAttrs (n: v: v final.parsed) inspect.predicates
// mapAttrs (n: v: v final.platform.gcc.arch or "default") architectures.predicates // mapAttrs (n: v: v final.gcc.arch or "default") architectures.predicates
// args; // args;
in assert final.useAndroidPrebuilt -> final.isAndroid; in assert final.useAndroidPrebuilt -> final.isAndroid;
assert lib.foldl assert lib.foldl

View file

@ -7,7 +7,6 @@ let
riscv = bits: { riscv = bits: {
config = "riscv${bits}-unknown-linux-gnu"; config = "riscv${bits}-unknown-linux-gnu";
platform = platforms.riscv-multiplatform;
}; };
in in
@ -17,84 +16,68 @@ rec {
# #
powernv = { powernv = {
config = "powerpc64le-unknown-linux-gnu"; config = "powerpc64le-unknown-linux-gnu";
platform = platforms.powernv;
}; };
musl-power = { musl-power = {
config = "powerpc64le-unknown-linux-musl"; config = "powerpc64le-unknown-linux-musl";
platform = platforms.powernv;
}; };
sheevaplug = { sheevaplug = {
config = "armv5tel-unknown-linux-gnueabi"; config = "armv5tel-unknown-linux-gnueabi";
platform = platforms.sheevaplug; } // platforms.sheevaplug;
};
raspberryPi = { raspberryPi = {
config = "armv6l-unknown-linux-gnueabihf"; config = "armv6l-unknown-linux-gnueabihf";
platform = platforms.raspberrypi; } // platforms.raspberrypi;
};
remarkable1 = { remarkable1 = {
config = "armv7l-unknown-linux-gnueabihf"; config = "armv7l-unknown-linux-gnueabihf";
platform = platforms.zero-gravitas; } // platforms.zero-gravitas;
};
remarkable2 = { remarkable2 = {
config = "armv7l-unknown-linux-gnueabihf"; config = "armv7l-unknown-linux-gnueabihf";
platform = platforms.zero-sugar; } // platforms.zero-sugar;
};
armv7l-hf-multiplatform = { armv7l-hf-multiplatform = {
config = "armv7l-unknown-linux-gnueabihf"; config = "armv7l-unknown-linux-gnueabihf";
platform = platforms.armv7l-hf-multiplatform;
}; };
aarch64-multiplatform = { aarch64-multiplatform = {
config = "aarch64-unknown-linux-gnu"; config = "aarch64-unknown-linux-gnu";
platform = platforms.aarch64-multiplatform;
}; };
armv7a-android-prebuilt = { armv7a-android-prebuilt = {
config = "armv7a-unknown-linux-androideabi"; config = "armv7a-unknown-linux-androideabi";
sdkVer = "29"; sdkVer = "29";
ndkVer = "21"; ndkVer = "21";
platform = platforms.armv7a-android;
useAndroidPrebuilt = true; useAndroidPrebuilt = true;
}; } // platforms.armv7a-android;
aarch64-android-prebuilt = { aarch64-android-prebuilt = {
config = "aarch64-unknown-linux-android"; config = "aarch64-unknown-linux-android";
sdkVer = "29"; sdkVer = "29";
ndkVer = "21"; ndkVer = "21";
platform = platforms.aarch64-multiplatform;
useAndroidPrebuilt = true; useAndroidPrebuilt = true;
}; };
scaleway-c1 = armv7l-hf-multiplatform // rec { scaleway-c1 = armv7l-hf-multiplatform // platforms.scaleway-c1;
platform = platforms.scaleway-c1;
inherit (platform.gcc) fpu;
};
pogoplug4 = { pogoplug4 = {
config = "armv5tel-unknown-linux-gnueabi"; config = "armv5tel-unknown-linux-gnueabi";
platform = platforms.pogoplug4; } // platforms.pogoplug4;
};
ben-nanonote = { ben-nanonote = {
config = "mipsel-unknown-linux-uclibc"; config = "mipsel-unknown-linux-uclibc";
platform = platforms.ben_nanonote; } // platforms.ben_nanonote;
};
fuloongminipc = { fuloongminipc = {
config = "mipsel-unknown-linux-gnu"; config = "mipsel-unknown-linux-gnu";
platform = platforms.fuloong2f_n32; } // platforms.fuloong2f_n32;
};
muslpi = raspberryPi // { muslpi = raspberryPi // {
config = "armv6l-unknown-linux-musleabihf"; config = "armv6l-unknown-linux-musleabihf";
}; };
aarch64-multiplatform-musl = aarch64-multiplatform // { aarch64-multiplatform-musl = {
config = "aarch64-unknown-linux-musl"; config = "aarch64-unknown-linux-musl";
}; };
@ -110,13 +93,11 @@ rec {
riscv64-embedded = { riscv64-embedded = {
config = "riscv64-none-elf"; config = "riscv64-none-elf";
libc = "newlib"; libc = "newlib";
platform = platforms.riscv-multiplatform;
}; };
riscv32-embedded = { riscv32-embedded = {
config = "riscv32-none-elf"; config = "riscv32-none-elf";
libc = "newlib"; libc = "newlib";
platform = platforms.riscv-multiplatform;
}; };
mmix = { mmix = {
@ -136,13 +117,11 @@ rec {
vc4 = { vc4 = {
config = "vc4-elf"; config = "vc4-elf";
libc = "newlib"; libc = "newlib";
platform = {};
}; };
or1k = { or1k = {
config = "or1k-elf"; config = "or1k-elf";
libc = "newlib"; libc = "newlib";
platform = {};
}; };
arm-embedded = { arm-embedded = {
@ -204,7 +183,6 @@ rec {
xcodeVer = "11.3.1"; xcodeVer = "11.3.1";
xcodePlatform = "iPhoneOS"; xcodePlatform = "iPhoneOS";
useiOSPrebuilt = true; useiOSPrebuilt = true;
platform = {};
}; };
iphone32 = { iphone32 = {
@ -214,7 +192,6 @@ rec {
xcodeVer = "11.3.1"; xcodeVer = "11.3.1";
xcodePlatform = "iPhoneOS"; xcodePlatform = "iPhoneOS";
useiOSPrebuilt = true; useiOSPrebuilt = true;
platform = {};
}; };
iphone64-simulator = { iphone64-simulator = {
@ -224,7 +201,6 @@ rec {
xcodeVer = "11.3.1"; xcodeVer = "11.3.1";
xcodePlatform = "iPhoneSimulator"; xcodePlatform = "iPhoneSimulator";
useiOSPrebuilt = true; useiOSPrebuilt = true;
platform = {};
}; };
iphone32-simulator = { iphone32-simulator = {
@ -234,7 +210,6 @@ rec {
xcodeVer = "11.3.1"; xcodeVer = "11.3.1";
xcodePlatform = "iPhoneSimulator"; xcodePlatform = "iPhoneSimulator";
useiOSPrebuilt = true; useiOSPrebuilt = true;
platform = {};
}; };
# #
@ -245,7 +220,6 @@ rec {
mingw32 = { mingw32 = {
config = "i686-w64-mingw32"; config = "i686-w64-mingw32";
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
platform = {};
}; };
# 64 bit mingw-w64 # 64 bit mingw-w64
@ -253,7 +227,6 @@ rec {
# That's the triplet they use in the mingw-w64 docs. # That's the triplet they use in the mingw-w64 docs.
config = "x86_64-w64-mingw32"; config = "x86_64-w64-mingw32";
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
platform = {};
}; };
# BSDs # BSDs
@ -275,6 +248,5 @@ rec {
# Ghcjs # Ghcjs
ghcjs = { ghcjs = {
config = "js-unknown-ghcjs"; config = "js-unknown-ghcjs";
platform = {};
}; };
} }

View file

@ -1,39 +1,36 @@
{ lib }: { lib }:
rec { rec {
pcBase = { pc = {
name = "pc"; linux-kernel = {
kernelBaseConfig = "defconfig"; name = "pc";
# Build whatever possible as a module, if not stated in the extra config.
kernelAutoModules = true; baseConfig = "defconfig";
kernelTarget = "bzImage"; # Build whatever possible as a module, if not stated in the extra config.
autoModules = true;
target = "bzImage";
};
}; };
pc64 = pcBase // { kernelArch = "x86_64"; }; pc_simplekernel = lib.recursiveUpdate pc {
linux-kernel.autoModules = false;
pc32 = pcBase // { kernelArch = "i386"; };
pc32_simplekernel = pc32 // {
kernelAutoModules = false;
};
pc64_simplekernel = pc64 // {
kernelAutoModules = false;
}; };
powernv = { powernv = {
name = "PowerNV"; linux-kernel = {
kernelArch = "powerpc"; name = "PowerNV";
kernelBaseConfig = "powernv_defconfig";
kernelTarget = "zImage"; baseConfig = "powernv_defconfig";
kernelInstallTarget = "install"; target = "zImage";
kernelFile = "vmlinux"; installTarget = "install";
kernelAutoModules = true; file = "vmlinux";
# avoid driver/FS trouble arising from unusual page size autoModules = true;
kernelExtraConfig = '' # avoid driver/FS trouble arising from unusual page size
PPC_64K_PAGES n extraConfig = ''
PPC_4K_PAGES y PPC_64K_PAGES n
IPV6 y PPC_4K_PAGES y
''; IPV6 y
'';
};
}; };
## ##
@ -41,17 +38,12 @@ rec {
## ##
pogoplug4 = { pogoplug4 = {
name = "pogoplug4"; linux-kernel = {
name = "pogoplug4";
gcc = { baseConfig = "multi_v5_defconfig";
arch = "armv5te"; autoModules = false;
}; extraConfig = ''
kernelBaseConfig = "multi_v5_defconfig";
kernelArch = "arm";
kernelAutoModules = false;
kernelExtraConfig =
''
# Ubi for the mtd # Ubi for the mtd
MTD_UBI y MTD_UBI y
UBIFS_FS y UBIFS_FS y
@ -61,136 +53,144 @@ rec {
UBIFS_FS_ZLIB y UBIFS_FS_ZLIB y
UBIFS_FS_DEBUG n UBIFS_FS_DEBUG n
''; '';
kernelMakeFlags = [ "LOADADDR=0x8000" ]; makeFlags = [ "LOADADDR=0x8000" ];
kernelTarget = "uImage"; target = "uImage";
# TODO reenable once manual-config's config actually builds a .dtb and this is checked to be working # TODO reenable once manual-config's config actually builds a .dtb and this is checked to be working
#kernelDTB = true; #DTB = true;
};
gcc = {
arch = "armv5te";
};
}; };
sheevaplug = { sheevaplug = {
name = "sheevaplug"; linux-kernel = {
kernelBaseConfig = "multi_v5_defconfig"; name = "sheevaplug";
kernelArch = "arm";
kernelAutoModules = false;
kernelExtraConfig = ''
BLK_DEV_RAM y
BLK_DEV_INITRD y
BLK_DEV_CRYPTOLOOP m
BLK_DEV_DM m
DM_CRYPT m
MD y
REISERFS_FS m
BTRFS_FS m
XFS_FS m
JFS_FS m
EXT4_FS m
USB_STORAGE_CYPRESS_ATACB m
# mv cesa requires this sw fallback, for mv-sha1 baseConfig = "multi_v5_defconfig";
CRYPTO_SHA1 y autoModules = false;
# Fast crypto extraConfig = ''
CRYPTO_TWOFISH y BLK_DEV_RAM y
CRYPTO_TWOFISH_COMMON y BLK_DEV_INITRD y
CRYPTO_BLOWFISH y BLK_DEV_CRYPTOLOOP m
CRYPTO_BLOWFISH_COMMON y BLK_DEV_DM m
DM_CRYPT m
MD y
REISERFS_FS m
BTRFS_FS m
XFS_FS m
JFS_FS m
EXT4_FS m
USB_STORAGE_CYPRESS_ATACB m
IP_PNP y # mv cesa requires this sw fallback, for mv-sha1
IP_PNP_DHCP y CRYPTO_SHA1 y
NFS_FS y # Fast crypto
ROOT_NFS y CRYPTO_TWOFISH y
TUN m CRYPTO_TWOFISH_COMMON y
NFS_V4 y CRYPTO_BLOWFISH y
NFS_V4_1 y CRYPTO_BLOWFISH_COMMON y
NFS_FSCACHE y
NFSD m
NFSD_V2_ACL y
NFSD_V3 y
NFSD_V3_ACL y
NFSD_V4 y
NETFILTER y
IP_NF_IPTABLES y
IP_NF_FILTER y
IP_NF_MATCH_ADDRTYPE y
IP_NF_TARGET_LOG y
IP_NF_MANGLE y
IPV6 m
VLAN_8021Q m
CIFS y IP_PNP y
CIFS_XATTR y IP_PNP_DHCP y
CIFS_POSIX y NFS_FS y
CIFS_FSCACHE y ROOT_NFS y
CIFS_ACL y TUN m
NFS_V4 y
NFS_V4_1 y
NFS_FSCACHE y
NFSD m
NFSD_V2_ACL y
NFSD_V3 y
NFSD_V3_ACL y
NFSD_V4 y
NETFILTER y
IP_NF_IPTABLES y
IP_NF_FILTER y
IP_NF_MATCH_ADDRTYPE y
IP_NF_TARGET_LOG y
IP_NF_MANGLE y
IPV6 m
VLAN_8021Q m
WATCHDOG y CIFS y
WATCHDOG_CORE y CIFS_XATTR y
ORION_WATCHDOG m CIFS_POSIX y
CIFS_FSCACHE y
CIFS_ACL y
ZRAM m WATCHDOG y
NETCONSOLE m WATCHDOG_CORE y
ORION_WATCHDOG m
# Disable OABI to have seccomp_filter (required for systemd) ZRAM m
# https://github.com/raspberrypi/firmware/issues/651 NETCONSOLE m
OABI_COMPAT n
# Fail to build # Disable OABI to have seccomp_filter (required for systemd)
DRM n # https://github.com/raspberrypi/firmware/issues/651
SCSI_ADVANSYS n OABI_COMPAT n
USB_ISP1362_HCD n
SND_SOC n
SND_ALI5451 n
FB_SAVAGE n
SCSI_NSP32 n
ATA_SFF n
SUNGEM n
IRDA n
ATM_HE n
SCSI_ACARD n
BLK_DEV_CMD640_ENHANCED n
FUSE_FS m # Fail to build
DRM n
SCSI_ADVANSYS n
USB_ISP1362_HCD n
SND_SOC n
SND_ALI5451 n
FB_SAVAGE n
SCSI_NSP32 n
ATA_SFF n
SUNGEM n
IRDA n
ATM_HE n
SCSI_ACARD n
BLK_DEV_CMD640_ENHANCED n
# systemd uses cgroups FUSE_FS m
CGROUPS y
# Latencytop # systemd uses cgroups
LATENCYTOP y CGROUPS y
# Ubi for the mtd # Latencytop
MTD_UBI y LATENCYTOP y
UBIFS_FS y
UBIFS_FS_XATTR y
UBIFS_FS_ADVANCED_COMPR y
UBIFS_FS_LZO y
UBIFS_FS_ZLIB y
UBIFS_FS_DEBUG n
# Kdb, for kernel troubles # Ubi for the mtd
KGDB y MTD_UBI y
KGDB_SERIAL_CONSOLE y UBIFS_FS y
KGDB_KDB y UBIFS_FS_XATTR y
''; UBIFS_FS_ADVANCED_COMPR y
kernelMakeFlags = [ "LOADADDR=0x0200000" ]; UBIFS_FS_LZO y
kernelTarget = "uImage"; UBIFS_FS_ZLIB y
kernelDTB = true; # Beyond 3.10 UBIFS_FS_DEBUG n
# Kdb, for kernel troubles
KGDB y
KGDB_SERIAL_CONSOLE y
KGDB_KDB y
'';
makeFlags = [ "LOADADDR=0x0200000" ];
target = "uImage";
DTB = true; # Beyond 3.10
};
gcc = { gcc = {
arch = "armv5te"; arch = "armv5te";
}; };
}; };
raspberrypi = { raspberrypi = {
name = "raspberrypi"; linux-kernel = {
kernelBaseConfig = "bcm2835_defconfig"; name = "raspberrypi";
kernelDTB = true;
kernelArch = "arm"; baseConfig = "bcm2835_defconfig";
kernelAutoModules = true; DTB = true;
kernelPreferBuiltin = true; autoModules = true;
kernelExtraConfig = '' preferBuiltin = true;
# Disable OABI to have seccomp_filter (required for systemd) extraConfig = ''
# https://github.com/raspberrypi/firmware/issues/651 # Disable OABI to have seccomp_filter (required for systemd)
OABI_COMPAT n # https://github.com/raspberrypi/firmware/issues/651
''; OABI_COMPAT n
kernelTarget = "zImage"; '';
target = "zImage";
};
gcc = { gcc = {
arch = "armv6"; arch = "armv6";
fpu = "vfp"; fpu = "vfp";
@ -201,13 +201,15 @@ rec {
raspberrypi2 = armv7l-hf-multiplatform; raspberrypi2 = armv7l-hf-multiplatform;
zero-gravitas = { zero-gravitas = {
name = "zero-gravitas"; linux-kernel = {
kernelBaseConfig = "zero-gravitas_defconfig"; name = "zero-gravitas";
kernelArch = "arm";
# kernelTarget verified by checking /boot on reMarkable 1 device baseConfig = "zero-gravitas_defconfig";
kernelTarget = "zImage"; # Target verified by checking /boot on reMarkable 1 device
kernelAutoModules = false; target = "zImage";
kernelDTB = true; autoModules = false;
DTB = true;
};
gcc = { gcc = {
fpu = "neon"; fpu = "neon";
cpu = "cortex-a9"; cpu = "cortex-a9";
@ -215,13 +217,15 @@ rec {
}; };
zero-sugar = { zero-sugar = {
name = "zero-sugar"; linux-kernel = {
kernelBaseConfig = "zero-sugar_defconfig"; name = "zero-sugar";
kernelArch = "arm";
kernelDTB = true; baseConfig = "zero-sugar_defconfig";
kernelAutoModules = false; DTB = true;
kernelPreferBuiltin = true; autoModules = false;
kernelTarget = "zImage"; preferBuiltin = true;
target = "zImage";
};
gcc = { gcc = {
cpu = "cortex-a7"; cpu = "cortex-a7";
fpu = "neon-vfpv4"; fpu = "neon-vfpv4";
@ -229,7 +233,7 @@ rec {
}; };
}; };
scaleway-c1 = armv7l-hf-multiplatform // { scaleway-c1 = lib.recursiveUpdate armv7l-hf-multiplatform {
gcc = { gcc = {
cpu = "cortex-a9"; cpu = "cortex-a9";
fpu = "vfpv3"; fpu = "vfpv3";
@ -237,12 +241,11 @@ rec {
}; };
utilite = { utilite = {
name = "utilite"; linux-kernel = {
kernelBaseConfig = "multi_v7_defconfig"; name = "utilite";
kernelArch = "arm"; maseConfig = "multi_v7_defconfig";
kernelAutoModules = false; autoModules = false;
kernelExtraConfig = extraConfig = ''
''
# Ubi for the mtd # Ubi for the mtd
MTD_UBI y MTD_UBI y
UBIFS_FS y UBIFS_FS y
@ -252,35 +255,37 @@ rec {
UBIFS_FS_ZLIB y UBIFS_FS_ZLIB y
UBIFS_FS_DEBUG n UBIFS_FS_DEBUG n
''; '';
kernelMakeFlags = [ "LOADADDR=0x10800000" ]; makeFlags = [ "LOADADDR=0x10800000" ];
kernelTarget = "uImage"; target = "uImage";
kernelDTB = true; DTB = true;
};
gcc = { gcc = {
cpu = "cortex-a9"; cpu = "cortex-a9";
fpu = "neon"; fpu = "neon";
}; };
}; };
guruplug = sheevaplug // { guruplug = lib.recursiveUpdate sheevaplug {
# Define `CONFIG_MACH_GURUPLUG' (see # Define `CONFIG_MACH_GURUPLUG' (see
# <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>) # <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>)
# and other GuruPlug-specific things. Requires the `guruplug-defconfig' # and other GuruPlug-specific things. Requires the `guruplug-defconfig'
# patch. # patch.
linux-kernel.baseConfig = "guruplug_defconfig";
kernelBaseConfig = "guruplug_defconfig";
}; };
beaglebone = armv7l-hf-multiplatform // { beaglebone = lib.recursiveUpdate armv7l-hf-multiplatform {
name = "beaglebone"; linux-kernel = {
kernelBaseConfig = "bb.org_defconfig"; name = "beaglebone";
kernelAutoModules = false; baseConfig = "bb.org_defconfig";
kernelExtraConfig = ""; # TBD kernel config autoModules = false;
kernelTarget = "zImage"; extraConfig = ""; # TBD kernel config
target = "zImage";
};
}; };
# https://developer.android.com/ndk/guides/abis#v7a # https://developer.android.com/ndk/guides/abis#v7a
armv7a-android = { armv7a-android = {
name = "armeabi-v7a"; linux-kernel.name = "armeabi-v7a";
gcc = { gcc = {
arch = "armv7-a"; arch = "armv7-a";
float-abi = "softfp"; float-abi = "softfp";
@ -289,29 +294,31 @@ rec {
}; };
armv7l-hf-multiplatform = { armv7l-hf-multiplatform = {
name = "armv7l-hf-multiplatform"; linux-kernel = {
kernelBaseConfig = "multi_v7_defconfig"; name = "armv7l-hf-multiplatform";
kernelArch = "arm"; Major = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
kernelDTB = true; baseConfig = "multi_v7_defconfig";
kernelAutoModules = true; DTB = true;
kernelPreferBuiltin = true; autoModules = true;
kernelTarget = "zImage"; PreferBuiltin = true;
kernelExtraConfig = '' target = "zImage";
# Serial port for Raspberry Pi 3. Upstream forgot to add it to the ARMv7 defconfig. extraConfig = ''
SERIAL_8250_BCM2835AUX y # Serial port for Raspberry Pi 3. Upstream forgot to add it to the ARMv7 defconfig.
SERIAL_8250_EXTENDED y SERIAL_8250_BCM2835AUX y
SERIAL_8250_SHARE_IRQ y SERIAL_8250_EXTENDED y
SERIAL_8250_SHARE_IRQ y
# Fix broken sunxi-sid nvmem driver. # Fix broken sunxi-sid nvmem driver.
TI_CPTS y TI_CPTS y
# Hangs ODROID-XU4 # Hangs ODROID-XU4
ARM_BIG_LITTLE_CPUIDLE n ARM_BIG_LITTLE_CPUIDLE n
# Disable OABI to have seccomp_filter (required for systemd) # Disable OABI to have seccomp_filter (required for systemd)
# https://github.com/raspberrypi/firmware/issues/651 # https://github.com/raspberrypi/firmware/issues/651
OABI_COMPAT n OABI_COMPAT n
''; '';
};
gcc = { gcc = {
# Some table about fpu flags: # Some table about fpu flags:
# http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png # http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png
@ -336,34 +343,35 @@ rec {
}; };
aarch64-multiplatform = { aarch64-multiplatform = {
name = "aarch64-multiplatform"; linux-kernel = {
kernelBaseConfig = "defconfig"; name = "aarch64-multiplatform";
kernelArch = "arm64"; baseConfig = "defconfig";
kernelDTB = true; DTB = true;
kernelAutoModules = true; autoModules = true;
kernelPreferBuiltin = true; preferBuiltin = true;
kernelExtraConfig = '' extraConfig = ''
# Raspberry Pi 3 stuff. Not needed for kernels >= 4.10. # Raspberry Pi 3 stuff. Not needed for s >= 4.10.
ARCH_BCM2835 y ARCH_BCM2835 y
BCM2835_MBOX y BCM2835_MBOX y
BCM2835_WDT y BCM2835_WDT y
RASPBERRYPI_FIRMWARE y RASPBERRYPI_FIRMWARE y
RASPBERRYPI_POWER y RASPBERRYPI_POWER y
SERIAL_8250_BCM2835AUX y SERIAL_8250_BCM2835AUX y
SERIAL_8250_EXTENDED y SERIAL_8250_EXTENDED y
SERIAL_8250_SHARE_IRQ y SERIAL_8250_SHARE_IRQ y
# Cavium ThunderX stuff. # Cavium ThunderX stuff.
PCI_HOST_THUNDER_ECAM y PCI_HOST_THUNDER_ECAM y
# Nvidia Tegra stuff. # Nvidia Tegra stuff.
PCI_TEGRA y PCI_TEGRA y
# The default (=y) forces us to have the XHCI firmware available in initrd, # The default (=y) forces us to have the XHCI firmware available in initrd,
# which our initrd builder can't currently do easily. # which our initrd builder can't currently do easily.
USB_XHCI_TEGRA m USB_XHCI_TEGRA m
''; '';
kernelTarget = "Image"; target = "Image";
};
gcc = { gcc = {
arch = "armv8-a"; arch = "armv8-a";
}; };
@ -374,8 +382,9 @@ rec {
## ##
ben_nanonote = { ben_nanonote = {
name = "ben_nanonote"; linux-kernel = {
kernelArch = "mips"; name = "ben_nanonote";
};
gcc = { gcc = {
arch = "mips32"; arch = "mips32";
float = "soft"; float = "soft";
@ -383,75 +392,76 @@ rec {
}; };
fuloong2f_n32 = { fuloong2f_n32 = {
name = "fuloong2f_n32"; linux-kernel = {
kernelBaseConfig = "lemote2f_defconfig"; name = "fuloong2f_n32";
kernelArch = "mips"; baseConfig = "lemote2f_defconfig";
kernelAutoModules = false; autoModules = false;
kernelExtraConfig = '' extraConfig = ''
MIGRATION n MIGRATION n
COMPACTION n COMPACTION n
# nixos mounts some cgroup # nixos mounts some cgroup
CGROUPS y CGROUPS y
BLK_DEV_RAM y BLK_DEV_RAM y
BLK_DEV_INITRD y BLK_DEV_INITRD y
BLK_DEV_CRYPTOLOOP m BLK_DEV_CRYPTOLOOP m
BLK_DEV_DM m BLK_DEV_DM m
DM_CRYPT m DM_CRYPT m
MD y MD y
REISERFS_FS m REISERFS_FS m
EXT4_FS m EXT4_FS m
USB_STORAGE_CYPRESS_ATACB m USB_STORAGE_CYPRESS_ATACB m
IP_PNP y IP_PNP y
IP_PNP_DHCP y IP_PNP_DHCP y
IP_PNP_BOOTP y IP_PNP_BOOTP y
NFS_FS y NFS_FS y
ROOT_NFS y ROOT_NFS y
TUN m TUN m
NFS_V4 y NFS_V4 y
NFS_V4_1 y NFS_V4_1 y
NFS_FSCACHE y NFS_FSCACHE y
NFSD m NFSD m
NFSD_V2_ACL y NFSD_V2_ACL y
NFSD_V3 y NFSD_V3 y
NFSD_V3_ACL y NFSD_V3_ACL y
NFSD_V4 y NFSD_V4 y
# Fail to build # Fail to build
DRM n DRM n
SCSI_ADVANSYS n SCSI_ADVANSYS n
USB_ISP1362_HCD n USB_ISP1362_HCD n
SND_SOC n SND_SOC n
SND_ALI5451 n SND_ALI5451 n
FB_SAVAGE n FB_SAVAGE n
SCSI_NSP32 n SCSI_NSP32 n
ATA_SFF n ATA_SFF n
SUNGEM n SUNGEM n
IRDA n IRDA n
ATM_HE n ATM_HE n
SCSI_ACARD n SCSI_ACARD n
BLK_DEV_CMD640_ENHANCED n BLK_DEV_CMD640_ENHANCED n
FUSE_FS m FUSE_FS m
# Needed for udev >= 150 # Needed for udev >= 150
SYSFS_DEPRECATED_V2 n SYSFS_DEPRECATED_V2 n
VGA_CONSOLE n VGA_CONSOLE n
VT_HW_CONSOLE_BINDING y VT_HW_CONSOLE_BINDING y
SERIAL_8250_CONSOLE y SERIAL_8250_CONSOLE y
FRAMEBUFFER_CONSOLE y FRAMEBUFFER_CONSOLE y
EXT2_FS y EXT2_FS y
EXT3_FS y EXT3_FS y
REISERFS_FS y REISERFS_FS y
MAGIC_SYSRQ y MAGIC_SYSRQ y
# The kernel doesn't boot at all, with FTRACE # The kernel doesn't boot at all, with FTRACE
FTRACE n FTRACE n
''; '';
kernelTarget = "vmlinux"; target = "vmlinux";
};
gcc = { gcc = {
arch = "loongson2f"; arch = "loongson2f";
float = "hard"; float = "hard";
@ -464,34 +474,36 @@ rec {
## ##
riscv-multiplatform = { riscv-multiplatform = {
name = "riscv-multiplatform"; linux-kernel = {
kernelArch = "riscv"; name = "riscv-multiplatform";
kernelTarget = "vmlinux"; target = "vmlinux";
kernelAutoModules = true; autoModules = true;
kernelBaseConfig = "defconfig"; baseConfig = "defconfig";
kernelExtraConfig = '' extraConfig = ''
FTRACE n FTRACE n
SERIAL_OF_PLATFORM y SERIAL_OF_PLATFORM y
''; '';
};
}; };
select = platform: select = platform:
# x86 # x86
/**/ if platform.isx86_32 then pc32 /**/ if platform.isx86 then pc
else if platform.isx86_64 then pc64
# ARM # ARM
else if platform.isAarch32 then let else if platform.isAarch32 then let
version = platform.parsed.cpu.version or null; version = platform.parsed.cpu.version or null;
in if version == null then pcBase in if version == null then pc
else if lib.versionOlder version "6" then sheevaplug else if lib.versionOlder version "6" then sheevaplug
else if lib.versionOlder version "7" then raspberrypi else if lib.versionOlder version "7" then raspberrypi
else armv7l-hf-multiplatform else armv7l-hf-multiplatform
else if platform.isAarch64 then aarch64-multiplatform else if platform.isAarch64 then aarch64-multiplatform
else if platform.isRiscV then riscv-multiplatform
else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then fuloong2f_n32 else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then fuloong2f_n32
else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv
else pcBase; else pc;
} }

View file

@ -603,6 +603,22 @@ http://some.json-exporter.host:7979/probe?target=https://example.com/some/json/e
<literal>/etc/netgroup</literal> defines network-wide groups and may affect to setups using NIS. <literal>/etc/netgroup</literal> defines network-wide groups and may affect to setups using NIS.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
Platforms, like <varname>stdenv.hostPlatform</varname>, no longer have a <varname>platform</varname> attribute.
It has been (mostly) flattoned away:
</para>
<itemizedlist>
<listitem><para><varname>platform.gcc</varname> is now <varname>gcc</varname></para></listitem>
<listitem><para><literal>platform.kernel*</literal> is now <literal>linux-kernel.*</literal></para></listitem>
</itemizedlist>
<para>
Additionally, <varname>platform.kernelArch</varname> moved to the top level as <varname>linuxArch</varname> to match the other <literal>*Arch</literal> variables.
</para>
<para>
The <varname>platform</varname> grouping of these things never meant anything, and was just a historial/implementation artifact that was overdue removal.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
</section> </section>

View file

@ -68,11 +68,11 @@ let
patchShebangs scripts/* patchShebangs scripts/*
substituteInPlace scripts/Makefile.lib \ substituteInPlace scripts/Makefile.lib \
--replace 'DTC_FLAGS += $(DTC_FLAGS_$(basetarget))' 'DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) -@' --replace 'DTC_FLAGS += $(DTC_FLAGS_$(basetarget))' 'DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) -@'
make ${pkgs.stdenv.hostPlatform.platform.kernelBaseConfig} ARCH="${pkgs.stdenv.hostPlatform.platform.kernelArch}" make ${pkgs.stdenv.hostPlatform.linux-kernel.baseConfig} ARCH="${pkgs.stdenv.hostPlatform.linuxArch}"
make dtbs ARCH="${pkgs.stdenv.hostPlatform.platform.kernelArch}" make dtbs ARCH="${pkgs.stdenv.hostPlatform.linuxArch}"
''; '';
installPhase = '' installPhase = ''
make dtbs_install INSTALL_DTBS_PATH=$out/dtbs ARCH="${pkgs.stdenv.hostPlatform.platform.kernelArch}" make dtbs_install INSTALL_DTBS_PATH=$out/dtbs ARCH="${pkgs.stdenv.hostPlatform.linuxArch}"
''; '';
}; };
@ -115,7 +115,7 @@ in
options = { options = {
hardware.deviceTree = { hardware.deviceTree = {
enable = mkOption { enable = mkOption {
default = pkgs.stdenv.hostPlatform.platform.kernelDTB or false; default = pkgs.stdenv.hostPlatform.linux-kernel.DTB or false;
type = types.bool; type = types.bool;
description = '' description = ''
Build device tree files. These are used to describe the Build device tree files. These are used to describe the

View file

@ -88,7 +88,7 @@ with lib;
system.build.netbootIpxeScript = pkgs.writeTextDir "netboot.ipxe" '' system.build.netbootIpxeScript = pkgs.writeTextDir "netboot.ipxe" ''
#!ipxe #!ipxe
kernel ${pkgs.stdenv.hostPlatform.platform.kernelTarget} init=${config.system.build.toplevel}/init initrd=initrd ${toString config.boot.kernelParams} kernel ${pkgs.stdenv.hostPlatform.linux-kernel.target} init=${config.system.build.toplevel}/init initrd=initrd ${toString config.boot.kernelParams}
initrd initrd initrd initrd
boot boot
''; '';

View file

@ -587,10 +587,10 @@ in
nix.systemFeatures = mkDefault ( nix.systemFeatures = mkDefault (
[ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++ [ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++
optionals (pkgs.hostPlatform.platform ? gcc.arch) ( optionals (pkgs.hostPlatform ? gcc.arch) (
# a builder can run code for `platform.gcc.arch` and inferior architectures # a builder can run code for `gcc.arch` and inferior architectures
[ "gccarch-${pkgs.hostPlatform.platform.gcc.arch}" ] ++ [ "gccarch-${pkgs.hostPlatform.gcc.arch}" ] ++
map (x: "gccarch-${x}") lib.systems.architectures.inferiors.${pkgs.hostPlatform.platform.gcc.arch} map (x: "gccarch-${x}") lib.systems.architectures.inferiors.${pkgs.hostPlatform.gcc.arch}
) )
); );

View file

@ -190,7 +190,7 @@ in
system.boot.loader.kernelFile = mkOption { system.boot.loader.kernelFile = mkOption {
internal = true; internal = true;
default = pkgs.stdenv.hostPlatform.platform.kernelTarget; default = pkgs.stdenv.hostPlatform.linux-kernel.target;
type = types.str; type = types.str;
description = '' description = ''
Name of the kernel file to be passed to the bootloader. Name of the kernel file to be passed to the bootloader.

View file

@ -59,7 +59,7 @@ in
system.build.installBootLoader = generationsDirBuilder; system.build.installBootLoader = generationsDirBuilder;
system.boot.loader.id = "generationsDir"; system.boot.loader.id = "generationsDir";
system.boot.loader.kernelFile = platform.kernelTarget; system.boot.loader.kernelFile = linux-kernel.target;
}; };
} }

View file

@ -103,6 +103,6 @@ in
system.build.installBootLoader = builder; system.build.installBootLoader = builder;
system.boot.loader.id = "raspberrypi"; system.boot.loader.id = "raspberrypi";
system.boot.loader.kernelFile = platform.kernelTarget; system.boot.loader.kernelFile = linux-kernel.target;
}; };
} }

View file

@ -79,7 +79,7 @@ let
in in
tarball // tarball //
{ meta = { { meta = {
description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.platform.name}"; description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.linux-kernel.name}";
maintainers = map (x: lib.maintainers.${x}) maintainers; maintainers = map (x: lib.maintainers.${x}) maintainers;
}; };
inherit config; inherit config;
@ -105,7 +105,7 @@ let
modules = makeModules module {}; modules = makeModules module {};
}; };
build = configEvaled.config.system.build; build = configEvaled.config.system.build;
kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.platform.kernelTarget; kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target;
in in
pkgs.symlinkJoin { pkgs.symlinkJoin {
name = "netboot"; name = "netboot";

View file

@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
startScript = if stdenv.isx86_32 then "START_LINUX_X86" startScript = if stdenv.isx86_32 then "START_LINUX_X86"
else if stdenv.isx86_64 then "START_LINUX_X86_64" else if stdenv.isx86_64 then "START_LINUX_X86_64"
#else if stdenv.isDarwin then "START_MACOS.app" # disabled because I cannot test on Darwin #else if stdenv.isDarwin then "START_MACOS.app" # disabled because I cannot test on Darwin
else abort "Unsupported platform: ${stdenv.platform.kernelArch}."; else abort "Unsupported platform: ${stdenv.hostPlatform.linuxArch}.";
linuxExecutable = if stdenv.isx86_32 then "pixilang_linux_x86" linuxExecutable = if stdenv.isx86_32 then "pixilang_linux_x86"
else if stdenv.isx86_64 then "pixilang_linux_x86_64" else if stdenv.isx86_64 then "pixilang_linux_x86_64"

View file

@ -75,7 +75,7 @@ in
CROSVM_CARGO_TEST_KERNEL_BINARY = CROSVM_CARGO_TEST_KERNEL_BINARY =
lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform) lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform)
"${linux}/${stdenv.hostPlatform.platform.kernelTarget}"; "${linux}/${stdenv.hostPlatform.linux-kernel.target}";
passthru = { passthru = {
inherit adhdSrc; inherit adhdSrc;

View file

@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
buildPhase = ''( buildPhase = ''(
cd src cd src
./mk.sh ${stdenv.buildPlatform.platform.kernelArch} ./mk.sh ${stdenv.buildPlatform.linuxArch}
)''; )'';
installPhase = '' installPhase = ''

View file

@ -190,7 +190,7 @@ stdenv.mkDerivation {
else if targetPlatform.isRiscV then "lriscv" else if targetPlatform.isRiscV then "lriscv"
else throw "unknown emulation for platform: ${targetPlatform.config}"; else throw "unknown emulation for platform: ${targetPlatform.config}";
in if targetPlatform.useLLVM or false then "" in if targetPlatform.useLLVM or false then ""
else targetPlatform.platform.bfdEmulation or (fmt + sep + arch); else targetPlatform.bfdEmulation or (fmt + sep + arch);
strictDeps = true; strictDeps = true;
depsTargetTargetPropagated = extraPackages; depsTargetTargetPropagated = extraPackages;

View file

@ -402,32 +402,32 @@ stdenv.mkDerivation {
# Always add -march based on cpu in triple. Sometimes there is a # Always add -march based on cpu in triple. Sometimes there is a
# discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in # discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
# that case. # that case.
+ optionalString ((targetPlatform ? platform.gcc.arch) && + optionalString ((targetPlatform ? gcc.arch) &&
isGccArchSupported targetPlatform.platform.gcc.arch) '' isGccArchSupported targetPlatform.gcc.arch) ''
echo "-march=${targetPlatform.platform.gcc.arch}" >> $out/nix-support/cc-cflags-before echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
'' ''
# -mcpu is not very useful. You should use mtune and march # -mcpu is not very useful. You should use mtune and march
# instead. Its provided here for backwards compatibility. # instead. Its provided here for backwards compatibility.
+ optionalString (targetPlatform ? platform.gcc.cpu) '' + optionalString (targetPlatform ? gcc.cpu) ''
echo "-mcpu=${targetPlatform.platform.gcc.cpu}" >> $out/nix-support/cc-cflags-before echo "-mcpu=${targetPlatform.gcc.cpu}" >> $out/nix-support/cc-cflags-before
'' ''
# -mfloat-abi only matters on arm32 but we set it here # -mfloat-abi only matters on arm32 but we set it here
# unconditionally just in case. If the abi specifically sets hard # unconditionally just in case. If the abi specifically sets hard
# vs. soft floats we use it here. # vs. soft floats we use it here.
+ optionalString (targetPlatform ? platform.gcc.float-abi) '' + optionalString (targetPlatform ? gcc.float-abi) ''
echo "-mfloat-abi=${targetPlatform.platform.gcc.float-abi}" >> $out/nix-support/cc-cflags-before echo "-mfloat-abi=${targetPlatform.gcc.float-abi}" >> $out/nix-support/cc-cflags-before
'' ''
+ optionalString (targetPlatform ? platform.gcc.fpu) '' + optionalString (targetPlatform ? gcc.fpu) ''
echo "-mfpu=${targetPlatform.platform.gcc.fpu}" >> $out/nix-support/cc-cflags-before echo "-mfpu=${targetPlatform.gcc.fpu}" >> $out/nix-support/cc-cflags-before
'' ''
+ optionalString (targetPlatform ? platform.gcc.mode) '' + optionalString (targetPlatform ? gcc.mode) ''
echo "-mmode=${targetPlatform.platform.gcc.mode}" >> $out/nix-support/cc-cflags-before echo "-mmode=${targetPlatform.gcc.mode}" >> $out/nix-support/cc-cflags-before
'' ''
+ optionalString (targetPlatform ? platform.gcc.tune && + optionalString (targetPlatform ? gcc.tune &&
isGccArchSupported targetPlatform.platform.gcc.tune) '' isGccArchSupported targetPlatform.gcc.tune) ''
echo "-mtune=${targetPlatform.platform.gcc.tune}" >> $out/nix-support/cc-cflags-before echo "-mtune=${targetPlatform.gcc.tune}" >> $out/nix-support/cc-cflags-before
'' ''
# TODO: categorize these and figure out a better place for them # TODO: categorize these and figure out a better place for them

View file

@ -56,13 +56,13 @@ in
, prepend ? [] , prepend ? []
# Whether to wrap the initramfs in a u-boot image. # Whether to wrap the initramfs in a u-boot image.
, makeUInitrd ? stdenvNoCC.hostPlatform.platform.kernelTarget == "uImage" , makeUInitrd ? stdenvNoCC.hostPlatform.linux-kernel.target == "uImage"
# If generating a u-boot image, the architecture to use. The default # If generating a u-boot image, the architecture to use. The default
# guess may not align with u-boot's nomenclature correctly, so it can # guess may not align with u-boot's nomenclature correctly, so it can
# be overridden. # be overridden.
# See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L81-106 for a list. # See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L81-106 for a list.
, uInitrdArch ? stdenvNoCC.hostPlatform.kernelArch , uInitrdArch ? stdenvNoCC.hostPlatform.linuxArch
# The name of the compression, as recognised by u-boot. # The name of the compression, as recognised by u-boot.
# See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L195-204 for a list. # See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L195-204 for a list.

View file

@ -1,6 +1,6 @@
{ pkgs { pkgs
, kernel ? pkgs.linux , kernel ? pkgs.linux
, img ? pkgs.stdenv.hostPlatform.platform.kernelTarget , img ? pkgs.stdenv.hostPlatform.linux-kernel.target
, storeDir ? builtins.storeDir , storeDir ? builtins.storeDir
, rootModules ? , rootModules ?
[ "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_balloon" "virtio_rng" "ext4" "unix" "9p" "9pnet_virtio" "crc32c_generic" ] [ "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_balloon" "virtio_rng" "ext4" "unix" "9p" "9pnet_virtio" "crc32c_generic" ]

View file

@ -1,7 +1,7 @@
{ lib, targetPlatform }: { lib, targetPlatform }:
let let
p = targetPlatform.platform.gcc or {} p = targetPlatform.gcc or {}
// targetPlatform.parsed.abi; // targetPlatform.parsed.abi;
in lib.concatLists [ in lib.concatLists [
(lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64 (lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64

View file

@ -123,7 +123,7 @@ stdenv.mkDerivation rec {
let let
arch = stdenv.lib.head (stdenv.lib.splitString "-" stdenv.system); arch = stdenv.lib.head (stdenv.lib.splitString "-" stdenv.system);
march = { march = {
x86_64 = stdenv.hostPlatform.platform.gcc.arch or "x86-64"; x86_64 = stdenv.hostPlatform.gcc.arch or "x86-64";
i686 = "pentium4"; i686 = "pentium4";
aarch64 = "armv8-a"; aarch64 = "armv8-a";
}.${arch} }.${arch}

View file

@ -73,7 +73,7 @@ stdenv.mkDerivation rec {
let let
arch = head (splitString "-" stdenv.system); arch = head (splitString "-" stdenv.system);
march = { march = {
x86_64 = stdenv.hostPlatform.platform.gcc.arch or "x86-64"; x86_64 = stdenv.hostPlatform.gcc.arch or "x86-64";
i686 = "pentium4"; i686 = "pentium4";
aarch64 = "armv8-a"; aarch64 = "armv8-a";
}.${arch} }.${arch}

View file

@ -71,7 +71,7 @@ stdenv.mkDerivation rec {
let let
arch = head (splitString "-" stdenv.system); arch = head (splitString "-" stdenv.system);
march = { march = {
x86_64 = stdenv.hostPlatform.platform.gcc.arch or "x86-64"; x86_64 = stdenv.hostPlatform.gcc.arch or "x86-64";
i686 = "pentium4"; i686 = "pentium4";
aarch64 = "armv8-a"; aarch64 = "armv8-a";
}.${arch} }.${arch}

View file

@ -158,7 +158,7 @@ stdenv.mkDerivation ({
"--enable-kernel=3.2.0" # can't get below with glibc >= 2.26 "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
(lib.flip lib.withFeature "fp" (lib.flip lib.withFeature "fp"
(stdenv.hostPlatform.platform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft")) (stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft"))
"--with-__thread" "--with-__thread"
] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform && stdenv.hostPlatform.isAarch32) [ ] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform && stdenv.hostPlatform.isAarch32) [
"--host=arm-linux-gnueabi" "--host=arm-linux-gnueabi"

View file

@ -88,7 +88,7 @@ qtModule {
NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [ NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [
# with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
"-Wno-class-memaccess" "-Wno-class-memaccess"
] ++ lib.optionals (stdenv.hostPlatform.platform.gcc.arch or "" == "sandybridge") [ ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [
# it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
# TODO: investigate and fix properly # TODO: investigate and fix properly
"-march=westmere" "-march=westmere"

View file

@ -73,9 +73,9 @@ let
if isLinux if isLinux
then then
( (
x: x.platform == "manylinux1_${stdenv.platform.kernelArch}" x: x.platform == "manylinux1_${stdenv.hostPlatform.linuxArch}"
|| x.platform == "manylinux2010_${stdenv.platform.kernelArch}" || x.platform == "manylinux2010_${stdenv.hostPlatform.linuxArch}"
|| x.platform == "manylinux2014_${stdenv.platform.kernelArch}" || x.platform == "manylinux2014_${stdenv.hostPlatform.linuxArch}"
|| x.platform == "any" || x.platform == "any"
) )
else (x: hasInfix "macosx" x.platform || x.platform == "any"); else (x: hasInfix "macosx" x.platform || x.platform == "any");

View file

@ -95,7 +95,7 @@ let
else if stdenv.isDarwin then "darwin" else if stdenv.isDarwin then "darwin"
else throw "Unsupported platform" else throw "Unsupported platform"
); );
platform_machine = stdenv.platform.kernelArch; platform_machine = stdenv.hostPlatform.linuxArch;
platform_python_implementation = platform_python_implementation =
let let
impl = python.passthru.implementation; impl = python.passthru.implementation;

View file

@ -60,18 +60,17 @@ in
configureFlags = let configureFlags = let
isCross = stdenv.hostPlatform != stdenv.buildPlatform; isCross = stdenv.hostPlatform != stdenv.buildPlatform;
host = stdenv.hostPlatform.platform; inherit (stdenv.hostPlatform) gcc isArch32;
isAarch32 = stdenv.hostPlatform.isAarch32;
in sharedConfigureFlags ++ [ in sharedConfigureFlags ++ [
"--without-dtrace" "--without-dtrace"
] ++ (optionals isCross [ ] ++ (optionals isCross [
"--cross-compiling" "--cross-compiling"
"--without-intl" "--without-intl"
"--without-snapshot" "--without-snapshot"
]) ++ (optionals (isCross && isAarch32 && hasAttr "fpu" host.gcc) [ ]) ++ (optionals (isCross && isAarch32 && hasAttr "fpu" gcc) [
"--with-arm-fpu=${host.gcc.fpu}" "--with-arm-fpu=${gcc.fpu}"
]) ++ (optionals (isCross && isAarch32 && hasAttr "float-abi" host.gcc) [ ]) ++ (optionals (isCross && isAarch32 && hasAttr "float-abi" gcc) [
"--with-arm-float-abi=${host.gcc.float-abi}" "--with-arm-float-abi=${gcc.float-abi}"
]) ++ (optionals (isCross && isAarch32) [ ]) ++ (optionals (isCross && isAarch32) [
"--dest-cpu=arm" "--dest-cpu=arm"
]) ++ extraConfigFlags; ]) ++ extraConfigFlags;

View file

@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
makeFlags = [ makeFlags = [
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"ARCH=${stdenv.hostPlatform.platform.kernelArch}" "ARCH=${stdenv.hostPlatform.linuxArch}"
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}" "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
]; ];

View file

@ -7,7 +7,7 @@ let
pname = "linux-headers"; pname = "linux-headers";
inherit version; inherit version;
ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch; ARCH = stdenvNoCC.hostPlatform.linuxArch;
# It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc. # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
# We do this so we have a build->build, not build->host, C compiler. # We do this so we have a build->build, not build->host, C compiler.

View file

@ -42,7 +42,7 @@
# symbolic name and `patch' is the actual patch. The patch may # symbolic name and `patch' is the actual patch. The patch may
# optionally be compressed with gzip or bzip2. # optionally be compressed with gzip or bzip2.
kernelPatches ? [] kernelPatches ? []
, ignoreConfigErrors ? stdenv.hostPlatform.platform.name != "pc" || , ignoreConfigErrors ? stdenv.hostPlatform.linux-kernel.name != "pc" ||
stdenv.hostPlatform != stdenv.buildPlatform stdenv.hostPlatform != stdenv.buildPlatform
, extraMeta ? {} , extraMeta ? {}
@ -51,10 +51,10 @@
, isLibre ? false , isLibre ? false
, isHardened ? false , isHardened ? false
# easy overrides to stdenv.hostPlatform.platform members # easy overrides to stdenv.hostPlatform.linux-kernel members
, autoModules ? stdenv.hostPlatform.platform.kernelAutoModules , autoModules ? stdenv.hostPlatform.linux-kernel.autoModules
, preferBuiltin ? stdenv.hostPlatform.platform.kernelPreferBuiltin or false , preferBuiltin ? stdenv.hostPlatform.linux-kernel.preferBuiltin or false
, kernelArch ? stdenv.hostPlatform.platform.kernelArch , kernelArch ? stdenv.hostPlatform.linuxArch
, ... , ...
}: }:
@ -87,7 +87,7 @@ let
intermediateNixConfig = configfile.moduleStructuredConfig.intermediateNixConfig intermediateNixConfig = configfile.moduleStructuredConfig.intermediateNixConfig
# extra config in legacy string format # extra config in legacy string format
+ extraConfig + extraConfig
+ lib.optionalString (stdenv.hostPlatform.platform ? kernelExtraConfig) stdenv.hostPlatform.platform.kernelExtraConfig; + stdenv.hostPlatform.linux-kernel.extraConfig or "";
structuredConfigFromPatches = structuredConfigFromPatches =
map ({extraStructuredConfig ? {}, ...}: {settings=extraStructuredConfig;}) kernelPatches; map ({extraStructuredConfig ? {}, ...}: {settings=extraStructuredConfig;}) kernelPatches;
@ -113,11 +113,11 @@ let
nativeBuildInputs = [ perl gmp libmpc mpfr ] nativeBuildInputs = [ perl gmp libmpc mpfr ]
++ lib.optionals (lib.versionAtLeast version "4.16") [ bison flex ]; ++ lib.optionals (lib.versionAtLeast version "4.16") [ bison flex ];
platformName = stdenv.hostPlatform.platform.name; platformName = stdenv.hostPlatform.linux-kernel.name;
# e.g. "defconfig" # e.g. "defconfig"
kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.platform.kernelBaseConfig; kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.linux-kernel.baseConfig;
# e.g. "bzImage" # e.g. "bzImage"
kernelTarget = stdenv.hostPlatform.platform.kernelTarget; kernelTarget = stdenv.hostPlatform.linux-kernel.target;
prePatch = kernel.prePatch + '' prePatch = kernel.prePatch + ''
# Patch kconfig to print "###" after every question so that # Patch kconfig to print "###" after every question so that

View file

@ -64,10 +64,10 @@ let
commonMakeFlags = [ commonMakeFlags = [
"O=$(buildRoot)" "O=$(buildRoot)"
] ++ lib.optionals (stdenv.hostPlatform.platform ? kernelMakeFlags) ] ++ lib.optionals (stdenv.hostPlatform.linux-kernel ? makeFlags)
stdenv.hostPlatform.platform.kernelMakeFlags; stdenv.hostPlatform.linux-kernel.makeFlags;
drvAttrs = config_: platform: kernelPatches: configfile: drvAttrs = config_: kernelConf: kernelPatches: configfile:
let let
config = let attrName = attr: "CONFIG_" + attr; in { config = let attrName = attr: "CONFIG_" + attr; in {
isSet = attr: hasAttr (attrName attr) config; isSet = attr: hasAttr (attrName attr) config;
@ -171,7 +171,7 @@ let
buildFlags = [ buildFlags = [
"KBUILD_BUILD_VERSION=1-NixOS" "KBUILD_BUILD_VERSION=1-NixOS"
platform.kernelTarget kernelConf.target
"vmlinux" # for "perf" and things like that "vmlinux" # for "perf" and things like that
] ++ optional isModular "modules"; ] ++ optional isModular "modules";
@ -186,16 +186,16 @@ let
''; '';
# Some image types need special install targets (e.g. uImage is installed with make uinstall) # Some image types need special install targets (e.g. uImage is installed with make uinstall)
installTargets = [ ( installTargets = [
if platform ? kernelInstallTarget then platform.kernelInstallTarget (kernelConf.installTarget or (
else if platform.kernelTarget == "uImage" then "uinstall" /**/ if kernelConf.target == "uImage" then "uinstall"
else if platform.kernelTarget == "zImage" || platform.kernelTarget == "Image.gz" then "zinstall" else if kernelConf.target == "zImage" || kernelConf.target == "Image.gz" then "zinstall"
else "install" else "install"))
) ]; ];
postInstall = (optionalString installsFirmware '' postInstall = (optionalString installsFirmware ''
mkdir -p $out/lib/firmware mkdir -p $out/lib/firmware
'') + (if (platform ? kernelDTB && platform.kernelDTB) then '' '') + (if (kernelConf.DTB or false) then ''
make $makeFlags "''${makeFlagsArray[@]}" dtbs dtbs_install INSTALL_DTBS_PATH=$out/dtbs make $makeFlags "''${makeFlagsArray[@]}" dtbs dtbs_install INSTALL_DTBS_PATH=$out/dtbs
'' else "") + (if isModular then '' '' else "") + (if isModular then ''
mkdir -p $dev mkdir -p $dev
@ -300,7 +300,7 @@ in
assert (lib.versionAtLeast version "4.14" && lib.versionOlder version "5.8") -> libelf != null; assert (lib.versionAtLeast version "4.14" && lib.versionOlder version "5.8") -> libelf != null;
assert lib.versionAtLeast version "5.8" -> elfutils != null; assert lib.versionAtLeast version "5.8" -> elfutils != null;
stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.platform kernelPatches configfile) // { stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPatches configfile) // {
pname = "linux"; pname = "linux";
inherit version; inherit version;
@ -308,7 +308,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.platform kernelPatches
depsBuildBuild = [ buildPackages.stdenv.cc ]; depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr gawk zstd ] nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr gawk zstd ]
++ optional (stdenv.hostPlatform.platform.kernelTarget == "uImage") buildPackages.ubootTools ++ optional (stdenv.hostPlatform.linux-kernel.target == "uImage") buildPackages.ubootTools
++ optional (lib.versionAtLeast version "4.14" && lib.versionOlder version "5.8") libelf ++ optional (lib.versionAtLeast version "4.14" && lib.versionOlder version "5.8") libelf
# Removed util-linuxMinimal since it should not be a dependency. # Removed util-linuxMinimal since it should not be a dependency.
++ optionals (lib.versionAtLeast version "4.16") [ bison flex ] ++ optionals (lib.versionAtLeast version "4.16") [ bison flex ]
@ -322,10 +322,10 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.platform kernelPatches
makeFlags = commonMakeFlags ++ [ makeFlags = commonMakeFlags ++ [
"CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" "CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc" "HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
"ARCH=${stdenv.hostPlatform.platform.kernelArch}" "ARCH=${stdenv.hostPlatform.linuxArch}"
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}" "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
]; ];
karch = stdenv.hostPlatform.platform.kernelArch; karch = stdenv.hostPlatform.linuxArch;
}) })

View file

@ -25,11 +25,11 @@ stdenv.mkDerivation rec {
hardeningDisable = [ "format" "stackprotector" ]; hardeningDisable = [ "format" "stackprotector" ];
makeFlags = commonMakeFlags ++ [ makeFlags = commonMakeFlags ++ [
"KLIBCARCH=${stdenv.hostPlatform.platform.kernelArch}" "KLIBCARCH=${stdenv.hostPlatform.linuxArch}"
"KLIBCKERNELSRC=${linuxHeaders}" "KLIBCKERNELSRC=${linuxHeaders}"
] # TODO(@Ericson2314): We now can get the ABI from ] # TODO(@Ericson2314): We now can get the ABI from
# `stdenv.hostPlatform.parsed.abi`, is this still a good idea? # `stdenv.hostPlatform.parsed.abi`, is this still a good idea?
++ lib.optional (stdenv.hostPlatform.platform.kernelArch == "arm") "CONFIG_AEABI=y" ++ lib.optional (stdenv.hostPlatform.linuxArch == "arm") "CONFIG_AEABI=y"
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}"; ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
# Install static binaries as well. # Install static binaries as well.

View file

@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
buildInputs = [ nukeReferences ]; buildInputs = [ nukeReferences ];
makeFlags = [ makeFlags = [
"ARCH=${stdenv.hostPlatform.platform.kernelArch}" # Normally not needed, but the Makefile sets ARCH in a broken way. "ARCH=${stdenv.hostPlatform.linuxArch}" # Normally not needed, but the Makefile sets ARCH in a broken way.
"KSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" # Makefile uses $(uname -r); breaks us. "KSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" # Makefile uses $(uname -r); breaks us.
]; ];

View file

@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
''; '';
makeFlags = [ makeFlags = [
"ARCH=${stdenv.hostPlatform.platform.kernelArch}" "ARCH=${stdenv.hostPlatform.linuxArch}"
"KSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" "KSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
("CONFIG_PLATFORM_I386_PC=" + (if (stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isx86_64) then "y" else "n")) ("CONFIG_PLATFORM_I386_PC=" + (if (stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isx86_64) then "y" else "n"))
("CONFIG_PLATFORM_ARM_RPI=" + (if (stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64) then "y" else "n")) ("CONFIG_PLATFORM_ARM_RPI=" + (if (stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64) then "y" else "n"))

View file

@ -68,7 +68,7 @@ stdenv.mkDerivation {
cat << EOF | parseconfig cat << EOF | parseconfig
${nixConfig} ${nixConfig}
${extraConfig} ${extraConfig}
${stdenv.hostPlatform.platform.uclibc.extraConfig or ""} ${stdenv.hostPlatform.uclibc.extraConfig or ""}
EOF EOF
( set +o pipefail; yes "" | make oldconfig ) ( set +o pipefail; yes "" | make oldconfig )
''; '';

View file

@ -278,8 +278,8 @@ in rec {
enableParallelChecking = attrs.enableParallelChecking or true; enableParallelChecking = attrs.enableParallelChecking or true;
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) { } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {
NIX_HARDENING_ENABLE = enabledHardeningOptions; NIX_HARDENING_ENABLE = enabledHardeningOptions;
} // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? platform.gcc.arch) { } // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? gcc.arch) {
requiredSystemFeatures = attrs.requiredSystemFeatures or [] ++ [ "gccarch-${stdenv.hostPlatform.platform.gcc.arch}" ]; requiredSystemFeatures = attrs.requiredSystemFeatures or [] ++ [ "gccarch-${stdenv.hostPlatform.gcc.arch}" ];
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) { } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
inherit __darwinAllowLocalNetworking; inherit __darwinAllowLocalNetworking;
# TODO: remove lib.unique once nix has a list canonicalization primitive # TODO: remove lib.unique once nix has a list canonicalization primitive

View file

@ -19291,7 +19291,7 @@ in
buildPhase = '' buildPhase = ''
set -x set -x
make \ make \
ARCH=${stdenv.hostPlatform.kernelArch} \ ARCH=${stdenv.hostPlatform.linuxArch} \
HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc \ HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc \
${makeTarget} ${makeTarget}
''; '';