Skip to content

Commit 6606a06

Browse files
authored
Use cabal-install if nix is failing in CI (#1859)
* Use cabal-install if nix is failing in CI * Add default.nix * Split nix job * Fix syntax error * Reorder
1 parent 00bbcb1 commit 6606a06

File tree

2 files changed

+53
-11
lines changed

2 files changed

+53
-11
lines changed

.github/workflows/nix.yml

+42-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches:
66
- '**'
7+
push:
8+
branches:
9+
- master
710

811
jobs:
912
pre_job:
@@ -17,11 +20,10 @@ jobs:
1720
cancel_others: true
1821
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", ".circleci/**", "install/**"]'
1922

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

2628
strategy:
2729
fail-fast: false
@@ -41,14 +43,43 @@ jobs:
4143
extra_nix_config: |
4244
experimental-features = nix-command flakes
4345
nix_path: nixpkgs=channel:nixos-unstable
44-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }}
45-
uses: cachix/cachix-action@v8
46+
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
47+
uses: cachix/cachix-action@v10
4648
with:
4749
name: haskell-language-server
48-
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
50+
# Disable pushing, we will do that in job `build`
51+
skipPush: true
4952
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
50-
run: nix build
51-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }}
52-
run: nix develop --profile dev && cachix push haskell-language-server dev
53-
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }}
54-
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
53+
run: |
54+
nix develop --command cabal update
55+
nix develop --command cabal build
56+
57+
# Build and then push HLS binaries with developmet shell to cachix
58+
# This job runs when PRs are merged to master, and should be excluded from branch protections
59+
build:
60+
runs-on: ${{ matrix.os }}
61+
if: ${{ github.repository_owner == 'haskell' && github.ref == 'ref/heads/master' }}
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
os: [ubuntu-latest, macOS-latest]
66+
67+
steps:
68+
- uses: actions/checkout@v2
69+
with:
70+
submodules: true
71+
- uses: cachix/install-nix-action@v13
72+
with:
73+
install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
74+
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
75+
extra_nix_config: |
76+
experimental-features = nix-command flakes
77+
nix_path: nixpkgs=channel:nixos-unstable
78+
- uses: cachix/cachix-action@v10
79+
with:
80+
name: haskell-language-server
81+
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
82+
- run: |
83+
nix develop --profile dev && cachix push haskell-language-server dev
84+
nix build
85+
nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server

default.nix

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat
2+
# See flake.nix for details
3+
(import (
4+
let
5+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
6+
in fetchTarball {
7+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
8+
sha256 = lock.nodes.flake-compat.locked.narHash; }
9+
) {
10+
src = ./.;
11+
}).defaultNix

0 commit comments

Comments
 (0)