Skip to content

Commit 483e641

Browse files
authored
Simplify nix setup (#531)
* Simplify nix setup This doesn't try to build the dependencies, just provides GHC/cabal/HLS. * Add cabal-fmt and fourmolu * Updated fourmolu * Use the default GHC
1 parent 418c878 commit 483e641

File tree

8 files changed

+37
-50
lines changed

8 files changed

+37
-50
lines changed

fourmolu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
indentation: 2
2+
single-constraint-parens: auto

lsp-test/src/Language/LSP/Test.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,15 @@ executeCodeAction action = do
753753
let req = TRequestMessage "" (IdInt 0) SMethod_WorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing e)
754754
in updateState (FromServerMess SMethod_WorkspaceApplyEdit req)
755755

756-
-- |Resolves the provided code action.
756+
-- | Resolves the provided code action.
757757
resolveCodeAction :: CodeAction -> Session CodeAction
758758
resolveCodeAction ca = do
759759
rsp <- request SMethod_CodeActionResolve ca
760760
case rsp ^. L.result of
761761
Right ca -> return ca
762762
Left er -> throw (UnexpectedResponseError (SomeLspId $ fromJust $ rsp ^. L.id) er)
763763

764-
{- |If a code action contains a _data_ field: resolves the code action, then
764+
{- | If a code action contains a _data_ field: resolves the code action, then
765765
executes it. Otherwise, just executes it.
766766
-}
767767
resolveAndExecuteCodeAction :: CodeAction -> Session ()
@@ -821,7 +821,7 @@ getAndResolveCompletions doc pos = do
821821
items <- getCompletions doc pos
822822
for items $ \item -> if isJust (item ^. L.data_) then resolveCompletion item else pure item
823823

824-
-- |Resolves the provided completion item.
824+
-- | Resolves the provided completion item.
825825
resolveCompletion :: CompletionItem -> Session CompletionItem
826826
resolveCompletion ci = do
827827
rsp <- request SMethod_CompletionItemResolve ci
@@ -956,7 +956,7 @@ getAndResolveCodeLenses tId = do
956956
codeLenses <- getCodeLenses tId
957957
for codeLenses $ \codeLens -> if isJust (codeLens ^. L.data_) then resolveCodeLens codeLens else pure codeLens
958958

959-
-- |Resolves the provided code lens.
959+
-- | Resolves the provided code lens.
960960
resolveCodeLens :: CodeLens -> Session CodeLens
961961
resolveCodeLens cl = do
962962
rsp <- request SMethod_CodeLensResolve cl

lsp-test/src/Language/LSP/Test/Replay.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
and validating that the server output matches up with another log.
33
-}
44
module Language.LSP.Test.Replay (
5-
)
5+
6+
)
67
where
78

89
-- replaySession

lsp-types/src/Language/LSP/Protocol/Types/WatchKinds.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@ import Language.LSP.Protocol.Types.LspEnum (fromOpenEnumBaseType, toEnumBaseType
77
-- WatchKind is better represented as a Set than as enum. As the lsp spec
88
-- defines them as an enum, these helper functions help bridge the difference.
99

10-
-- |Tests whether `WatchKind_Create` is contained in the provided WatchKind enum
10+
-- | Tests whether `WatchKind_Create` is contained in the provided WatchKind enum
1111
containsCreate :: WatchKind -> Bool
1212
containsCreate WatchKind_Create = True
1313
containsCreate (WatchKind_Custom 3) = True
1414
containsCreate (WatchKind_Custom 5) = True
1515
containsCreate (WatchKind_Custom 7) = True
1616
containsCreate _ = False
1717

18-
-- |Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
18+
-- | Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
1919
containsChange :: WatchKind -> Bool
2020
containsChange WatchKind_Change = True
2121
containsChange (WatchKind_Custom 3) = True
2222
containsChange (WatchKind_Custom 6) = True
2323
containsChange (WatchKind_Custom 7) = True
2424
containsChange _ = False
2525

26-
-- |Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
26+
-- | Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
2727
containsDelete :: WatchKind -> Bool
2828
containsDelete WatchKind_Delete = True
2929
containsDelete (WatchKind_Custom 5) = True
3030
containsDelete (WatchKind_Custom 6) = True
3131
containsDelete (WatchKind_Custom 7) = True
3232
containsDelete _ = False
3333

34-
{- |Combine a set of WatchKind types into a new WatchKind type that accurately
34+
{- | Combine a set of WatchKind types into a new WatchKind type that accurately
3535
represents the set
3636
-}
3737
combineWatchKinds :: Set WatchKind -> WatchKind

lsp/src/Language/LSP/VFS.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ getCompletionPrefix pos@(J.Position l c) (VirtualFile _ _ ropetext) =
538538
beforePos <- Rope.toText . fst <$> Rope.splitAt (fromIntegral c) curRope
539539
curWord <-
540540
if
541-
| T.null beforePos -> Just ""
542-
| T.last beforePos == ' ' -> Just "" -- don't count abc as the curword in 'abc '
543-
| otherwise -> lastMaybe (T.words beforePos)
541+
| T.null beforePos -> Just ""
542+
| T.last beforePos == ' ' -> Just "" -- don't count abc as the curword in 'abc '
543+
| otherwise -> lastMaybe (T.words beforePos)
544544

545545
let parts =
546546
T.split (== '.') $

nix/default.nix

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
11
{ sources ? import ./sources.nix }:
22

3-
let
4-
overlay = self: super:
5-
let
6-
inherit (import sources."gitignore.nix" { inherit (super) lib; })
7-
gitignoreSource;
8-
ourSources = {
9-
lsp = gitignoreSource ../lsp;
10-
lsp-test = gitignoreSource ../lsp-test;
11-
lsp-types = gitignoreSource ../lsp-types;
12-
};
13-
14-
in {
15-
inherit gitignoreSource;
16-
inherit ourSources;
17-
ourHaskellPackages = with super.haskell.lib;
18-
super.haskellPackages.extend (packageSourceOverrides ourSources);
19-
};
20-
in (import sources.nixpkgs {
21-
overlays = [ overlay ];
22-
config = { allowBroken = true; };
23-
})
3+
import sources.nixpkgs { }

nix/sources.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"homepage": "",
66
"owner": "hercules-ci",
77
"repo": "gitignore.nix",
8-
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
9-
"sha256": "07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh",
8+
"rev": "9e21c80adf67ebcb077d75bd5e7d724d21eeafd6",
9+
"sha256": "1lbkgn94y8850g7idqnbji12pscxjwrspnzmx8fmm7xmy9ablk5y",
1010
"type": "tarball",
11-
"url": "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz",
11+
"url": "https://github.com/hercules-ci/gitignore.nix/archive/9e21c80adf67ebcb077d75bd5e7d724d21eeafd6.tar.gz",
1212
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
1313
},
1414
"niv": {
@@ -17,10 +17,10 @@
1717
"homepage": "https://github.com/nmattia/niv",
1818
"owner": "nmattia",
1919
"repo": "niv",
20-
"rev": "7225521219f64df00de86c3b946a26f608f3b4dc",
21-
"sha256": "04w9c06f70n0k9c4xhma4nfrkxxg7d039xd3v9dak8xd7avjb7v0",
20+
"rev": "723f0eeb969a730db3c30f977c2b66b9dce9fe4a",
21+
"sha256": "0016l7230gd2kdh0g2w573r9a2krqb7x4ifcjhhsn4h1bwap7qr0",
2222
"type": "tarball",
23-
"url": "https://github.com/nmattia/niv/archive/7225521219f64df00de86c3b946a26f608f3b4dc.tar.gz",
23+
"url": "https://github.com/nmattia/niv/archive/723f0eeb969a730db3c30f977c2b66b9dce9fe4a.tar.gz",
2424
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
2525
},
2626
"nixpkgs": {
@@ -29,10 +29,10 @@
2929
"homepage": "",
3030
"owner": "NixOS",
3131
"repo": "nixpkgs",
32-
"rev": "b969a89c3e84a121c9b3af2e4ef277cd822b988a",
33-
"sha256": "0qib8p3iscj7l3i6y03x1f5fhmn8336nbk7lg2hwvx44cpy63jvz",
32+
"rev": "9ea24fc7e02b65c150c88e1412400b70087bd382",
33+
"sha256": "002abgrz7gdj99gzyhmkpxx8j3x5grapmal9i0r580phvin9g2r5",
3434
"type": "tarball",
35-
"url": "https://github.com/NixOS/nixpkgs/archive/b969a89c3e84a121c9b3af2e4ef277cd822b988a.tar.gz",
35+
"url": "https://github.com/NixOS/nixpkgs/archive/9ea24fc7e02b65c150c88e1412400b70087bd382.tar.gz",
3636
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
3737
}
3838
}

shell.nix

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
{ withHoogle ? false, nixpkgs ? import ./nix { } }:
1+
{ nixpkgs ? import ./nix { } }:
22
with nixpkgs;
3-
with ourHaskellPackages;
4-
shellFor {
5-
inherit withHoogle;
6-
doBenchmark = true;
7-
doTest = true;
8-
packages = p: with builtins; map (name: p.${name}) (attrNames ourSources);
9-
buildInputs = [ cabal-install nixpkgs.haskellPackages.haskell-language-server nixpkgs.haskellPackages.fourmolu ];
3+
let
4+
hsPkgs = haskellPackages;
5+
ghc = haskellPackages.ghc;
6+
in mkShell {
7+
nativeBuildInputs = [
8+
hsPkgs.ghc
9+
hsPkgs.haskell-language-server
10+
haskellPackages.cabal-fmt
11+
haskellPackages.fourmolu
12+
cabal-install
13+
zlib
14+
pkg-config ];
1015
}

0 commit comments

Comments
 (0)