Skip to content

Commit 6dd4b09

Browse files
committed
Upgrade Nix script to use the haskell-updates branch.
The haskell-updates branch is already on Stackage nightly, which allows for a much better cache hit rate (assuming haskell-updates is backed by a Hydra cache, which I'm not quite sure of).
1 parent d0fb85e commit 6dd4b09

File tree

3 files changed

+82
-110
lines changed

3 files changed

+82
-110
lines changed

nix/default.nix

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{ sources ? import ./sources.nix }:
2+
let
3+
overlay = _self: pkgs:
4+
let sharedOverrides = {
5+
overrides = _self: super: {
6+
mkDerivation = args: super.mkDerivation (args //
7+
{
8+
# skip running tests for Hackage packages
9+
doCheck =
10+
# but not for ghcide
11+
args.version == "0";
12+
# relax upper bounds
13+
jailbreak = args.pname != "jailbreak-cabal";
14+
});
15+
};
16+
};
17+
extended = haskellPackages:
18+
haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides {
19+
haskell-language-server = ../.;
20+
ghcide = ../ghcide;
21+
hie-compat = ../ghcide/hie-compat;
22+
hls-plugin-api = ../hls-plugin-api;
23+
hls-tactics-plugin = ../plugins/tactics;
24+
hls-hlint-plugin = ../plugins/hls-hlint-plugin;
25+
});
26+
in
27+
{
28+
inherit (import sources.gitignore { inherit (pkgs) lib; }) gitignoreSource;
29+
ourHaskell = pkgs.haskell // {
30+
packages = pkgs.haskell.packages // {
31+
# relax upper bounds on ghc 8.10.x versions (and skip running tests)
32+
ghc8101 = extended (pkgs.haskell.packages.ghc8101.override sharedOverrides);
33+
ghc8102 = extended (pkgs.haskell.packages.ghc8102.override sharedOverrides);
34+
};
35+
};
36+
};
37+
38+
in import sources.nixpkgs
39+
{ overlays = [ overlay ] ; config = {allowBroken = true;}; }

nix/sources.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{
2+
"gitignore": {
3+
"branch": "master",
4+
"description": "Nix function for filtering local git sources",
5+
"homepage": "",
6+
"owner": "hercules-ci",
7+
"repo": "gitignore",
8+
"rev": "c4662e662462e7bf3c2a968483478a665d00e717",
9+
"sha256": "1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx",
10+
"type": "tarball",
11+
"url": "https://github.com/hercules-ci/gitignore/archive/c4662e662462e7bf3c2a968483478a665d00e717.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
214
"niv": {
315
"branch": "master",
416
"description": "Easy dependency management for Nix projects",
@@ -12,15 +24,15 @@
1224
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
1325
},
1426
"nixpkgs": {
15-
"branch": "nixpkgs-unstable",
27+
"branch": "haskell-updates",
1628
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
1729
"homepage": "https://github.com/NixOS/nixpkgs",
1830
"owner": "NixOS",
19-
"repo": "nixpkgs-channels",
20-
"rev": "a332da8588aeea4feb9359d23f58d95520899e3c",
21-
"sha256": "18hlja5syv3xpi14c07h9lrn1cchq2azmj06fyalq52vl064nx75",
31+
"repo": "nixpkgs",
32+
"rev": "cbf707b2af4cd66bdcdd84b2bddfb627194b39c0",
33+
"sha256": "1bj55jkgdzx7lv6dvy26l354c7vsxaa1jipm99axgqqax905m8sa",
2234
"type": "tarball",
23-
"url": "https://github.com/NixOS/nixpkgs-channels/archive/a332da8588aeea4feb9359d23f58d95520899e3c.tar.gz",
35+
"url": "https://github.com/NixOS/nixpkgs/archive/cbf707b2af4cd66bdcdd84b2bddfb627194b39c0.tar.gz",
2436
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
2537
}
2638
}

shell.nix

Lines changed: 26 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,46 @@
11
# This shell.nix file is designed for use with cabal build
2-
# It aims to leverage the nix cache in as much as possible
3-
# while reducing Nix maintenance costs.
4-
# It does **not** aim to replace Cabal/Stack with Nix
2+
# It does **not** aim to replace Cabal
53

64
# Maintaining this file:
75
#
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
6+
# - Bump the nixpkgs version using `niv update nixpkgs`
177

18-
{ sources ? import nix/sources.nix,
19-
nixpkgs ? import sources.nixpkgs { },
20-
compiler ? "default",
21-
hoogle ? false
8+
{ compiler ? "default",
9+
withHoogle ? false,
10+
nixpkgs ? import ./nix {}
2211
}:
12+
2313
with nixpkgs;
2414

2515
let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.version;
26-
haskellPackagesForProject = p:
27-
if compiler == "default" || compiler == defaultCompiler
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 (_: []);
16+
haskellPackagesForProject =
17+
if compiler == "default"
18+
then ourHaskell.packages.${defaultCompiler}
19+
else ourHaskell.packages.${compiler};
20+
21+
packages = p: [ p.haskell-language-server
22+
p.ghcide
23+
p.hie-compat
24+
p.hls-plugin-api
25+
p.hls-tactics-plugin
26+
p.hls-hlint-plugin
27+
];
3528

36-
retrie = with haskell.lib; dontCheck(disableLibraryProfiling(haskellPackages.retrie));
37-
compilerWithPackages = haskellPackagesForProject(p:
38-
with p;
39-
[
40-
Diff
41-
Glob
42-
HsYAML-aeson
43-
QuickCheck
44-
aeson
45-
alex
46-
async
47-
base16-bytestring
48-
blaze-builder
49-
blaze-markup
50-
brittany
51-
conduit-extra
52-
conduit-parse
53-
cryptohash-sha1
54-
data-default
55-
data-default-class
56-
data-default-instances-containers
57-
data-default-instances-dlist
58-
data-default-instances-old-locale
59-
extra
60-
floskell
61-
# fourmolu
62-
fuzzy
63-
generic-deriving
64-
ghc-check
65-
gitrev
66-
haddock-library
67-
happy
68-
haskell-lsp
69-
haskell-src-exts
70-
hie-bios
71-
hslogger
72-
hspec
73-
lens
74-
lsp-test
75-
megaparsec
76-
network
77-
opentelemetry
78-
optparse-simple
79-
ormolu
80-
parser-combinators
81-
parsers
82-
prettyprinter
83-
prettyprinter-ansi-terminal
84-
primes
85-
psqueues
86-
regex-tdfa
87-
retrie
88-
rope-utf16-splay
89-
safe-exceptions
90-
shake
91-
sorted-list
92-
strict
93-
stylish-haskell
94-
tasty
95-
tasty-ant-xml
96-
tasty-expected-failure
97-
tasty-golden
98-
tasty-hunit
99-
tasty-rerun
100-
temporary
101-
text
102-
typed-process
103-
unix-compat
104-
unordered-containers
105-
xml
106-
yaml
107-
zlib
108-
]);
29+
isSupported = compiler == "default" || compiler == defaultCompiler;
10930
in
110-
stdenv.mkDerivation {
111-
name = "haskell-language-server";
31+
haskellPackagesForProject.shellFor {
32+
inherit withHoogle;
33+
doBenchmark = true;
34+
packages = p: if isSupported then packages p else [p.ghc-paths];
11235
buildInputs = [
113-
git
11436
gmp
115-
ncurses
11637
zlib
38+
ncurses
11739

11840
haskellPackages.cabal-install
11941
haskellPackages.hlint
120-
121-
compilerWithPackages
122-
42+
haskellPackages.ormolu
43+
haskellPackages.stylish-haskell
12344
];
12445
src = null;
12546
shellHook = ''

0 commit comments

Comments
 (0)