Skip to content

Commit

Permalink
Introduce Nix development flake
Browse files Browse the repository at this point in the history
Provide a mostly self-contained development environment automatically
sets up tooling like Cargo and Bazel via nix.

This makes it easy for nix users to contribute to our project and
enables future work on reproducible release binaries and containers.
  • Loading branch information
aaronmondal committed Oct 20, 2023
1 parent 659d571 commit cdc5878
Show file tree
Hide file tree
Showing 8 changed files with 1,500 additions and 64 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake --impure
57 changes: 57 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Nix

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions: read-all

jobs:
nix-bazel:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Mount Nix cache
uses: actions/cache@v3.3.2
with:
key: ${{ runner.os }}-nix
path: ~/nix
- name: Mount bazel cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: ${{ runner.os }}-bazel-nix
- name: Invoke bazel build in Nix shell
run: >
nix --store ~/nix develop --impure --command
bash -c "bazel test ..."
nix-cargo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Mount Nix cache
uses: actions/cache@v3.3.2
with:
key: ${{ runner.os }}-nix
path: ~/nix
- name: Invoke bazel build in Nix shell
run: >
nix --store ~/nix develop --impure --command
bash -c "cargo test --all"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ target/
terraform.tfstate*
.update_scheduler_ips.zip
__pycache__
.devenv/
.direnv/
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ Should you wish to work on an issue, please claim it first by commenting on
the GitHub issue that you want to work on it. This is to prevent duplicated
efforts from contributors on the same issue.

## Nix development flake

You can use the Nix development flake to automatically set up Bazel, Cargo and
various Cloud CLIs for you:

1. Install the [nix package manger](https://nixos.org/download.html) and enable
[flakes](https://nixos.wiki/wiki/Flakes).
2. Optionally, install [direnv](https://direnv.net/docs/installation.html) and
hook it into your shell.
3. We currently don't ship a C++ toolchain as part of the flake. Make sure to
install a recent version of Clang.

## Pull Request Checklist

- Branch from the main branch and, if needed, rebase to the current main
Expand Down
Loading

0 comments on commit cdc5878

Please sign in to comment.