mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 05:36:09 +03:00
6f7504ad93
Callers should use `mkLib` with an instantiation of `pkgs` instead of using `crane.lib.${system}` directly
45 lines
1.1 KiB
Nix
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;
|
|
});
|
|
}
|