on e94de40 help sign in
149 lines 5.9 kB history raw
1# This overlay helps accessing common executable components.
2# Typically we want to make these available in a nix-shell
3# created with shellFor. In most cases the package name
4# will be the same as the executable, but we have a
5# `toolPackageName` and `packageToolName` mapping to help
6# when it is not.
7#
8# To get a single tool:
9# haskell-nix.tool "ghc884" "cabal" "3.2.0.0"
11# This does the same thing as:
12# (haskell-nix.hackage-package {
13# compiler-nix-name = "ghc884";
14# name = "cabal-install"
15# version = "3.2.0.0"
16# }).components.exes.cabal
18# To get an attr set containing multiple tools:
19# haskell-nix.tools "ghc884" { cabal = "3.2.0.0"; hlint = "2.2.11"; }
21# To add tools to a shell:
22# shellFor { tools = { cabal = "3.2.0.0"; hlint = "2.2.11"; }; }
24# When used in shellFor the tools will be compiled with the same version
25# of ghc used in the shell (the build ghc in the case of cross compilation).
27# To get tools for use with project `p` without using shellFor:
28# p.tool "cabal" "3.2.0.0"
29# p.tools { cabal = "3.2.0.0"; hlint = "2.2.11"; }
30# (the ghc version used to build it will match the one used in the project)
32# Instead of a version string we can use an attr set containing
33# arguments that will be passed to `cabalProject`.
35# For instance to add haskell.nix modules. Use:
36# haskell-nix.tool "ghc884" "cabal" {
37# version = "3.2.0.0";
38# modules = [ ... ];
39# }
41final: prev:
42let
43 inherit (final) lib;
45in { haskell-nix = prev.haskell-nix // {
47 # Some times the package name in hackage is not the same as tool name.
48 # Tools better known by their exe name.
49 toolPackageName = {
50 cabal = "cabal-install";
51 };
53 # Packages that are better known by their package name. We are not
54 # reusing toolPackageName here as perhaps the more one package
55 # will have the same exe name.
56 packageToolName = {
57 cabal-install = "cabal";
58 };
60 hackage-tool = { name, ... }@args':
61 let
62 args = { caller = "hackage-tool"; } // args';
63 in
64 (final.haskell-nix.hackage-package
65 (args // { name = final.haskell-nix.toolPackageName.${name} or name; }))
66 .components.exes."${final.haskell-nix.packageToolName.${name} or name}";
68 tool = compiler-nix-name: name: versionOrArgs:
69 let
70 args' = final.haskell-nix.haskellLib.versionOrArgsToArgs versionOrArgs;
71 args = { inherit compiler-nix-name; } // args';
72 in
73 (if final.haskell-nix.custom-tools ? "${name}"
74 && final.haskell-nix.custom-tools."${name}" ? "${args.version}"
75 then final.haskell-nix.custom-tools."${name}"."${args.version}"
76 else final.haskell-nix.hackage-tool) (args // { inherit name; });
78 tools = compiler-nix-name: lib.mapAttrs (final.haskell-nix.tool compiler-nix-name);
80 # Like `tools` but allows default ghc to be specified
81 toolsForGhc = ghcOverride: toolSet:
82 final.haskell-nix.tools (
83 lib.mapAttrs (name: versionOrArgs:
84 let args = final.haskell-nix.haskellLib.versionOrArgsToArgs versionOrArgs;
85 in
86 # Add default ghc if not specified in the args
87 (lib.optionalAttrs (!(args ? "compiler-nix-name" || args ? "ghc"))
88 { inherit ghcOverride; }
89 ) // args
90 ) toolSet
91 );
93 # Tools not in hackage yet
94 # When adding custom tools here, consider adding them
95 # to the `tools` attribute defined in `build.nix` to make
96 # sure they are cached.
97 custom-tools = {
98 ghcide.object-code = args:
99 (final.haskell-nix.cabalProject (args // {
100 name = "ghcide";
101 src = final.fetchFromGitHub {
102 owner = "mpickering";
103 repo = "ghcide";
104 rev = "706c59c97c25c66798815c1dc3ee6885a298918a";
105 sha256 = "0d158xifwvz0y69ah98ckxakzqpz229mq7rpf2bpbmwhnpw3jmm6";
106 };
107 modules = [({config, ...}: {
108 packages.ghcide.configureFlags = lib.optional (!final.stdenv.targetPlatform.isMusl)
109 "--enable-executable-dynamic";
110 nonReinstallablePkgs = [ "Cabal" "array" "base" "binary" "bytestring" "containers" "deepseq"
111 "directory" "filepath" "ghc" "ghc-boot" "ghc-boot-th" "ghc-compact"
112 "ghc-heap" "ghc-prim" "ghci" "haskeline" "hpc" "integer-gmp"
113 "libiserv" "mtl" "parsec" "pretty" "process" "rts" "stm"
114 "template-haskell" "terminfo" "text" "time" "transformers" "unix"
115 "xhtml"
116 ];
117 })];
118 pkg-def-extras = [
119 (hackage: {
120 packages = {
121 "alex" = (((hackage.alex)."3.2.5").revisions).default;
122 "happy" = (((hackage.happy)."1.19.12").revisions).default;
123 };
124 })
125 ];
126 })).ghcide.components.exes.ghcide;
128 haskell-language-server."0.5.1" = args:
129 (final.haskell-nix.cabalProject ( args // {
130 name = "haskell-language-server";
131 src = final.fetchFromGitHub {
132 owner = "haskell";
133 repo = "haskell-language-server";
134 rev = "0.5.1";
135 sha256 = "17nzgpiacmrvwsy2fjx6a6pcpkncqcwfhaijvajm16jpdgni8mik";
136 fetchSubmodules = true;
137 };
138 sha256map = {
139 "https://github.com/bubba/brittany.git"."c59655f10d5ad295c2481537fc8abf0a297d9d1c" = "1rkk09f8750qykrmkqfqbh44dbx1p8aq1caznxxlw8zqfvx39cxl";
140 };
141 # Plan issues with the benchmarks, can try removing later
142 configureArgs = "--disable-benchmarks";
143 modules = [{
144 # Tests don't pass for some reason, but this is a somewhat random revision.
145 packages.haskell-language-server.doCheck = false;
146 }];
147 })).haskell-language-server.components.exes.haskell-language-server;
148 };
149}; }