Hello everyone!
I am trying to add a binary dependency in a GitHub CI using a flake.
The cargo test
in some configs will depend on a binary located in BITCOIND_EXEC
environment variable.
The codebase is extent, I don’t want to “nixify” the whole CI now. I just want to avoid download the external binary.
This is my flake.nix
:
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# pinned to 0.25.0
nixpkgs-bitcoind.url = "github:nixos/nixpkgs?rev=9957cd48326fe8dbd52fdc50dd2502307f188b0d";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgs-bitcoind, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs-bitcoind = nixpkgs-bitcoind.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell
{
packages = [
pkgs.bashInteractive
pkgs-bitcoind.bitcoind
];
shellHook = ''
bitcoind --version
'';
BITCOIND_EXEC = "${pkgs.bitcoind}/bin/bitcoind";
};
});
Then how do I make sure that CI will have the packages
installed and the BITCOIND_EXEC
var defined?
Locally I am using nix-direnv
that already does that to my local environment upon entering the directory.
This is the relevant parts in my GH Action:
build-test:
name: Build and test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: stable
clippy: true
- version: 1.57.0 # MSRV
features:
- --no-default-features
- --all-features
<....>
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v5
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust.version }}
override: true
profile: minimal
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.1
- name: Build
run: cargo build ${{ matrix.features }}
- name: Test
run: cargo test ${{ matrix.features }}
The idea would be to have Nix instantiate the default shell before the run: cargo build ${{ matrix.features }}
How can I accomplish this?