crane/examples/cross-musl/flake.nix
Ivan Petkov 6f7504ad93
Drop dependency on nixpkgs (#692)
Callers should use `mkLib` with an instantiation of `pkgs` instead of
using `crane.lib.${system}` directly
2024-08-29 23:29:16 +00:00

45 lines
1.1 KiB
Nix

{
description = "Building static binaries with musl";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default.override {
targets = [ "x86_64-unknown-linux-musl" ];
});
my-crate = craneLib.buildPackage {
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
};
in
{
checks = {
inherit my-crate;
};
packages.default = my-crate;
});
}