Skip to content

Commit

Permalink
flake: 🥐 add nix development shell
Browse files Browse the repository at this point in the history
  • Loading branch information
cratelyn committed May 28, 2024
1 parent 60f546d commit 6b6eb40
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
106 changes: 106 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions flake.nix
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
'';
};
}
);
}

0 comments on commit 6b6eb40

Please sign in to comment.