mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +00:00
102 lines
3 KiB
Nix
102 lines
3 KiB
Nix
{
|
|
description = "pict-rs";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
fenix = {
|
|
url = "github:nix-community/fenix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
naersk = {
|
|
url = "github:nix-community/naersk";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils, fenix, naersk }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ fenix.overlays.default ];
|
|
};
|
|
|
|
systemMappings = {
|
|
"x86_64-linux" = ["x86_64" "unknown" "linux" "gnu"];
|
|
"aarch64-linux" = ["aarch64" "unknown" "linux" "gnu"];
|
|
};
|
|
|
|
hostCargoTarget = nixpkgs.lib.strings.concatMapStringsSep "_" (nixpkgs.lib.strings.toUpper) systemMappings.${system};
|
|
|
|
makeRustCrossPackage = (crossSystem:
|
|
let
|
|
pkgsCross = import nixpkgs {
|
|
inherit system;
|
|
crossSystem.system = crossSystem;
|
|
};
|
|
|
|
target = nixpkgs.lib.strings.concatStringsSep "-" systemMappings.${crossSystem};
|
|
|
|
cargoTarget = nixpkgs.lib.strings.concatMapStringsSep "_" (nixpkgs.lib.strings.toUpper) systemMappings.${crossSystem};
|
|
|
|
toolchain = with fenix.packages.${system}; combine [
|
|
minimal.cargo
|
|
minimal.rustc
|
|
targets.${target}.latest.rust-std
|
|
];
|
|
|
|
inherit (pkgsCross.stdenv) cc;
|
|
in
|
|
(naersk.lib.${system}.override {
|
|
cargo = toolchain;
|
|
rustc = toolchain;
|
|
}).buildPackage {
|
|
src = ./.;
|
|
|
|
CARGO_BUILD_TARGET = target;
|
|
"CARGO_TARGET_${cargoTarget}_LINKER" = "${cc}/bin/${cc.targetPrefix}cc";
|
|
TARGET_CC = "${cc}/bin/${cc.targetPrefix}cc";
|
|
TARGET_AR = "${cc}/bin/${cc.targetPrefix}ar";
|
|
});
|
|
in
|
|
{
|
|
packages = rec {
|
|
pict-rs-x86_64-linux-gnu = makeRustCrossPackage "x86_64-linux";
|
|
|
|
pict-rs-aarch64-linux-gnu = makeRustCrossPackage "aarch64-linux";
|
|
|
|
pict-rs = pict-rs-x86_64-linux-gnu;
|
|
|
|
default = pict-rs;
|
|
};
|
|
|
|
apps = rec {
|
|
dev = flake-utils.lib.mkApp { drv = self.packages.${system}.pict-rs; };
|
|
default = dev;
|
|
};
|
|
|
|
devShell = with pkgs; mkShell {
|
|
"CARGO_TARGET_${hostCargoTarget}_LINKER" = "${clang}/bin/clang";
|
|
"RUSTFLAGS" = "--cfg tokio_unstable --cfg uuid_unstable -C link-arg=-fuse-ld=${mold-wrapped}/bin/mold";
|
|
|
|
nativeBuildInputs = [
|
|
diesel-cli
|
|
exiftool
|
|
(pkgs.fenix.complete.withComponents [
|
|
"cargo"
|
|
"clippy"
|
|
"rust-src"
|
|
"rustc"
|
|
"rustfmt"
|
|
])
|
|
ffmpeg_6-full
|
|
garage
|
|
imagemagick
|
|
rust-analyzer-nightly
|
|
taplo
|
|
tokio-console
|
|
];
|
|
};
|
|
});
|
|
}
|