Able to build zephyr toolchains
This commit is contained in:
parent
bfd6338ec6
commit
cdd6ddad6f
19
flake.nix
19
flake.nix
|
@ -6,16 +6,13 @@
|
|||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
zephyr = pkgs.callPackage ./packages/zephyr { };
|
||||
};
|
||||
outputs = { self, nixpkgs, utils }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = import nixpkgs { inherit system; };
|
||||
in {
|
||||
packages = { zephyr = pkgs.callPackage ./packages/zephyr { }; };
|
||||
|
||||
formatter = pkgs.nixfmt;
|
||||
});
|
||||
}
|
||||
formatter = pkgs.nixfmt;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
{ callPackage, stdenv, lib }:
|
||||
let assets = lib.importJSON ./assets.json;
|
||||
in {
|
||||
in rec {
|
||||
host-tools = callPackage ./host-tools.nix {
|
||||
inherit (assets) version hosts;
|
||||
sources = assets.host_tools;
|
||||
};
|
||||
|
||||
toolchains = lib.mapAttrs (target: sources:
|
||||
callPackage ./toolchain.nix {
|
||||
inherit target sources;
|
||||
inherit (assets) version hosts;
|
||||
}) assets.toolchains;
|
||||
}
|
||||
|
|
42
packages/zephyr/toolchain.nix
Normal file
42
packages/zephyr/toolchain.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ stdenv, lib, fetchurl, autoPatchelfHook, target, sources, version, hosts }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "zephyr-toolchain-${target}";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl (sources."${stdenv.hostPlatform.system}");
|
||||
|
||||
dontConfigure = true;
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
# If we're building the same architecture as the target it will mess with files like
|
||||
# crt1.o, so use autopatchelf and only some files
|
||||
dontPatchELF = true;
|
||||
dontAutoPatchelf = true;
|
||||
nativeBuildInputs = [ autoPatchelfHook ];
|
||||
autoPatchelfIgnoreMissingDeps = [ "libpython*" ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p "$out"
|
||||
tar -C "$out" -xvf "$src"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
autoPatchelf ${target}/bin
|
||||
autoPatchelf ${target}/${target}/bin
|
||||
autoPatchelf ${target}/lib/bfd-plugins
|
||||
autoPatchelf ${target}/lib/gcc/${target}/*/plugin ${target}/libexec/gcc/${target}
|
||||
echo "done with my autopatchelf"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://www.zephyrproject.org/";
|
||||
description =
|
||||
"Toolchain for building Zephyr for the ${target} architecture";
|
||||
license = licenses.asl20;
|
||||
platforms = hosts;
|
||||
maintainers = with maintainers; [ artemist ];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue