Skip to content

Instantly share code, notes, and snippets.

@samueldr
Last active May 22, 2019 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueldr/150eda3dbd4ddcb06e7183b48b6a6c5c to your computer and use it in GitHub Desktop.
Save samueldr/150eda3dbd4ddcb06e7183b48b6a6c5c to your computer and use it in GitHub Desktop.
{ lib, python3Packages, stdenv, writeTextDir, substituteAll, targetPackages }:
python3Packages.buildPythonApplication rec {
# ...
crossFile = writeTextDir "cross-file.conf" ''
[host_machine]
system = '${targetPackages.stdenv.targetPlatform.parsed.kernel.name}'
cpu_family = '${
# http://mesonbuild.com/Reference-tables.html#cpu-families
if targetPackages.stdenv.targetPlatform.isAarch32 then "arm"
else if targetPackages.stdenv.targetPlatform.isx86_32 then "x86"
else targetPackages.stdenv.targetPlatform.parsed.cpu.name
}'
cpu = '${targetPackages.stdenv.targetPlatform.parsed.cpu.name}'
endian = ${if targetPackages.stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
'';
# ...
}
{ lib, python3Packages, stdenv, writeTextDir, substituteAll, targetPackages }:
let
# http://mesonbuild.com/Reference-tables.html#cpu-families
cpuFamily =
if targetPackages.stdenv.targetPlatform.isAarch32 then "arm"
else if targetPackages.stdenv.targetPlatform.isx86_32 then "x86"
else targetPackages.stdenv.targetPlatform.parsed.cpu.name
;
in
python3Packages.buildPythonApplication rec {
# ...
crossFile = writeTextDir "cross-file.conf" ''
[host_machine]
system = '${targetPackages.stdenv.targetPlatform.parsed.kernel.name}'
cpu_family = '${cpuFamily}'
cpu = '${targetPackages.stdenv.targetPlatform.parsed.cpu.name}'
endian = ${if targetPackages.stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
'';
# ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment