2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-20 11:21:14 +00:00
pict-rs/flake.nix

103 lines
3 KiB
Nix
Raw Normal View History

2023-03-10 01:54:03 +00:00
{
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";
};
2023-03-10 01:54:03 +00:00
};
outputs = { self, nixpkgs, flake-utils, fenix, naersk }:
2023-03-10 01:54:03 +00:00
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
2023-03-10 01:54:03 +00:00
};
2023-11-10 23:36:46 +00:00
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";
2023-11-11 00:54:34 +00:00
TARGET_CC = "${cc}/bin/${cc.targetPrefix}cc";
TARGET_AR = "${cc}/bin/${cc.targetPrefix}ar";
});
2023-03-10 01:54:03 +00:00
in
{
2023-03-10 02:19:40 +00:00
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;
2023-03-10 02:19:40 +00:00
default = pict-rs;
};
apps = rec {
dev = flake-utils.lib.mkApp { drv = self.packages.${system}.pict-rs; };
default = dev;
2023-03-10 01:54:03 +00:00
};
2023-03-10 02:19:40 +00:00
2023-03-10 03:29:56 +00:00
devShell = with pkgs; mkShell {
2023-11-11 00:07:01 +00:00
"CARGO_TARGET_${hostCargoTarget}_LINKER" = "${clang}/bin/clang";
"RUSTFLAGS" = "--cfg tokio_unstable --cfg uuid_unstable -C link-arg=-fuse-ld=${mold-wrapped}/bin/mold";
2023-11-10 23:36:46 +00:00
2023-03-11 19:02:20 +00:00
nativeBuildInputs = [
2023-09-02 16:52:55 +00:00
diesel-cli
2023-06-11 16:54:25 +00:00
exiftool
(pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
2023-06-19 20:46:23 +00:00
ffmpeg_6-full
garage
2023-03-11 19:02:20 +00:00
imagemagick
rust-analyzer-nightly
2023-04-07 16:20:26 +00:00
taplo
2023-10-21 00:08:23 +00:00
tokio-console
2023-03-11 19:02:20 +00:00
];
2023-03-10 03:29:56 +00:00
};
2023-03-10 01:54:03 +00:00
});
}