Skip to content

Commit

Permalink
feat(ci): hopefully speed up ci slightly by using nix flake for the d…
Browse files Browse the repository at this point in the history
…ev shell (evaluations should be cached better)
  • Loading branch information
SG60 committed Mar 22, 2024
1 parent 01cdda3 commit 6280b64
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
# use nix --arg targetSystem '"aarch64-unknown-linux-gnu"'

# for native compilation:
use nix
# use nix

# flake version
use flake .#default
# use flake .#aarch64-unknown-linux-musl
5 changes: 2 additions & 3 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: test
run: nix-shell --command "cargo test"
run: nix develop -c cargo test
- name: build
env:
TARGET_CC: clang
run: nix-shell --arg targetSystem \"${{ matrix.target.rust }}\" --run \
"cargo build --target ${{ matrix.target.rust }} --release"
run: nix develop .#${{ matrix.target.rust }} -c cargo build --target ${{ matrix.target.rust }} --release

- name: Login to Docker registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3
Expand Down
58 changes: 58 additions & 0 deletions flake.lock

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

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
devShells = {
# default = with pkgs; mkShellNoCC { packages = [ protobuf ]; };
default = import ./shell.nix { inherit pkgs; };
default = import ./shell.nix { inherit nixpkgs pkgs system; targetSystem = system; };
aarch64-unknown-linux-musl = import ./shell.nix { inherit nixpkgs pkgs system; targetSystem = "aarch64-unknown-linux-musl"; };
};
});
}
5 changes: 3 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{ nixpkgs ? fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11"
, pkgs ? import nixpkgs { config = { }; overlays = [ ]; }
, targetSystem ? builtins.currentSystem
, system ? builtins.currentSystem # local system
}:
let
crossPkgs =
if targetSystem != builtins.currentSystem then
if targetSystem != system then
import nixpkgs
{
localSystem = builtins.currentSystem;
localSystem = system;
crossSystem = { config = targetSystem; };
}
else pkgs;
Expand Down

0 comments on commit 6280b64

Please sign in to comment.