Skip to content

Commit f8efb57

Browse files
committed
Flakify
1 parent f04f481 commit f8efb57

9 files changed

Lines changed: 156 additions & 290 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ jobs:
2727
key: cabal-deps-${{ runner.os }}-${{ hashFiles('nix/sources.json') }}-${{ matrix.ghc-version }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('linear-base.cabal') }}-${{ github.sha }}
2828
restore-keys: cabal-deps-${{ runner.os }}-${{ hashFiles('nix/sources.json') }}-${{ matrix.ghc-version }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('linear-base.cabal') }}-
2929
- name: Build Nix dependencies
30-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "echo '=== Nix dependencies installed ==='"
30+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command echo '=== Nix dependencies installed ==='
3131
- name: Init Cabal's config file
32-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal --config-file=/home/runner/.cabal/config user-config -f init"
32+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal --config-file=/home/runner/.cabal/config user-config -f init
3333
- name: Update Cabal's database
34-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal update"
34+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal update
3535
- name: Build Cabal's dependencies
36-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build --dependencies-only"
36+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal build --dependencies-only
3737
- name: Build
38-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build"
38+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal build
3939
- name: Haddock
40-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal haddock"
40+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal haddock
4141
- name: cabal-docspec
42-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal-docspec"
42+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal-docspec
4343
- name: Build benchmarks
44-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal build linear-base:bench:bench"
44+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal build linear-base:bench:bench
4545
- name: Run benchmarks
46-
run: nix-shell --arg ghcVersion '"${{ matrix.ghc-version }}"' --arg installHls 'false' --pure --run "cabal bench 2>&1 | tee benchmark_ghc${{ matrix.ghc-version }}.txt"
46+
run: nix develop .#devShells.x86_64-linux.ci-"${{ matrix.ghc-version }}" --command cabal bench 2>&1 | tee benchmark_ghc${{ matrix.ghc-version }}.txt
4747
- name: Upload benchmark results
4848
uses: actions/upload-artifact@v4
4949
with:
@@ -67,9 +67,9 @@ jobs:
6767
key: stack-deps-ormolu-${{ runner.os }}-${{ hashFiles('nix/sources.json') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('stack.yaml.lock') }}-${{ github.sha }}
6868
restore-keys: stack-deps-ormolu-${{ runner.os }}-${{ hashFiles('nix/sources.json') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('stack.yaml.lock') }}-
6969
- name: Build Nix dependencies
70-
run: nix-shell --arg installHls 'false' --pure --run "echo '=== Nix dependencies installed ==='"
70+
run: nix develop .#devShells.x86_64-linux.ci-stack --command echo '=== Nix dependencies installed ==='
7171
- name: check formatting
72-
run: nix-shell --arg installHls 'false' --pure --run 'stack build ormolu && stack exec ormolu -- -m check $(find . -type f -name "*.hs-boot" -o -name "*.hs")'
72+
run: nix develop .#devShells.x86_64-linux.ci-stack --command ormolu -m check $(find . -type f -name "*.hs-boot" -o -name "*.hs")
7373

7474
stack-build:
7575
name: stack build
@@ -86,6 +86,6 @@ jobs:
8686
key: stack-deps-${{ runner.os }}-${{ hashFiles('nix/sources.json') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('stack.yaml.lock', 'linear-base.cabal') }}-${{ github.sha }}
8787
restore-keys: stack-deps-${{ runner.os }}-${{ hashFiles('nix/sources.json') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('stack.yaml.lock', 'linear-base.cabal') }}-
8888
- name: Build Nix dependencies
89-
run: nix-shell --arg installHls 'false' --pure --run "echo '=== Nix dependencies installed ==='"
89+
run: nix develop .#devShells.x86_64-linux.ci-stack --command echo '=== Nix dependencies installed ==='
9090
- name: Build
91-
run: nix-shell --arg installHls 'false' --pure --run "stack build --pedantic --test --bench --no-run-benchmarks"
91+
run: nix develop .#devShells.x86_64-linux.ci-stack --command stack build --pedantic --test --bench --no-run-benchmarks

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
description = "Linear-base";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
inputs.flake-utils.url = "github:numtide/flake-utils";
6+
7+
outputs = { self, nixpkgs, flake-utils }:
8+
flake-utils.lib.eachDefaultSystem (system:
9+
let
10+
pkgs = import nixpkgs { inherit system; inherit overlays; };
11+
12+
# need to match Stackage LTS version from stack.yaml snapshot
13+
ghc-version = "ghc9103";
14+
15+
# Versions used by CI's Cabal-based matrix
16+
ci-ghc-versions = ["96" "98" "910" "912"];
17+
18+
haskell =
19+
pkgs.haskell.packages."${ghc-version}";
20+
21+
cabal-docspec = import ./nix/cabal-docspec.nix { inherit pkgs; };
22+
23+
buildTools = ghc-ver:
24+
let hask = pkgs.haskell.packages."${ghc-ver}"; in
25+
[
26+
hask.ghc
27+
hask.cabal-install
28+
stack-wrapped
29+
cabal-docspec
30+
haskell.ormolu # Haskell formatter
31+
];
32+
33+
mkCIShellFor = ghc-ver: pkgs.mkShell {
34+
# Set UTF-8 local so that run-tests can parse GHC's unicode output.
35+
LANG="C.UTF-8";
36+
37+
buildInputs = buildTools "${ghc-ver}";
38+
};
39+
40+
ci-shells = builtins.listToAttrs (map (ver:
41+
{ name = "ci-${ver}"; value = mkCIShellFor "ghc${ver}"; }
42+
) ci-ghc-versions);
43+
44+
devTools = [
45+
haskell.ghcid # Continuous terminal Haskell compile checker
46+
haskell.haskell-language-server # LSP server for editor
47+
];
48+
49+
# See https://docs.haskellstack.org/en/stable/topics/nix_integration/
50+
stack-wrapped = pkgs.symlinkJoin {
51+
name = "stack"; # will be available as the usual `stack` in terminal
52+
paths = [ pkgs.stack ];
53+
buildInputs = [ pkgs.makeWrapper ];
54+
postBuild = ''
55+
wrapProgram $out/bin/stack \
56+
--add-flags "\
57+
--no-nix \
58+
--system-ghc \
59+
--no-install-ghc \
60+
"
61+
'';
62+
};
63+
64+
overlays = [
65+
];
66+
67+
in {
68+
69+
devShells = ci-shells // {
70+
default = pkgs.mkShell {
71+
# Set UTF-8 local so that run-tests can parse GHC's unicode output.
72+
LANG="C.UTF-8";
73+
74+
buildInputs = buildTools ghc-version ++ devTools;
75+
};
76+
77+
ci-stack = mkCIShellFor ghc-version;};
78+
}
79+
);
80+
}

format.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,4 @@ set -e
55

66
export LANG="C.UTF-8"
77

8-
stack build ormolu
9-
## We can't format cabal at the moment because `cabal format` inlines
10-
## common stanzas, which is very much something that we don't want. See
11-
## https://github.com/haskell/cabal/issues/5734
12-
#
13-
# cabal format
14-
stack exec ormolu -- -m inplace $(find . -type f -name "*.hs-boot" -o -name "*.hs")
8+
ormolu -m inplace $(find . -type f -name "*.hs-boot" -o -name "*.hs")

nix/shell-stack.nix

Lines changed: 0 additions & 9 deletions
This file was deleted.

nix/sources.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)