Skip to content

Commit 86d67ff

Browse files
authored
Update nixpkgs to ghc 8.10.4 (#1538)
* Update niv and nixpkgs * Use nixos-unstable in CI * Do not override mkDerivation * Switch to nixpkgs-unstable * Jailbreak only broken packages * Update nixpkgs * Better override * Update nixpkgs * Check whether the package is jailbroken, add comments * Downgrade tracy to 0.7.5 * Update maintainer notes
1 parent 0e9dca4 commit 86d67ff

File tree

5 files changed

+97
-64
lines changed

5 files changed

+97
-64
lines changed

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
submodules: true
2828
- uses: cachix/install-nix-action@v12
2929
with:
30-
nix_path: nixpkgs=channel:nixos-20.03
30+
nix_path: nixpkgs=channel:nixos-unstable
3131
- uses: cachix/cachix-action@v8
3232
with:
3333
name: haskell-language-server

nix/default.nix

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
let
33
nix-pre-commit-hooks = (import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master/" + "/nix/") { sources = sources; }).packages;
44
overlay = _self: pkgs:
5-
let sharedOverrides = {
6-
overrides = _self: super: {
7-
mkDerivation = args: super.mkDerivation (args //
8-
{
9-
# skip running tests for Hackage packages
10-
doCheck = args.pname == "ghcide" || args.pname == "haskell-language-server";
11-
# relax upper bounds
12-
jailbreak = args.pname != "jailbreak-cabal";
13-
});
14-
};
15-
};
16-
gitignoreSource = (import sources.gitignore { inherit (pkgs) lib; }).gitignoreSource;
17-
extended = haskellPackages:
18-
haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides {
5+
let
6+
sharedOverrides = {
7+
overrides = _self: super: {
8+
# we override mkDerivation here to apply the following
9+
# tweak to each haskell package:
10+
# if the package is broken, then we disable its check and relax the cabal bounds;
11+
# otherwise, we leave it unchanged.
12+
# hopefully, this could fix packages marked as broken by nix due to check failures
13+
# or the build failure because of tight cabal bounds
14+
mkDerivation = args:
15+
let
16+
broken = args.broken or false;
17+
check = args.doCheck or true;
18+
jailbreak = args.jailbreak or false;
19+
in super.mkDerivation (args // {
20+
jailbreak = if broken then true else jailbreak;
21+
doCheck = if broken then false else check;
22+
});
23+
};
24+
};
25+
ourSources = {
1926
haskell-language-server = gitignoreSource ../.;
2027
ghcide = gitignoreSource ../ghcide;
2128
shake-bench = gitignoreSource ../shake-bench;
@@ -30,10 +37,26 @@ let
3037
hls-retrie-plugin = gitignoreSource ../plugins/hls-retrie-plugin;
3138
hls-splice-plugin = gitignoreSource ../plugins/hls-splice-plugin;
3239
hls-tactics-plugin = gitignoreSource ../plugins/hls-tactics-plugin;
33-
});
40+
};
41+
gitignoreSource = (import sources.gitignore { inherit (pkgs) lib; }).gitignoreSource;
42+
extended = haskellPackages:
43+
haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides ourSources);
3444
in
3545
{
3646
inherit gitignoreSource;
47+
inherit ourSources;
48+
49+
# tracy-0.7.6 is broken on macOS
50+
tracy = pkgs.tracy.overrideAttrs (_old: rec {
51+
version = "0.7.5";
52+
src = pkgs.fetchFromGitHub {
53+
owner = "wolfpld";
54+
repo = "tracy";
55+
rev = "v${version}";
56+
sha256 = "0qfb30k6a8vi8vn65vv927wd9nynwwvc9crbmi7a55kp20hzg06r";
57+
};
58+
});
59+
3760
ourHaskell = pkgs.haskell // {
3861
packages = pkgs.haskell.packages // {
3962
# relax upper bounds on ghc 8.10.x versions (and skip running tests)

nix/sources.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"homepage": "",
66
"owner": "hercules-ci",
77
"repo": "gitignore",
8-
"rev": "c4662e662462e7bf3c2a968483478a665d00e717",
9-
"sha256": "1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx",
8+
"rev": "211907489e9f198594c0eb0ca9256a1949c9d412",
9+
"sha256": "06j7wpvj54khw0z10fjyi31kpafkr6hi1k0di13k1xp8kywvfyx8",
1010
"type": "tarball",
11-
"url": "https://github.com/hercules-ci/gitignore/archive/c4662e662462e7bf3c2a968483478a665d00e717.tar.gz",
11+
"url": "https://github.com/hercules-ci/gitignore/archive/211907489e9f198594c0eb0ca9256a1949c9d412.tar.gz",
1212
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
1313
},
1414
"niv": {
@@ -17,22 +17,22 @@
1717
"homepage": "https://github.com/nmattia/niv",
1818
"owner": "nmattia",
1919
"repo": "niv",
20-
"rev": "89ae775e9dfc2571f912156dd2f8627e14d4d507",
21-
"sha256": "0ssw6byyn79fpyzswi28s5b85x66xh4xsfhmcfl5mkdxxpmyy0ns",
20+
"rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e",
21+
"sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n",
2222
"type": "tarball",
23-
"url": "https://github.com/nmattia/niv/archive/89ae775e9dfc2571f912156dd2f8627e14d4d507.tar.gz",
23+
"url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz",
2424
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
2525
},
2626
"nixpkgs": {
27-
"branch": "haskell-updates",
27+
"branch": "nixpkgs-unstable",
2828
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
2929
"homepage": "https://github.com/NixOS/nixpkgs",
3030
"owner": "NixOS",
3131
"repo": "nixpkgs",
32-
"rev": "8911c99c2f1bf44210be7ff35314430f02f0f33d",
33-
"sha256": "06mi91yxidjyyrc7q5dbi1j8bxi2iird0ivqcnb4kiglpw0ivpkr",
32+
"rev": "c5147860e23ed75ce9d40298c66b416c00be1167",
33+
"sha256": "104mw4rfbzyrfkxq468dlk38drrjx92dgyvkazgci67a6cx3n6nx",
3434
"type": "tarball",
35-
"url": "https://github.com/NixOS/nixpkgs/archive/8911c99c2f1bf44210be7ff35314430f02f0f33d.tar.gz",
35+
"url": "https://github.com/NixOS/nixpkgs/archive/c5147860e23ed75ce9d40298c66b416c00be1167.tar.gz",
3636
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
3737
}
3838
}

nix/sources.nix

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@ let
66
# The fetchers. fetch_<type> fetches specs of type <type>.
77
#
88

9-
fetch_file = pkgs: spec:
10-
if spec.builtin or true then
11-
builtins_fetchurl { inherit (spec) url sha256; }
12-
else
13-
pkgs.fetchurl { inherit (spec) url sha256; };
9+
fetch_file = pkgs: name: spec:
10+
let
11+
name' = sanitizeName name + "-src";
12+
in
13+
if spec.builtin or true then
14+
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
15+
else
16+
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
1417

1518
fetch_tarball = pkgs: name: spec:
1619
let
17-
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
18-
# sanitize the name, though nix will still fail if name starts with period
19-
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
20+
name' = sanitizeName name + "-src";
2021
in
2122
if spec.builtin or true then
2223
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
2324
else
2425
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
2526

26-
fetch_git = spec:
27-
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
27+
fetch_git = name: spec:
28+
let
29+
ref =
30+
if spec ? ref then spec.ref else
31+
if spec ? branch then "refs/heads/${spec.branch}" else
32+
if spec ? tag then "refs/tags/${spec.tag}" else
33+
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
34+
in
35+
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
2836

2937
fetch_local = spec: spec.path;
3038

@@ -40,11 +48,21 @@ let
4048
# Various helpers
4149
#
4250

51+
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
52+
sanitizeName = name:
53+
(
54+
concatMapStrings (s: if builtins.isList s then "-" else s)
55+
(
56+
builtins.split "[^[:alnum:]+._?=-]+"
57+
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
58+
)
59+
);
60+
4361
# The set of packages used when specs are fetched using non-builtins.
44-
mkPkgs = sources:
62+
mkPkgs = sources: system:
4563
let
4664
sourcesNixpkgs =
47-
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
65+
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
4866
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
4967
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
5068
in
@@ -64,9 +82,9 @@ let
6482

6583
if ! builtins.hasAttr "type" spec then
6684
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
67-
else if spec.type == "file" then fetch_file pkgs spec
85+
else if spec.type == "file" then fetch_file pkgs name spec
6886
else if spec.type == "tarball" then fetch_tarball pkgs name spec
69-
else if spec.type == "git" then fetch_git spec
87+
else if spec.type == "git" then fetch_git name spec
7088
else if spec.type == "local" then fetch_local spec
7189
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
7290
else if spec.type == "builtin-url" then fetch_builtin-url name
@@ -80,7 +98,10 @@ let
8098
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
8199
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
82100
in
83-
if ersatz == "" then drv else ersatz;
101+
if ersatz == "" then drv else
102+
# this turns the string into an actual Nix path (for both absolute and
103+
# relative paths)
104+
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
84105

85106
# Ports of functions for older nix versions
86107

@@ -98,25 +119,29 @@ let
98119

99120
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
100121
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
122+
concatMapStrings = f: list: concatStrings (map f list);
101123
concatStrings = builtins.concatStringsSep "";
102124

125+
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
126+
optionalAttrs = cond: as: if cond then as else {};
127+
103128
# fetchTarball version that is compatible between all the versions of Nix
104-
builtins_fetchTarball = { url, name, sha256 }@attrs:
129+
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
105130
let
106131
inherit (builtins) lessThan nixVersion fetchTarball;
107132
in
108133
if lessThan nixVersion "1.12" then
109-
fetchTarball { inherit name url; }
134+
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
110135
else
111136
fetchTarball attrs;
112137

113138
# fetchurl version that is compatible between all the versions of Nix
114-
builtins_fetchurl = { url, sha256 }@attrs:
139+
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
115140
let
116141
inherit (builtins) lessThan nixVersion fetchurl;
117142
in
118143
if lessThan nixVersion "1.12" then
119-
fetchurl { inherit url; }
144+
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
120145
else
121146
fetchurl attrs;
122147

@@ -135,7 +160,8 @@ let
135160
mkConfig =
136161
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
137162
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
138-
, pkgs ? mkPkgs sources
163+
, system ? builtins.currentSystem
164+
, pkgs ? mkPkgs sources system
139165
}: rec {
140166
# The sources, i.e. the attribute set of spec name to spec
141167
inherit sources;

shell.nix

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
# Maintaining this file:
55
#
66
# - Bump the nixpkgs version using `niv update nixpkgs`
7-
# - To edit the set of local packages:
8-
# 1. Declare them in nix/default.nix
9-
# 2. Edit the list of packages below
7+
# - Edit `ourSources` (in nix/default.nix) to update the set of local packages
108
#
119
# For more details: https://github.com/NixOS/nixpkgs/blob/20.03/pkgs/development/haskell-modules/make-package-set.nix#L256
1210

@@ -24,21 +22,7 @@ let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.
2422
then ourHaskell.packages.${defaultCompiler}
2523
else ourHaskell.packages.${compiler};
2624

27-
packages = p: [ p.haskell-language-server
28-
p.ghcide
29-
p.shake-bench
30-
p.hie-compat
31-
p.hls-plugin-api
32-
p.hls-brittany-plugin
33-
p.hls-class-plugin
34-
p.hls-haddock-comments-plugin
35-
p.hls-eval-plugin
36-
p.hls-explicit-imports-plugin
37-
p.hls-hlint-plugin
38-
p.hls-retrie-plugin
39-
p.hls-splice-plugin
40-
p.hls-tactics-plugin
41-
];
25+
packages = p: with builtins; map (name: p.${name}) (attrNames ourSources);
4226

4327
isSupported = compiler == "default" || compiler == defaultCompiler;
4428
in

0 commit comments

Comments
 (0)