add support for armv6l

This commit is contained in:
Quentin 2023-05-09 17:22:17 +02:00
parent 8711c0c190
commit afb5ef1764
Signed by: quentin
GPG key ID: E9602264D639FF68

View file

@ -2,16 +2,19 @@
description = "Aerogramme"; description = "Aerogramme";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/master";
flake-utils.url = "github:numtide/flake-utils";
# this patched version of cargo2nix makes easier to use clippy for building
cargo2nix = { cargo2nix = {
type = "github"; type = "github";
owner = "Alexis211"; owner = "Alexis211";
repo = "cargo2nix"; repo = "cargo2nix";
ref = "custom_unstable"; ref = "custom_unstable";
}; };
nixpkgs.url = "github:NixOS/nixpkgs/master";
#cargo2nix.url = "github:cargo2nix/cargo2nix/release-0.11.0"; # use rust project builds
fenix.url = "github:nix-community/fenix/monthly"; fenix.url = "github:nix-community/fenix/monthly";
flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix }: outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix }:
@ -20,13 +23,32 @@
"aarch64-unknown-linux-musl" "aarch64-unknown-linux-musl"
"armv6l-unknown-linux-musleabihf" "armv6l-unknown-linux-musleabihf"
] (targetHost: let ] (targetHost: let
# with fenix, we get builds from the rust project.
# they are done with an old version of musl (prior to 1.2.x that is used in NixOS),
# however musl has a breaking change from 1.1.x to 1.2.x on 32 bit systems.
# so we pin the lib to 1.1.x to avoid recompiling rust ourselves.
muslOverlay = self: super: {
musl = super.musl.overrideAttrs(old: if targetHost == "armv6l-unknown-linux-musleabihf" then rec {
pname = "musl";
version = "1.1.24";
src = builtins.fetchurl {
url = "https://musl.libc.org/releases/${pname}-${version}.tar.gz";
sha256 = "sha256:18r2a00k82hz0mqdvgm7crzc7305l36109c0j9yjmkxj2alcjw0k";
};
} else {});
};
pkgs = import nixpkgs { pkgs = import nixpkgs {
system = "x86_64-linux"; # hardcoded as we will cross compile system = "x86_64-linux"; # hardcoded as we will cross compile
crossSystem = { crossSystem = {
config = targetHost; # here we cross compile config = targetHost; # here we cross compile
isStatic = true; isStatic = true;
}; };
overlays = [cargo2nix.overlays.default]; overlays = [
cargo2nix.overlays.default
muslOverlay
];
}; };
shell = pkgs.mkShell { shell = pkgs.mkShell {
@ -35,14 +57,16 @@
]; ];
}; };
rustTarget = if targetHost == "armv6l-unknown-linux-musleabihf" then "arm-unknown-linux-musleabihf" else targetHost;
rustPkgs = pkgs.rustBuilder.makePackageSet({ rustPkgs = pkgs.rustBuilder.makePackageSet({
packageFun = import ./Cargo.nix;
target = rustTarget;
rustToolchain = with fenix.packages.x86_64-linux; combine [ rustToolchain = with fenix.packages.x86_64-linux; combine [
minimal.cargo minimal.cargo
minimal.rustc minimal.rustc
targets.${targetHost}.latest.rust-std targets.${rustTarget}.latest.rust-std
]; ];
packageFun = import ./Cargo.nix;
}); });
in { in {