domani/flake.nix

55 lines
1.5 KiB
Nix
Raw Normal View History

2023-05-03 07:58:06 +00:00
{
inputs = {
naersk.url = "github:nix-community/naersk/master";
2023-05-04 12:56:31 +00:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
2023-05-03 07:58:06 +00:00
utils.url = "github:numtide/flake-utils";
2023-05-08 16:25:51 +00:00
rust-overlay.url = "github:oxalica/rust-overlay";
2023-05-03 07:58:06 +00:00
};
2023-05-08 16:25:51 +00:00
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
2023-05-03 07:58:06 +00:00
utils.lib.eachDefaultSystem (system:
let
2023-05-08 16:25:51 +00:00
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";
};
2023-05-03 07:58:06 +00:00
in
{
defaultPackage = naersk-lib.buildPackage ({
2023-05-15 20:58:40 +00:00
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);
2023-05-16 14:20:01 +00:00
devShell = pkgs.mkShell ({
2023-05-08 16:25:51 +00:00
nativeBuildInputs = [
pkgs.stdenv.cc
pkgs.openssl
2023-05-08 16:25:51 +00:00
toolchain
];
2023-05-04 12:56:31 +00:00
shellHook = ''
2023-05-15 16:03:16 +00:00
source $(pwd)/.env.dev
2023-05-04 12:56:31 +00:00
export CARGO_HOME=$(pwd)/.cargo
'';
} // opensslEnv);
2023-05-03 07:58:06 +00:00
});
}