mirror of
https://github.com/ipetkov/crane.git
synced 2024-12-01 17:27:23 +03:00
52 lines
1.3 KiB
Nix
52 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 = { self, 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 ./.;
|
|
|
|
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;
|
|
});
|
|
}
|