mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
53 lines
1.3 KiB
Nix
53 lines
1.3 KiB
Nix
{
|
|
description = "Building static binaries with musl";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
crane = {
|
|
url = "github:ipetkov/crane";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
flake-utils.follows = "flake-utils";
|
|
};
|
|
};
|
|
};
|
|
|
|
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) ];
|
|
};
|
|
|
|
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
|
targets = [ "x86_64-unknown-linux-musl" ];
|
|
};
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
|
|
|
my-crate = craneLib.buildPackage {
|
|
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
|
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;
|
|
});
|
|
}
|