Skip to content

Commit f7cc4c8

Browse files
authored
Merge pull request #296 from pepeiborra/nix-ci
Add a Nix CI job + a Hoogle option
2 parents c966e6f + 3451ca0 commit f7cc4c8

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

Diff for: .circleci/config.yml

+27
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,32 @@ jobs:
156156
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
157157
paths:
158158
- ~/.cabal
159+
nix:
160+
working_directory: ~/build
161+
environment:
162+
- NIXPKGS_ALLOW_BROKEN: 1
163+
docker:
164+
- image: nixorg/nix:circleci
165+
steps:
166+
- checkout
167+
- run:
168+
name: Sync submodules
169+
command: git submodule sync --recursive
170+
- run:
171+
name: Update submodules
172+
command: git submodule update --recursive --init
173+
- restore-cache:
174+
keys:
175+
- cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
176+
- run:
177+
name: Build
178+
command: nix-shell -j4 --run "cabal new-update && cabal new-build -j1 --enable-tests"
179+
no_output_timeout: 30m
180+
- save_cache:
181+
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
182+
paths:
183+
- ~/.cabal
184+
159185

160186

161187
workflows:
@@ -170,3 +196,4 @@ workflows:
170196
- ghc-8.10.1
171197
# - ghc-nightly
172198
- cabal
199+
- nix

Diff for: nix/sources.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
"homepage": "https://github.com/NixOS/nixpkgs",
1818
"owner": "NixOS",
1919
"repo": "nixpkgs-channels",
20-
"rev": "b8c367a7bd05e3a514c2b057c09223c74804a21b",
21-
"sha256": "0y17zxhwdw0afml2bwkmhvkymd9fv242hksl3l3xz82gmlg1zks4",
20+
"rev": "2c4e0f37a6d5d33666b550a1b85daf46b37f1b25",
21+
"sha256": "0hqr6ci0rgg1fyfg7w2182vgbi0cq472p2j8r7mcmkbpdwwi6i69",
2222
"type": "tarball",
23-
"url": "https://github.com/NixOS/nixpkgs-channels/archive/b8c367a7bd05e3a514c2b057c09223c74804a21b.tar.gz",
23+
"url": "https://github.com/NixOS/nixpkgs-channels/archive/2c4e0f37a6d5d33666b550a1b85daf46b37f1b25.tar.gz",
2424
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
2525
}
2626
}

Diff for: shell.nix

+23-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,35 @@
33
# while reducing Nix maintenance costs.
44
# It does **not** aim to replace Cabal/Stack with Nix
55

6+
# Maintaining this file:
7+
#
8+
# - Dealing with broken nix-shell
9+
#
10+
# 1. Bump the nixpkgs version using `niv update nixpkgs`
11+
# 2. Comment out any remaining failing packages
12+
#
13+
# - Dealing with broken cabal build inside nix-shell:
14+
#
15+
# If my understanding of cabal new-build is correct this should never happen,
16+
# assuming that cabal new-build does succeed outside nix-shell
617

718
{ sources ? import nix/sources.nix,
819
nixpkgs ? import sources.nixpkgs {},
9-
compiler ? "default"
20+
compiler ? "default",
21+
hoogle ? false
1022
}:
1123
with nixpkgs;
1224

1325
let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.version;
1426
haskellPackagesForProject = p:
1527
if compiler == "default" || compiler == defaultCompiler
16-
then haskellPackages.ghcWithPackages p
17-
# for all other compilers there is no Nix cache so dont bother building deps with NIx
18-
else haskell.packages.${compiler}.ghcWithPackages (_: []);
28+
then if hoogle
29+
then haskellPackages.ghcWithHoogle p
30+
else haskellPackages.ghcWithPackages p
31+
# for all other compilers there is no Nix cache so dont bother building deps
32+
else if hoogle
33+
then haskell.packages.${compiler}.ghcWithHoogle (_: [])
34+
else haskell.packages.${compiler}.ghcWithPackages (_: []);
1935

2036
retrie = with haskell.lib; dontCheck(disableLibraryProfiling(haskellPackages.retrie));
2137
compilerWithPackages = haskellPackagesForProject(p:
@@ -42,7 +58,7 @@ let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.
4258
data-default-instances-old-locale
4359
extra
4460
floskell
45-
fourmolu
61+
# fourmolu
4662
fuzzy
4763
generic-deriving
4864
ghc-check
@@ -94,9 +110,10 @@ in
94110
stdenv.mkDerivation {
95111
name = "haskell-language-server";
96112
buildInputs = [
113+
git
97114
gmp
98-
zlib
99115
ncurses
116+
zlib
100117

101118
haskellPackages.cabal-install
102119
haskellPackages.hlint

Diff for: src/Ide/Plugin/Example.hs

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import Ide.Plugin
3737
import Ide.Types
3838
import Language.Haskell.LSP.Types
3939
import Text.Regex.TDFA.Text()
40+
import Development.IDE.GHC.Compat (ParsedModule(ParsedModule))
4041

4142
-- ---------------------------------------------------------------------
4243

@@ -106,7 +107,9 @@ mkDiag file diagSource sev loc msg = (file, D.ShowDiag,)
106107

107108
-- | Generate code actions.
108109
codeAction :: CodeActionProvider
109-
codeAction _lf _state _pid (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List _xs} = do
110+
codeAction _lf state _pid (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List _xs} = do
111+
let Just nfp = uriToNormalizedFilePath $ toNormalizedUri uri
112+
Just (ParsedModule{},_) <- runIdeAction "example" (shakeExtras state) $ useWithStaleFast GetParsedModule nfp
110113
let
111114
title = "Add TODO Item 1"
112115
tedit = [TextEdit (Range (Position 2 0) (Position 2 0))

0 commit comments

Comments
 (0)