Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Cargo plugins #10

Merged
merged 7 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# pick up cargo plugins
PATH_add ./.cargo/bin

# watch the output to add lorri once it’s built
PATH_add ./target/debug

if [ -e ./target/debug/lorri ]; then
echo "direnv: using local lorri (./target/debug/lorri)"
Expand Down
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# `cargo build` dir
/target
**/*.rs.bk
.bash_history
# we set this as CARGO_INSTALL_ROOT
/.cargo
# lorri cache dir
.lorri
# nix-build symlink
result
**/*.rs.bk
.bash_history
34 changes: 29 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ pkgs ? import ./nix/nixpkgs.nix { enableMozillaOverlay = true; } }:
pkgs.mkShell {
pkgs.mkShell rec {
name = "lorri";
buildInputs = [
# This rust comes from the Mozilla rust overlay so we can
Expand All @@ -14,11 +14,26 @@ pkgs.mkShell {
pkgs.darwin.apple_sdk.frameworks.CoreServices
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
];

# Keep project-specific shell commands local
HISTFILE = "${toString ./.}/.bash_history";
RUST_BACKTRACE = 1;
ROOT = toString ./.;

# Lorri-specific

# The root directory of this project
LORRI_ROOT = toString ./.;
# Needed by the lorri build.rs to determine its own version
# for the development repository (non-release), we set it to 1
BUILD_REV_COUNT = 1;

# Rust-specific

# Enable printing backtraces for rust binaries
RUST_BACKTRACE = 1;
# Set up a local directory to install binaries in
CARGO_INSTALL_ROOT = "${LORRI_ROOT}/.cargo";

# Executed when entering `nix-shell`
shellHook = ''
# we can only output to stderr in the shellHook,
# otherwise direnv `use nix` does not work.
Expand All @@ -31,11 +46,17 @@ pkgs.mkShell {
# nix-shell, you don't need this.
export SHELL="${pkgs.bashInteractive}/bin/bash";

alias newlorri="(cd $ROOT; cargo run -- shell)"
alias newlorri="(cd $LORRI_ROOT; cargo run -- shell)"
alias ci="ci_check"

# this is mirrored from .envrc to make available from nix-shell
# pick up cargo plugins
export PATH="$LORRI_ROOT/.cargo/bin:$PATH"
# watch the output to add lorri once it's built
export PATH="$LORRI_ROOT/target/debug:$PATH"

function ci_check() (
cd "$ROOT";
cd "$LORRI_ROOT";

set -x

Expand Down Expand Up @@ -79,4 +100,7 @@ pkgs.mkShell {
# Cargo wasn't able to find CF during a `cargo test` run on Darwin.
export NIX_LDFLAGS="-F${pkgs.darwin.apple_sdk.frameworks.CoreFoundation}/Library/Frameworks -framework CoreFoundation $NIX_LDFLAGS"
'');

preferLocalBuild = true;
buildUseSubstitutes = false;
}