2024-05-08 16:12:49 +00:00
|
|
|
{
|
|
|
|
description = "alert-me project";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
naersk.url = "github:nix-community/naersk";
|
|
|
|
fenix.url = "github:nix-community/fenix";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
nixpkgs,
|
|
|
|
naersk,
|
|
|
|
fenix,
|
|
|
|
flake-utils,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
buildTargets = {
|
|
|
|
"x86_64-linux" = {
|
|
|
|
crossSystemConfig = "x86_64-unknown-linux-musl";
|
|
|
|
rustTarget = "x86_64-unknown-linux-musl";
|
|
|
|
};
|
|
|
|
|
|
|
|
"i686-linux" = {
|
|
|
|
crossSystemConfig = "i686-unknown-linux-musl";
|
|
|
|
rustTarget = "i686-unknown-linux-musl";
|
|
|
|
};
|
|
|
|
|
|
|
|
"aarch64-linux" = {
|
|
|
|
crossSystemConfig = "aarch64-unknown-linux-musl";
|
|
|
|
rustTarget = "aarch64-unknown-linux-musl";
|
|
|
|
};
|
|
|
|
|
|
|
|
"armv6l-linux" = {
|
|
|
|
crossSystemConfig = "armv6l-unknown-linux-musleabihf";
|
|
|
|
rustTarget = "arm-unknown-linux-musleabihf";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
eachSystem =
|
|
|
|
supportedSystems: callback:
|
|
|
|
builtins.foldl' (overall: system: overall // { ${system} = callback system; }) { } supportedSystems;
|
|
|
|
|
|
|
|
eachCrossSystem =
|
|
|
|
supportedSystems: callback:
|
|
|
|
eachSystem supportedSystems (
|
|
|
|
buildSystem:
|
|
|
|
builtins.foldl' (
|
|
|
|
inner: targetSystem: inner // { "cross-${targetSystem}" = callback buildSystem targetSystem; }
|
|
|
|
) { default = callback buildSystem buildSystem; } supportedSystems
|
|
|
|
);
|
|
|
|
|
|
|
|
mkPkgs =
|
|
|
|
buildSystem: targetSystem:
|
|
|
|
import nixpkgs (
|
|
|
|
{
|
|
|
|
system = buildSystem;
|
|
|
|
}
|
|
|
|
// (
|
|
|
|
if targetSystem == null then
|
|
|
|
{ }
|
|
|
|
else
|
|
|
|
{ crossSystem.config = buildTargets.${targetSystem}.crossSystemConfig; }
|
|
|
|
)
|
|
|
|
);
|
|
|
|
in
|
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2024-05-20 09:18:17 +00:00
|
|
|
# rust = fenix.packages.${system}.stable;
|
|
|
|
rust =
|
|
|
|
with fenix.packages.${system};
|
|
|
|
fromToolchainFile {
|
|
|
|
file = ./rust-toolchain.toml;
|
2024-09-24 06:05:22 +00:00
|
|
|
sha256 = "sha256-LqLkRalgBChXud42w4/im8z6vHjzv3uMOJKRlMqSFLQ=";
|
2024-05-20 09:18:17 +00:00
|
|
|
};
|
2024-05-08 16:12:49 +00:00
|
|
|
in
|
|
|
|
with pkgs;
|
|
|
|
{
|
|
|
|
devShells.default = mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
mosquitto
|
2024-05-20 10:00:39 +00:00
|
|
|
cargo-deny
|
2024-05-20 09:18:17 +00:00
|
|
|
rust
|
2024-05-08 16:12:49 +00:00
|
|
|
rust-analyzer
|
|
|
|
sea-orm-cli
|
2024-05-20 09:18:17 +00:00
|
|
|
probe-rs
|
2024-05-08 16:12:49 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// {
|
|
|
|
packages = eachCrossSystem (builtins.attrNames buildTargets) (
|
|
|
|
buildSystem: targetSystem:
|
|
|
|
let
|
|
|
|
pkgs = mkPkgs buildSystem null;
|
|
|
|
pkgsCross = mkPkgs buildSystem targetSystem;
|
|
|
|
rustTarget = buildTargets.${targetSystem}.rustTarget;
|
|
|
|
|
|
|
|
fenixPkgs = fenix.packages.${buildSystem};
|
|
|
|
|
|
|
|
mkToolchain = fenixPkgs: fenixPkgs.stable;
|
|
|
|
|
|
|
|
toolchain = fenixPkgs.combine [
|
|
|
|
(mkToolchain fenixPkgs).rustc
|
|
|
|
(mkToolchain fenixPkgs).cargo
|
|
|
|
(mkToolchain fenixPkgs.targets.${rustTarget}).rust-std
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPackageAttrs =
|
|
|
|
if builtins.hasAttr "makeBuildPackageAttrs" buildTargets.${targetSystem} then
|
|
|
|
buildTargets.${targetSystem}.makeBuildPackageAttrs pkgsCross
|
|
|
|
else
|
|
|
|
{ };
|
|
|
|
|
|
|
|
naersk-lib = pkgs.callPackage naersk {
|
|
|
|
cargo = toolchain;
|
|
|
|
rustc = toolchain;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
naersk-lib.buildPackage (
|
|
|
|
buildPackageAttrs
|
|
|
|
// rec {
|
|
|
|
src = ./.;
|
|
|
|
strictDeps = true;
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
TARGET_CC = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
|
|
|
|
|
|
|
CARGO_BUILD_TARGET = rustTarget;
|
|
|
|
CARGO_BUILD_RUSTFLAGS = [
|
|
|
|
"-C"
|
|
|
|
"target-feature=+crt-static"
|
|
|
|
|
|
|
|
"-C"
|
|
|
|
"linker=${TARGET_CC}"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|