diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index b054f4f..7d16cb5 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,18 +24,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: ${{ matrix.target }} - override: true + - name: Install Nix + uses: cachix/install-nix-action@v31 - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --verbose --release --target ${{ matrix.target }} + run: nix-shell --command "cargo build --verbose --release --target ${{ matrix.target }}" - name: Strip binaries (Linux) if: matrix.target == 'x86_64-unknown-linux-gnu' diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dde9647..ec52980 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,12 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Rust - run: rustup update stable - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov + - name: Install Nix + uses: cachix/install-nix-action@v31 - name: Generate code coverage - run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + run: nix-shell --command "cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info" - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/hooky.yml b/.github/workflows/hooky.yml index 4f95a96..881c717 100644 --- a/.github/workflows/hooky.yml +++ b/.github/workflows/hooky.yml @@ -13,21 +13,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - uses: moonrepo/setup-rust@v1 - - name: Download Hooky binary - id: download - run: | - TAG="v1.0.0" - ASSET="hooky-${TAG#v}-linux-x86_64" - URL="https://github.com/brandonchinn178/hooky/releases/download/${TAG}/${ASSET}" - echo "Downloading $URL" - sudo curl -L -o /usr/bin/hooky "${URL}" - sudo chmod +x /usr/bin/hooky - - name: Verify dependency versions - run: | - hooky --version - rustfmt --version + - name: Install Nix + uses: cachix/install-nix-action@v31 - name: Execute hooks - run: hooky run --all --format=verbose + run: nix-shell --command "hooky run --all --format=verbose" env: SKIP: no_commit_to_branch diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..b1eaa86 --- /dev/null +++ b/shell.nix @@ -0,0 +1,23 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/83e29f2b8791f6dec20804382fcd9a666d744c07.tar.gz"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShell { + packages = with pkgs; [ + hooky + cargo + cargo-llvm-cov + rustc + rustc.llvmPackages.llvm + rustfmt + clippy + rust-analyzer + sqlite + ]; + + shellHook = '' + export LLVM_COV=${pkgs.llvm}/bin/llvm-cov + export LLVM_PROFDATA=${pkgs.llvm}/bin/llvm-profdata + ''; +}