55 lines
1.5 KiB
Nix
55 lines
1.5 KiB
Nix
{
|
|
inputs = {
|
|
naersk.url = "github:nix-community/naersk/master";
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
|
|
utils.lib.eachDefaultSystem (system:
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ (import rust-overlay) ];
|
|
};
|
|
|
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
|
|
naersk-lib = pkgs.callPackage naersk {
|
|
cargo = toolchain;
|
|
rustc = toolchain;
|
|
};
|
|
|
|
opensslEnv = {
|
|
OPENSSL_STATIC = "1";
|
|
OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
|
|
OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}/include";
|
|
};
|
|
|
|
in
|
|
{
|
|
defaultPackage = naersk-lib.buildPackage ({
|
|
src = ./.;
|
|
doCheck = false;
|
|
nativeBuildInputs = [ pkgs.pkgsStatic.stdenv.cc ];
|
|
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
|
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
|
} // opensslEnv);
|
|
|
|
devShell = pkgs.mkShell ({
|
|
nativeBuildInputs = [
|
|
pkgs.stdenv.cc
|
|
pkgs.openssl
|
|
toolchain
|
|
];
|
|
shellHook = ''
|
|
source $(pwd)/.env.dev
|
|
export CARGO_HOME=$(pwd)/.cargo
|
|
'';
|
|
} // opensslEnv);
|
|
});
|
|
}
|