2024-07-03 12:20:11 +00:00
|
|
|
# thanks to https://code.betamike.com/micropelago/domani for the flake, I still do not completely understand it :)
|
2024-06-25 09:56:30 +00:00
|
|
|
{
|
|
|
|
description = "little-hesinde project";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-07-03 12:20:11 +00:00
|
|
|
naersk.url = "github:nix-community/naersk/master";
|
2024-07-03 10:32:47 +00:00
|
|
|
fenix.url = "github:nix-community/fenix";
|
2024-06-25 09:56:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
2024-07-03 10:32:47 +00:00
|
|
|
{
|
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
2024-07-03 12:20:11 +00:00
|
|
|
naersk,
|
2024-07-03 10:32:47 +00:00
|
|
|
fenix,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-03 12:20:11 +00:00
|
|
|
let
|
|
|
|
mkToolchain =
|
|
|
|
fenixPkgs:
|
|
|
|
fenixPkgs.fromToolchainFile {
|
|
|
|
file = ./rust-toolchain.toml;
|
|
|
|
sha256 = "sha256-Ngiz76YP4HTY75GGdH2P+APE/DEIx2R/Dn+BwwOyzZU=";
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
2024-06-25 09:56:30 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2024-07-03 12:20:11 +00:00
|
|
|
toolchain = mkToolchain fenix.packages.${system};
|
|
|
|
|
2024-06-25 09:56:30 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
devShells.default =
|
|
|
|
with pkgs;
|
|
|
|
mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
geckodriver
|
2024-07-03 12:20:11 +00:00
|
|
|
toolchain
|
2024-07-03 10:32:47 +00:00
|
|
|
cargo-deny
|
|
|
|
rust-analyzer
|
2024-06-25 09:56:30 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
2024-07-03 12:20:11 +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};
|
|
|
|
toolchain = mkToolchain fenixPkgs;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
OPENSSL_STATIC = "1";
|
|
|
|
OPENSSL_LIB_DIR = "${pkgsCross.pkgsStatic.openssl.out}/lib";
|
|
|
|
OPENSSL_INCLUDE_DIR = "${pkgsCross.pkgsStatic.openssl.dev}/include";
|
|
|
|
|
|
|
|
# Required because ring crate is special. This also seems to have
|
|
|
|
# fixed some issues with the x86_64-windows cross-compile :shrug:
|
|
|
|
TARGET_CC = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
|
|
|
|
|
|
|
CARGO_BUILD_TARGET = rustTarget;
|
|
|
|
CARGO_BUILD_RUSTFLAGS = [
|
|
|
|
"-C"
|
|
|
|
"target-feature=+crt-static"
|
|
|
|
|
|
|
|
# https://github.com/rust-lang/cargo/issues/4133
|
|
|
|
"-C"
|
|
|
|
"linker=${TARGET_CC}"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
};
|
2024-06-25 09:56:30 +00:00
|
|
|
}
|