Skip to content

Add a Nix CI job + a Hoogle option #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,32 @@ jobs:
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
paths:
- ~/.cabal
nix:
working_directory: ~/build
environment:
- NIXPKGS_ALLOW_BROKEN: 1
docker:
- image: nixorg/nix:circleci
steps:
- checkout
- run:
name: Sync submodules
command: git submodule sync --recursive
- run:
name: Update submodules
command: git submodule update --recursive --init
- restore-cache:
keys:
- cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
- run:
name: Build
command: nix-shell -j4 --run "cabal new-update && cabal new-build -j1 --enable-tests"
no_output_timeout: 30m
- save_cache:
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
paths:
- ~/.cabal



workflows:
Expand All @@ -170,3 +196,4 @@ workflows:
- ghc-8.10.1
# - ghc-nightly
- cabal
- nix
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "b8c367a7bd05e3a514c2b057c09223c74804a21b",
"sha256": "0y17zxhwdw0afml2bwkmhvkymd9fv242hksl3l3xz82gmlg1zks4",
"rev": "2c4e0f37a6d5d33666b550a1b85daf46b37f1b25",
"sha256": "0hqr6ci0rgg1fyfg7w2182vgbi0cq472p2j8r7mcmkbpdwwi6i69",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/b8c367a7bd05e3a514c2b057c09223c74804a21b.tar.gz",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/2c4e0f37a6d5d33666b550a1b85daf46b37f1b25.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
29 changes: 23 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@
# while reducing Nix maintenance costs.
# It does **not** aim to replace Cabal/Stack with Nix

# Maintaining this file:
#
# - Dealing with broken nix-shell
#
# 1. Bump the nixpkgs version using `niv update nixpkgs`
# 2. Comment out any remaining failing packages
#
# - Dealing with broken cabal build inside nix-shell:
#
# If my understanding of cabal new-build is correct this should never happen,
# assuming that cabal new-build does succeed outside nix-shell

{ sources ? import nix/sources.nix,
nixpkgs ? import sources.nixpkgs {},
compiler ? "default"
compiler ? "default",
hoogle ? false
}:
with nixpkgs;

let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.version;
haskellPackagesForProject = p:
if compiler == "default" || compiler == defaultCompiler
then haskellPackages.ghcWithPackages p
# for all other compilers there is no Nix cache so dont bother building deps with NIx
else haskell.packages.${compiler}.ghcWithPackages (_: []);
then if hoogle
then haskellPackages.ghcWithHoogle p
else haskellPackages.ghcWithPackages p
# for all other compilers there is no Nix cache so dont bother building deps
else if hoogle
then haskell.packages.${compiler}.ghcWithHoogle (_: [])
else haskell.packages.${compiler}.ghcWithPackages (_: []);

retrie = with haskell.lib; dontCheck(disableLibraryProfiling(haskellPackages.retrie));
compilerWithPackages = haskellPackagesForProject(p:
Expand All @@ -42,7 +58,7 @@ let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.
data-default-instances-old-locale
extra
floskell
fourmolu
# fourmolu
fuzzy
generic-deriving
ghc-check
Expand Down Expand Up @@ -94,9 +110,10 @@ in
stdenv.mkDerivation {
name = "haskell-language-server";
buildInputs = [
git
gmp
zlib
ncurses
zlib

haskellPackages.cabal-install
haskellPackages.hlint
Expand Down
5 changes: 4 additions & 1 deletion src/Ide/Plugin/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import Ide.Plugin
import Ide.Types
import Language.Haskell.LSP.Types
import Text.Regex.TDFA.Text()
import Development.IDE.GHC.Compat (ParsedModule(ParsedModule))

-- ---------------------------------------------------------------------

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

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