Skip to content

Commit 93ed096

Browse files
committed
nix: New entries which build all target at once
All HLS version can be built with `nix build .#all-haskell-language-server`, and all development shells with `nix build .#all-dev-shells`. I had to workaround a limitation in `nix build` which is not able to build multiples targets, instead I used linkFarmFromDrvs. All packages and shells are now named with a unique package name containing the GHC version.
1 parent 8d9c986 commit 93ed096

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

flake.nix

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
};
238238

239239
mkDevShell = hpkgs: cabalProject: with pkgs; mkShell {
240+
name = "haskell-language-server-dev-ghc${hpkgs.ghc.version}";
240241
# For theses tools packages, we use ghcDefault
241242
# This removes a rebuild with a different GHC version
242243
# Theses programs are tools, used as binary, independently of the
@@ -298,6 +299,7 @@
298299
let simpleShell = mkDevShell hpkgs cabalProject;
299300
in
300301
hpkgs.shellFor {
302+
name = "haskell-language-server-dev-nix-ghc${hpkgs.ghc.version}";
301303
inherit (simpleShell) shellHook buildInputs;
302304

303305
doBenchmark = true;
@@ -313,7 +315,7 @@
313315
# Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16
314316
mkExe = hpkgs:
315317
with pkgs.haskell.lib;
316-
justStaticExecutables (overrideCabal hpkgs.haskell-language-server
318+
(justStaticExecutables (overrideCabal hpkgs.haskell-language-server
317319
(_: {
318320
postInstall = ''
319321
remove-references-to -t ${hpkgs.ghc} $out/bin/haskell-language-server
@@ -322,7 +324,9 @@
322324
remove-references-to -t ${hpkgs.js-dgtable.data} $out/bin/haskell-language-server
323325
remove-references-to -t ${hpkgs.js-flot.data} $out/bin/haskell-language-server
324326
'';
325-
}));
327+
}))).overrideAttrs(old: {
328+
pname = old.pname + "-ghc${hpkgs.ghc.version}";
329+
});
326330
in with pkgs; rec {
327331

328332
devShells = {
@@ -339,14 +343,26 @@
339343
haskell-language-server-921-dev-nix = mkDevShellWithNixDeps ghc921 "cabal-ghc921.project";
340344
};
341345

342-
packages = {
346+
allPackages = {
343347
haskell-language-server = mkExe ghcDefault;
344348
haskell-language-server-884 = mkExe ghc884;
345349
haskell-language-server-8107 = mkExe ghc8107;
346350
haskell-language-server-901 = mkExe ghc901;
347351
haskell-language-server-921 = mkExe ghc921;
352+
};
353+
354+
packages = allPackages // {
355+
# See https://github.com/NixOS/nix/issues/5591
356+
# nix flake cannot build a list/set of derivation in one command.
357+
# Using a linkFarmFromDrvs, I'm creating a unique entry point to
358+
# build all HLS versions.
359+
# This is used in CI to test and populate cache for packages
360+
# distributed using nix.
361+
all-haskell-language-server = linkFarmFromDrvs "all-haskell-language-server" (lib.unique (builtins.attrValues allPackages));
362+
363+
# Same for all shells
364+
all-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues devShells)));
348365

349-
# docs
350366
docs = docs;
351367
};
352368

0 commit comments

Comments
 (0)