-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
description = "A nix development shell and build environment for galileo"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs = { | ||
nixpkgs.follows = "nixpkgs"; | ||
flake-utils.follows = "flake-utils"; | ||
}; | ||
}; | ||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs = { nixpkgs.follows = "nixpkgs"; }; | ||
}; | ||
}; | ||
|
||
outputs = { nixpkgs, flake-utils, rust-overlay, crane, ... }: | ||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
# Set up for Rust builds, pinned to the Rust toolchain version in the Penumbra repository | ||
overlays = [ (import rust-overlay) ]; | ||
pkgs = import nixpkgs { inherit system overlays; }; | ||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; | ||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; | ||
src = craneLib.cleanCargoSource (craneLib.path ./.); | ||
# Important environment variables so that the build can find the necessary libraries | ||
PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig"; | ||
LIBCLANG_PATH="${pkgs.libclang.lib}/lib"; | ||
in with pkgs; with pkgs.lib; let | ||
galileo = (craneLib.buildPackage { | ||
inherit src system PKG_CONFIG_PATH LIBCLANG_PATH; | ||
pname = "galileo"; | ||
version = "0.1.0"; | ||
nativeBuildInputs = [ pkg-config ]; | ||
buildInputs = [ clang openssl ]; | ||
# A lockfile is not used in this repository. | ||
cargoVendorDir = null; | ||
}).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times | ||
in { | ||
inherit galileo; | ||
devShells.default = craneLib.devShell { | ||
inherit LIBCLANG_PATH; | ||
inputsFrom = [ galileo ]; | ||
packages = [ cargo-watch cargo-nextest ]; | ||
shellHook = '' | ||
export LIBCLANG_PATH=${LIBCLANG_PATH} | ||
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} # Required for rust-analyzer | ||
''; | ||
}; | ||
} | ||
); | ||
} |