Skip to content

Commit

Permalink
Use cabal-install if nix is failing in CI (haskell#1859)
Browse files Browse the repository at this point in the history
* Use cabal-install if nix is failing in CI

* Add default.nix

* Split nix job

* Fix syntax error

* Reorder
  • Loading branch information
berberman authored May 24, 2021
1 parent 00bbcb1 commit 6606a06
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
53 changes: 42 additions & 11 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
branches:
- '**'
push:
branches:
- master

jobs:
pre_job:
Expand All @@ -17,11 +20,10 @@ jobs:
cancel_others: true
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", ".circleci/**", "install/**"]'

nix:
# Enter the development shell and run `cabal build`
develop:
needs: pre_job
runs-on: ${{ matrix.os }}
env:
HAS_TOKEN: ${{ secrets.HLS_CACHIX_AUTH_TOKEN != '' }}

strategy:
fail-fast: false
Expand All @@ -41,14 +43,43 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }}
uses: cachix/cachix-action@v8
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: cachix/cachix-action@v10
with:
name: haskell-language-server
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
# Disable pushing, we will do that in job `build`
skipPush: true
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: nix build
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }}
run: nix develop --profile dev && cachix push haskell-language-server dev
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }}
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
run: |
nix develop --command cabal update
nix develop --command cabal build
# Build and then push HLS binaries with developmet shell to cachix
# This job runs when PRs are merged to master, and should be excluded from branch protections
build:
runs-on: ${{ matrix.os }}
if: ${{ github.repository_owner == 'haskell' && github.ref == 'ref/heads/master' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v13
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
with:
name: haskell-language-server
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
- run: |
nix develop --profile dev && cachix push haskell-language-server dev
nix build
nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
11 changes: 11 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat
# See flake.nix for details
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix

0 comments on commit 6606a06

Please sign in to comment.