From 0bdef8e612fb963737575513e71ea9b8f6cd61ea Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Thu, 13 May 2021 15:59:41 +0800 Subject: [PATCH 01/13] nix: refactor with flakes --- default.nix | 9 +++ flake.lock | 114 +++++++++++++++++++++++++++++++ flake.nix | 172 ++++++++++++++++++++++++++++++++++++++++++++++ nix/default.nix | 92 ------------------------- nix/sources.json | 38 ----------- nix/sources.nix | 174 ----------------------------------------------- shell.nix | 56 --------------- 7 files changed, 295 insertions(+), 360 deletions(-) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 nix/default.nix delete mode 100644 nix/sources.json delete mode 100644 nix/sources.nix delete mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..f8a169dc5b --- /dev/null +++ b/default.nix @@ -0,0 +1,9 @@ +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; } +) { + src = ./.; +}).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..eb03e1001a --- /dev/null +++ b/flake.lock @@ -0,0 +1,114 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1606424373, + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1620759905, + "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1619345332, + "narHash": "sha256-qHnQkEp1uklKTpx3MvKtY6xzgcqXDsz5nLilbbuL+3A=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "2ebf2558e5bf978c7fb8ea927dfaed8fefab2e28", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "flake": false, + "locked": { + "lastModified": 1611672876, + "narHash": "sha256-qHu3uZ/o9jBHiA3MEKHJ06k7w4heOhA+4HCSIvflRxo=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "211907489e9f198594c0eb0ca9256a1949c9d412", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1620830445, + "narHash": "sha256-CE4R4OlOcTUATacRZMo5hyS9n47U6A0G5SASNoo4TbI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "65d6153aec85c8cb46023f0a7248628f423ca4ee", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1619976063, + "narHash": "sha256-2tjVP95+qR1UzL8/UeV/xRJu7S2fRB7rf7enZedbrik=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "09fb9e425111878b58223852e87ed85e8a189e0d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..1b363cd8ad --- /dev/null +++ b/flake.nix @@ -0,0 +1,172 @@ +# Maintaining this file: +# +# - Bump the inputs version using `nix flake update` +# - Edit `sourceDirs` to update the set of local packages +# +# For more details: https://nixos.wiki/wiki/Flakes +{ + description = "haskell language server flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + flake-utils.url = "github:numtide/flake-utils"; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + gitignore = { + url = "github:hercules-ci/gitignore.nix"; + flake = false; + }; + }; + outputs = + { self, nixpkgs, flake-compat, flake-utils, pre-commit-hooks, gitignore }: + { + overlay = final: prev: + with prev; + let + haskellOverrides = { + overrides = hself: hsuper: { + # we override mkDerivation here to apply the following + # tweak to each haskell package: + # if the package is broken, then we disable its check and relax the cabal bounds; + # otherwise, we leave it unchanged. + # hopefully, this could fix packages marked as broken by nix due to check failures + # or the build failure because of tight cabal bounds + mkDerivation = args: + let + broken = args.broken or false; + check = args.doCheck or true; + jailbreak = args.jailbreak or false; + in hsuper.mkDerivation (args // { + jailbreak = if broken then true else jailbreak; + doCheck = if broken then false else check; + }); + }; + }; + gitignoreSource = (import gitignore { inherit lib; }).gitignoreSource; + + sourceDirs = { + haskell-language-server = ./.; + ghcide = ./ghcide; + hls-graph = ./hls-graph; + shake-bench = ./shake-bench; + hie-compat = ./hie-compat; + hls-plugin-api = ./hls-plugin-api; + hls-test-utils = ./hls-test-utils; + hls-brittany-plugin = ./plugins/hls-brittany-plugin; + hls-stylish-haskell-plugin = ./plugins/hls-stylish-haskell-plugin; + hls-class-plugin = ./plugins/hls-class-plugin; + hls-haddock-comments-plugin = ./plugins/hls-haddock-comments-plugin; + hls-eval-plugin = ./plugins/hls-eval-plugin; + hls-explicit-imports-plugin = ./plugins/hls-explicit-imports-plugin; + hls-refine-imports-plugin = ./plugins/hls-refine-imports-plugin; + hls-hlint-plugin = ./plugins/hls-hlint-plugin; + hls-retrie-plugin = ./plugins/hls-retrie-plugin; + hls-splice-plugin = ./plugins/hls-splice-plugin; + hls-tactics-plugin = ./plugins/hls-tactics-plugin; + }; + + hlsSources = + builtins.mapAttrs (_: dir: gitignoreSource dir) sourceDirs; + in { + inherit hlsSources; + + # haskellPackages extended with hls packages + hlsHaskellPackages = with haskell.lib; + (haskellPackages.override haskellOverrides).extend (self: super: + # disable check for ghcide and hls + builtins.mapAttrs (name: drv: + if name == "ghcide" || name == "haskell-language-server" then + dontCheck drv + else + drv) (packageSourceOverrides hlsSources self super)); + + # Support of GenChangelogs.hs + gen-hls-changelogs = + let myGHC = haskellPackages.ghcWithPackages (p: with p; [ github ]); + in runCommand "gen-hls-changelogs" { + passAsFile = [ "text" ]; + preferLocalBuild = true; + allowSubstitutes = false; + buildInputs = [ git myGHC ]; + } '' + dest=$out/bin/gen-hls-changelogs + mkdir -p $out/bin + echo "#!${runtimeShell}" >> $dest + echo "${myGHC}/bin/runghc ${./GenChangelogs.hs}" >> $dest + chmod +x $dest + ''; + }; + } // (flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ]) + (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + config = { allowBroken = true; }; + }; + hlsPackages = p: + with builtins; + map (name: p.${name}) (attrNames pkgs.hlsSources); + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + stylish-haskell.enable = true; + stylish-haskell.excludes = [ + "^Setup.hs$" + "test/testdata/.*$" + "test/data/.*$" + "^hie-compat/.*$" + "^plugins/hls-tactics-plugin/.*$" + ]; + }; + }; + in with pkgs; rec { + + packages = with pkgs.haskell.lib; { + haskell-language-server = + justStaticExecutables hlsHaskellPackages.haskell-language-server; + ghcide = justStaticExecutables hlsHaskellPackages.ghcide; + }; + + apps = { + haskell-language-server = flake-utils.lib.mkApp { + drv = packages.haskell-language-server; + exePath = "/bin/haskell-language-server"; + }; + ghcide = flake-utils.lib.mkApp { + drv = packages.ghcide; + exePath = "/bin/ghcide"; + }; + }; + + defaultPackage = packages.haskell-language-server; + defaultApp = apps.haskell-language-server; + + devShell = hlsHaskellPackages.shellFor { + doBenchmark = true; + packages = hlsPackages; + buildInputs = [ gmp zlib ncurses capstone tracy gen-hls-changelogs ] + ++ (with haskellPackages; [ + cabal-install + hlint + ormolu + stylish-haskell + opentelemetry-extra + ]); + + src = null; + shellHook = '' + export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib + export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib + export PATH=$PATH:$HOME/.local/bin + ${pre-commit-check.shellHook} + ''; + }; + }); +} diff --git a/nix/default.nix b/nix/default.nix deleted file mode 100644 index 5311d174ff..0000000000 --- a/nix/default.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ sources ? import ./sources.nix }: -let - nix-pre-commit-hooks = (import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/87fb108527c7865ebee2ffe9af6154cb761ec9e0/" + "/nix/") { sources = sources; }).packages; - overlay = _self: pkgs: - let - sharedOverrides = { - overrides = _self: super: { - # we override mkDerivation here to apply the following - # tweak to each haskell package: - # if the package is broken, then we disable its check and relax the cabal bounds; - # otherwise, we leave it unchanged. - # hopefully, this could fix packages marked as broken by nix due to check failures - # or the build failure because of tight cabal bounds - mkDerivation = args: - let - broken = args.broken or false; - check = args.doCheck or true; - jailbreak = args.jailbreak or false; - in super.mkDerivation (args // { - jailbreak = if broken then true else jailbreak; - doCheck = if broken then false else check; - }); - }; - }; - ourSources = { - haskell-language-server = gitignoreSource ../.; - ghcide = gitignoreSource ../ghcide; - hls-graph = gitignoreSource ../hls-graph; - shake-bench = gitignoreSource ../shake-bench; - hie-compat = gitignoreSource ../hie-compat; - hls-plugin-api = gitignoreSource ../hls-plugin-api; - hls-test-utils = gitignoreSource ../hls-test-utils; - hls-brittany-plugin = gitignoreSource ../plugins/hls-brittany-plugin; - hls-stylish-haskell-plugin = gitignoreSource ../plugins/hls-stylish-haskell-plugin; - hls-class-plugin = gitignoreSource ../plugins/hls-class-plugin; - hls-haddock-comments-plugin = gitignoreSource ../plugins/hls-haddock-comments-plugin; - hls-eval-plugin = gitignoreSource ../plugins/hls-eval-plugin; - hls-explicit-imports-plugin = gitignoreSource ../plugins/hls-explicit-imports-plugin; - hls-refine-imports-plugin = gitignoreSource ../plugins/hls-refine-imports-plugin; - hls-hlint-plugin = gitignoreSource ../plugins/hls-hlint-plugin; - hls-retrie-plugin = gitignoreSource ../plugins/hls-retrie-plugin; - hls-splice-plugin = gitignoreSource ../plugins/hls-splice-plugin; - hls-tactics-plugin = gitignoreSource ../plugins/hls-tactics-plugin; - }; - gitignoreSource = (import sources.gitignore { inherit (pkgs) lib; }).gitignoreSource; - extended = haskellPackages: - haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides ourSources); - in - { - inherit gitignoreSource; - inherit ourSources; - - gen-hls-changelogs = with pkgs; - let myGHC = haskellPackages.ghcWithPackages (p: with p; [ github ]); - in runCommand "gen-hls-changelogs" { - passAsFile = [ "text" ]; - preferLocalBuild = true; - allowSubstitutes = false; - buildInputs = [ git myGHC ]; - } '' - dest=$out/bin/gen-hls-changelogs - mkdir -p $out/bin - echo "#!${runtimeShell}" >> $dest - echo "${myGHC}/bin/runghc ${../GenChangelogs.hs}" >> $dest - chmod +x $dest - ''; - - ourHaskell = pkgs.haskell // { - packages = pkgs.haskell.packages // { - # relax upper bounds on ghc 8.10.x versions (and skip running tests) - ghc8102 = extended (pkgs.haskell.packages.ghc8102.override sharedOverrides); - ghc8103 = extended (pkgs.haskell.packages.ghc8103.override sharedOverrides); - ghc8104 = extended (pkgs.haskell.packages.ghc8104.override sharedOverrides); - }; - }; - }; - -in (import sources.nixpkgs - { - overlays = [ overlay ]; - config = {allowBroken = true;}; - }) // { - pre-commit-check = nix-pre-commit-hooks.run { - src = ./.; - # If your hooks are intrusive, avoid running on each commit with a default_states like this: - # default_stages = ["manual" "push"]; - hooks = { - stylish-haskell.enable = true; - stylish-haskell.excludes = [ "^Setup.hs$" "test/testdata/.*$" "test/data/.*$" "^hie-compat/.*$" "^plugins/hls-tactics-plugin/.*$" ]; - }; - }; - } diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 710303ae97..0000000000 --- a/nix/sources.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "gitignore": { - "branch": "master", - "description": "Nix function for filtering local git sources", - "homepage": "", - "owner": "hercules-ci", - "repo": "gitignore", - "rev": "211907489e9f198594c0eb0ca9256a1949c9d412", - "sha256": "06j7wpvj54khw0z10fjyi31kpafkr6hi1k0di13k1xp8kywvfyx8", - "type": "tarball", - "url": "https://github.com/hercules-ci/gitignore/archive/211907489e9f198594c0eb0ca9256a1949c9d412.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e", - "sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixpkgs-unstable", - "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "homepage": "https://github.com/NixOS/nixpkgs", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6fc2b7ecc2a167ce6a6902d5417daf1fa5cac777", - "sha256": "0bcf8yr8scgk7kdjhbrvv7l1d1yv8fnb1d7k3vgnd9qrjnl2fbcf", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/6fc2b7ecc2a167ce6a6902d5417daf1fa5cac777.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 1938409ddd..0000000000 --- a/nix/sources.nix +++ /dev/null @@ -1,174 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 0ef0ad57fa..0000000000 --- a/shell.nix +++ /dev/null @@ -1,56 +0,0 @@ -# This shell.nix file is designed for use with cabal build -# It does **not** aim to replace Cabal - -# Maintaining this file: -# -# - Bump the nixpkgs version using `niv update nixpkgs` -# - Edit `ourSources` (in nix/default.nix) to update the set of local packages -# -# For more details: https://github.com/NixOS/nixpkgs/blob/20.03/pkgs/development/haskell-modules/make-package-set.nix#L256 - - -{ compiler ? "default", - withHoogle ? false, - nixpkgs ? import ./nix {} - }: - -with nixpkgs; - -let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.version; - haskellPackagesForProject = - if compiler == "default" - then ourHaskell.packages.${defaultCompiler} - else ourHaskell.packages.${compiler}; - - packages = p: with builtins; map (name: p.${name}) (attrNames ourSources); - - isSupported = compiler == "default" || compiler == defaultCompiler; -in -haskellPackagesForProject.shellFor { - inherit withHoogle; - doBenchmark = true; - packages = p: if isSupported then packages p else [p.ghc-paths]; - buildInputs = [ - gmp - zlib - ncurses - capstone - tracy - - gen-hls-changelogs - - haskellPackages.cabal-install - haskellPackages.hlint - haskellPackages.ormolu - haskellPackages.stylish-haskell - haskellPackages.opentelemetry-extra - - ]; - src = null; - shellHook = '' - export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib - export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib - export PATH=$PATH:$HOME/.local/bin - ${pre-commit-check.shellHook} - ''; -} From a687d2a25c3285685b20fc88f873d12a57fbce55 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Thu, 13 May 2021 16:25:38 +0800 Subject: [PATCH 02/13] Update github actions --- .github/workflows/nix.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 6fb91c9a0d..0d6c90d6f6 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -24,7 +24,6 @@ jobs: strategy: fail-fast: false matrix: - ghc: ['default'] os: [ubuntu-latest, macOS-latest] steps: @@ -33,13 +32,17 @@ jobs: with: submodules: true - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - uses: cachix/install-nix-action@v12 + - uses: cachix/install-nix-action@v13 with: - nix_path: nixpkgs=channel:nixos-unstable + install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install + install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' + extra_nix_config: | + experimental-features = nix-command flakes + nix_path: nixpkgs=channel:nixos-unstable - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} uses: cachix/cachix-action@v8 with: name: haskell-language-server authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - run: nix-shell --argstr compiler ${{ matrix.ghc }} --run "cabal update && cabal build" + run: nix build From 421c1fd0abf9ab41320ca0a586ae863f40dc546a Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Thu, 13 May 2021 16:31:16 +0800 Subject: [PATCH 03/13] Make pre-commit-hooks/flake-utils follows flake-utils --- flake.lock | 19 +++---------------- flake.nix | 1 + 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index eb03e1001a..25ca12a3dd 100644 --- a/flake.lock +++ b/flake.lock @@ -31,21 +31,6 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1619345332, - "narHash": "sha256-qHnQkEp1uklKTpx3MvKtY6xzgcqXDsz5nLilbbuL+3A=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "2ebf2558e5bf978c7fb8ea927dfaed8fefab2e28", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "gitignore": { "flake": false, "locked": { @@ -80,7 +65,9 @@ }, "pre-commit-hooks": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": [ + "flake-utils" + ], "nixpkgs": [ "nixpkgs" ] diff --git a/flake.nix b/flake.nix index 42a21017fd..f98b1e4c63 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,7 @@ pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; }; gitignore = { url = "github:hercules-ci/gitignore.nix"; From e32f4a85e58a97a4081cc16db739891fd4fc7958 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Thu, 13 May 2021 16:33:15 +0800 Subject: [PATCH 04/13] Update github actions --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 0d6c90d6f6..7d12cb3e85 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -32,7 +32,7 @@ jobs: with: submodules: true - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - - uses: cachix/install-nix-action@v13 + uses: cachix/install-nix-action@v13 with: install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' From 6bb7374a1ebc5f492b89f16d688aa783cbba24a1 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Thu, 13 May 2021 17:27:25 +0800 Subject: [PATCH 05/13] Update github actions --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 7d12cb3e85..c564b4fb0b 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -38,7 +38,7 @@ jobs: install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' extra_nix_config: | experimental-features = nix-command flakes - nix_path: nixpkgs=channel:nixos-unstable + nix_path: nixpkgs=channel:nixos-unstable - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} uses: cachix/cachix-action@v8 with: From 194046e0018e9c91eabdc9b41e293e320284b60c Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Fri, 14 May 2021 14:12:01 +0800 Subject: [PATCH 06/13] Support multi GHC versions --- .gitignore | 4 ++ flake.nix | 123 ++++++++++++++++++++++++++++++++--------------------- 2 files changed, 79 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 1afc2c2943..bb95f7c0a8 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,7 @@ test/testdata/**/hie.yaml # ghcide-bench *.identifierPosition /bench/example + +# nix +result +result-doc diff --git a/flake.nix b/flake.nix index f98b1e4c63..ab382d3985 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,7 @@ }; gitignoreSource = (import gitignore { inherit lib; }).gitignoreSource; + # Source directories of our packages, should be consistent with cabal.project sourceDirs = { haskell-language-server = ./.; ghcide = ./ghcide; @@ -72,20 +73,32 @@ hls-tactics-plugin = ./plugins/hls-tactics-plugin; }; + # Tweak our packages + tweaks = hself: hsuper: + with haskell.lib; { + hls-hlint-plugin = + hsuper.hls-hlint-plugin.override { hlint = hself.hlint_3_2_7; }; + hls-tactics-plugin = hsuper.hls-tactics-plugin.override { + refinery = hself.refinery_0_3_0_0; + }; + }; + hlsSources = builtins.mapAttrs (_: dir: gitignoreSource dir) sourceDirs; + + extended = hpkgs: + (hpkgs.override haskellOverrides).extend (hself: hsuper: + # disable all checks for our packages + builtins.mapAttrs (_: drv: haskell.lib.dontCheck drv) + (lib.composeExtensions + (haskell.lib.packageSourceOverrides hlsSources) tweaks hself + hsuper)); + in { inherit hlsSources; - # haskellPackages extended with hls packages - hlsHaskellPackages = with haskell.lib; - (haskellPackages.override haskellOverrides).extend (self: super: - # disable check for ghcide and hls - builtins.mapAttrs (name: drv: - if name == "ghcide" || name == "haskell-language-server" then - dontCheck drv - else - drv) (packageSourceOverrides hlsSources self super)); + # Haskell packages extended with our packages + hlsHpkgs = compiler: extended haskell.packages.${compiler}; # Support of GenChangelogs.hs gen-hls-changelogs = @@ -111,9 +124,8 @@ overlays = [ self.overlay ]; config = { allowBroken = true; }; }; - hlsPackages = p: - with builtins; - map (name: p.${name}) (attrNames pkgs.hlsSources); + + # Pre-commit hooks to run stylish-haskell pre-commit-check = pre-commit-hooks.lib.${system}.run { src = ./.; hooks = { @@ -137,47 +149,62 @@ ]; }; }; - in with pkgs; rec { - packages = with pkgs.haskell.lib; { - haskell-language-server = - justStaticExecutables hlsHaskellPackages.haskell-language-server; - ghcide = justStaticExecutables hlsHaskellPackages.ghcide; - }; + # GHC versions + ghcDefault = pkgs.hlsHpkgs ("ghc" + + pkgs.lib.replaceStrings [ "." ] [ "" ] + pkgs.haskellPackages.ghc.version); + ghc865 = pkgs.hlsHpkgs "ghc865"; + ghc884 = pkgs.hlsHpkgs "ghc884"; + ghc8104 = pkgs.hlsHpkgs "ghc8104"; + ghc901 = pkgs.hlsHpkgs "ghc901"; - apps = { - haskell-language-server = flake-utils.lib.mkApp { - drv = packages.haskell-language-server; - exePath = "/bin/haskell-language-server"; - }; - ghcide = flake-utils.lib.mkApp { - drv = packages.ghcide; - exePath = "/bin/ghcide"; + # Create a development shell of hls project + # See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319 + mkDevShell = hpkgs: + with pkgs; + hpkgs.shellFor { + doBenchmark = true; + packages = p: + with builtins; + map (name: p.${name}) (attrNames pkgs.hlsSources); + buildInputs = [ gmp zlib ncurses capstone tracy gen-hls-changelogs ] + ++ (with haskellPackages; [ + cabal-install + hlint + ormolu + stylish-haskell + opentelemetry-extra + ]); + + src = null; + shellHook = '' + export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib + export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib + export PATH=$PATH:$HOME/.local/bin + ${pre-commit-check.shellHook} + ''; }; + in with pkgs; rec { + + packages = { + # dev shell + haskell-language-server-dev = mkDevShell ghcDefault; + haskell-language-server-865-dev = mkDevShell ghc865; + haskell-language-server-884-dev = mkDevShell ghc884; + haskell-language-server-8104-dev = mkDevShell ghc8104; + haskell-language-server-901-dev = mkDevShell ghc901; + + # hls package + haskell-language-server = ghcDefault.haskell-language-server; + haskell-language-server-865 = ghc865.haskell-language-server; + haskell-language-server-884 = ghc884.haskell-language-server; + haskell-language-server-8104 = ghc8104.haskell-language-server; + haskell-language-server-901 = ghc901.haskell-language-server; }; defaultPackage = packages.haskell-language-server; - defaultApp = apps.haskell-language-server; - - devShell = hlsHaskellPackages.shellFor { - doBenchmark = true; - packages = hlsPackages; - buildInputs = [ gmp zlib ncurses capstone tracy gen-hls-changelogs ] - ++ (with haskellPackages; [ - cabal-install - hlint - ormolu - stylish-haskell - opentelemetry-extra - ]); - - src = null; - shellHook = '' - export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib - export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib - export PATH=$PATH:$HOME/.local/bin - ${pre-commit-check.shellHook} - ''; - }; + + devShell = packages.haskell-language-server-dev; }); } From b1d70fffb02d10d46de90bd4b40798045b108156 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Fri, 14 May 2021 14:41:14 +0800 Subject: [PATCH 07/13] Update github actions --- .github/workflows/nix.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index c564b4fb0b..c936ed3c4c 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -46,3 +46,7 @@ jobs: authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} run: nix build + - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + run: nix develop --profile dev && cachix push haskell-language-server dev + - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server From b8227ba62cc8ea82385e9bfe304211004ab2f71b Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Fri, 14 May 2021 15:09:08 +0800 Subject: [PATCH 08/13] Copy postInstall from nixpkgs --- flake.nix | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index ab382d3985..da42eb330a 100644 --- a/flake.nix +++ b/flake.nix @@ -185,6 +185,20 @@ ${pre-commit-check.shellHook} ''; }; + # Create a hls executable + # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16 + mkExe = hpkgs: + with pkgs.haskell.lib; + justStaticExecutables (overrideCabal hpkgs.haskell-language-server + (_: { + postInstall = '' + remove-references-to -t ${hpkgs.ghc} $out/bin/haskell-language-server + remove-references-to -t ${hpkgs.shake.data} $out/bin/haskell-language-server + remove-references-to -t ${hpkgs.js-jquery.data} $out/bin/haskell-language-server + remove-references-to -t ${hpkgs.js-dgtable.data} $out/bin/haskell-language-server + remove-references-to -t ${hpkgs.js-flot.data} $out/bin/haskell-language-server + ''; + })); in with pkgs; rec { packages = { @@ -196,11 +210,11 @@ haskell-language-server-901-dev = mkDevShell ghc901; # hls package - haskell-language-server = ghcDefault.haskell-language-server; - haskell-language-server-865 = ghc865.haskell-language-server; - haskell-language-server-884 = ghc884.haskell-language-server; - haskell-language-server-8104 = ghc8104.haskell-language-server; - haskell-language-server-901 = ghc901.haskell-language-server; + haskell-language-server = mkExe ghcDefault; + haskell-language-server-865 = mkExe ghc865; + haskell-language-server-884 = mkExe ghc884; + haskell-language-server-8104 = mkExe ghc8104; + haskell-language-server-901 = mkExe ghc901; }; defaultPackage = packages.haskell-language-server; From ee9f5e8f6c2c5dcbd0e2765423e6247d5dcaea66 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Fri, 14 May 2021 15:26:39 +0800 Subject: [PATCH 09/13] Remove invalid ghc865 --- flake.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/flake.nix b/flake.nix index da42eb330a..73641f3d36 100644 --- a/flake.nix +++ b/flake.nix @@ -154,7 +154,6 @@ ghcDefault = pkgs.hlsHpkgs ("ghc" + pkgs.lib.replaceStrings [ "." ] [ "" ] pkgs.haskellPackages.ghc.version); - ghc865 = pkgs.hlsHpkgs "ghc865"; ghc884 = pkgs.hlsHpkgs "ghc884"; ghc8104 = pkgs.hlsHpkgs "ghc8104"; ghc901 = pkgs.hlsHpkgs "ghc901"; @@ -204,14 +203,12 @@ packages = { # dev shell haskell-language-server-dev = mkDevShell ghcDefault; - haskell-language-server-865-dev = mkDevShell ghc865; haskell-language-server-884-dev = mkDevShell ghc884; haskell-language-server-8104-dev = mkDevShell ghc8104; haskell-language-server-901-dev = mkDevShell ghc901; # hls package haskell-language-server = mkExe ghcDefault; - haskell-language-server-865 = mkExe ghc865; haskell-language-server-884 = mkExe ghc884; haskell-language-server-8104 = mkExe ghc8104; haskell-language-server-901 = mkExe ghc901; From 450c91fc6eb369e9298649866ce9ca3d0a1612da Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 16 May 2021 20:33:03 +0800 Subject: [PATCH 10/13] Update README --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 23e2940d14..c1f084f7b3 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ background](https://neilmitchell.blogspot.com/2020/01/one-haskell-ide-to-rule-th - [Using Cabal](#using-cabal) - [Using Stack](#using-stack) - [Using Nix](#using-nix) + - [Flakes support](#flakes-support) - [Introduction tutorial](#introduction-tutorial) - [Test your hacked HLS in your editor](#test-your-hacked-hls-in-your-editor) - [Adding support for a new editor](#adding-support-for-a-new-editor) @@ -807,8 +808,25 @@ $ cabal update $ cabal build ``` +##### Flakes support + +If you are using nix 2.4 style command (enabled by `experimental-features = nix-command`), +you can use `nix develop` instead of `nix-shell` to enter the development shell. To enter the shell with specific GHC versions: + +* `nix develop` or `nix develop #haskell-language-server-dev` - default GHC version +* `nix develop #haskell-language-server-8104-dev` - GHC 8.10.4 +* `nix develop #haskell-language-server-884-dev` - GHC 8.8.4 +* `nix develop #haskell-language-server-901-dev` - GHC 9.0.1 + If you are looking for a Nix expression to create haskell-language-server binaries, see https://github.com/haskell/haskell-language-server/issues/122 +To create binaries: + +* `nix build` or `nix build #haskell-language-server` - default GHC version +* `nix build #haskell-language-server-8104` - GHC 8.10.4 +* `nix build #haskell-language-server-884` - GHC 8.8.4 +* `nix build #haskell-language-server-901` - GHC 9.0.1 + #### Introduction tutorial Pepeiborra [wrote an tutorial](https://github.com/pepeiborra/hls-tutorial) on writing a plugin in HLS. From bd37c8d93e795e9b7e6a0675ad2f179d6887d3f4 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 16 May 2021 20:33:41 +0800 Subject: [PATCH 11/13] Use nixpkgs-unstable --- default.nix | 2 ++ flake.lock | 14 +++++++------- flake.nix | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/default.nix b/default.nix index f8a169dc5b..d87fd23886 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,5 @@ +# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat +# See flake.nix for details (import ( let lock = builtins.fromJSON (builtins.readFile ./flake.lock); diff --git a/flake.lock b/flake.lock index 25ca12a3dd..d78e7a62f6 100644 --- a/flake.lock +++ b/flake.lock @@ -49,16 +49,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1620830445, - "narHash": "sha256-CE4R4OlOcTUATacRZMo5hyS9n47U6A0G5SASNoo4TbI=", + "lastModified": 1621151593, + "narHash": "sha256-wC8kXOdXwI3YyAeqv6LKZCmjqnjXovHI1UzOrma4kWA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "65d6153aec85c8cb46023f0a7248628f423ca4ee", + "rev": "f2c015d33d1b36070c64b726662db42c6c87b7be", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1619976063, - "narHash": "sha256-2tjVP95+qR1UzL8/UeV/xRJu7S2fRB7rf7enZedbrik=", + "lastModified": 1620897287, + "narHash": "sha256-UU0SysjA5h1NMCQhA0lKaeqy9gCBqpq/5dW1BWLbIXo=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "09fb9e425111878b58223852e87ed85e8a189e0d", + "rev": "40a51af82c1181b9dea3526c4124eee077e30213", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8e64ecf255..453d5406b7 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ description = "haskell language server flake"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; @@ -62,6 +62,7 @@ hls-test-utils = ./hls-test-utils; hls-brittany-plugin = ./plugins/hls-brittany-plugin; hls-stylish-haskell-plugin = ./plugins/hls-stylish-haskell-plugin; + hls-fourmolu-plugin = ./plugins/hls-fourmolu-plugin; hls-class-plugin = ./plugins/hls-class-plugin; hls-haddock-comments-plugin = ./plugins/hls-haddock-comments-plugin; hls-eval-plugin = ./plugins/hls-eval-plugin; From a2b60a6a87a8302360748e28de163f2ca3fa59b8 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Tue, 18 May 2021 19:28:45 +0800 Subject: [PATCH 12/13] Update README --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c1f084f7b3..ab199ea696 100644 --- a/README.md +++ b/README.md @@ -813,19 +813,21 @@ $ cabal build If you are using nix 2.4 style command (enabled by `experimental-features = nix-command`), you can use `nix develop` instead of `nix-shell` to enter the development shell. To enter the shell with specific GHC versions: -* `nix develop` or `nix develop #haskell-language-server-dev` - default GHC version -* `nix develop #haskell-language-server-8104-dev` - GHC 8.10.4 -* `nix develop #haskell-language-server-884-dev` - GHC 8.8.4 -* `nix develop #haskell-language-server-901-dev` - GHC 9.0.1 +* `nix develop` or `nix develop .#haskell-language-server-dev` - default GHC version +* `nix develop .#haskell-language-server-8104-dev` - GHC 8.10.4 +* `nix develop .#haskell-language-server-884-dev` - GHC 8.8.4 +* `nix develop .#haskell-language-server-901-dev` - GHC 9.0.1 If you are looking for a Nix expression to create haskell-language-server binaries, see https://github.com/haskell/haskell-language-server/issues/122 To create binaries: -* `nix build` or `nix build #haskell-language-server` - default GHC version -* `nix build #haskell-language-server-8104` - GHC 8.10.4 -* `nix build #haskell-language-server-884` - GHC 8.8.4 -* `nix build #haskell-language-server-901` - GHC 9.0.1 +* `nix build` or `nix build .#haskell-language-server` - default GHC version +* `nix build .#haskell-language-server-8104` - GHC 8.10.4 +* `nix build .#haskell-language-server-884` - GHC 8.8.4 +* `nix build .#haskell-language-server-901` - GHC 9.0.1 + +GHC 8.6.5 is not supported here because `nixpkgs-unstable` no longer maintains the corresponding packages set. #### Introduction tutorial From f94725a562945c27e61b176a482d7f29c2fa02fd Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Tue, 18 May 2021 20:10:26 +0800 Subject: [PATCH 13/13] Add plugins automatically --- flake.nix | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/flake.nix b/flake.nix index 0ef66e27a3..95e7a83693 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,12 @@ }; gitignoreSource = (import gitignore { inherit lib; }).gitignoreSource; + # List all subdirectories under `./plugins`, except `./plugins/default` + pluginsDir = ./plugins; + pluginSourceDirs = builtins.removeAttrs (lib.mapAttrs' + (name: _: lib.nameValuePair name (pluginsDir + ("/" + name))) + (builtins.readDir pluginsDir)) [ "default" ]; + # Source directories of our packages, should be consistent with cabal.project sourceDirs = { haskell-language-server = ./.; @@ -60,23 +66,7 @@ hie-compat = ./hie-compat; hls-plugin-api = ./hls-plugin-api; hls-test-utils = ./hls-test-utils; - hls-brittany-plugin = ./plugins/hls-brittany-plugin; - hls-stylish-haskell-plugin = ./plugins/hls-stylish-haskell-plugin; - hls-fourmolu-plugin = ./plugins/hls-fourmolu-plugin; - hls-ormolu-plugin = ./plugins/hls-ormolu-plugin; - hls-class-plugin = ./plugins/hls-class-plugin; - hls-haddock-comments-plugin = ./plugins/hls-haddock-comments-plugin; - hls-eval-plugin = ./plugins/hls-eval-plugin; - hls-explicit-imports-plugin = ./plugins/hls-explicit-imports-plugin; - hls-refine-imports-plugin = ./plugins/hls-refine-imports-plugin; - hls-hlint-plugin = ./plugins/hls-hlint-plugin; - hls-retrie-plugin = ./plugins/hls-retrie-plugin; - hls-splice-plugin = ./plugins/hls-splice-plugin; - hls-tactics-plugin = ./plugins/hls-tactics-plugin; - hls-floskell-plugin = ./plugins/hls-floskell-plugin; - hls-pragmas-plugin = ./plugins/hls-pragmas-plugin; - hls-module-name-plugin = ./plugins/hls-module-name-plugin; - }; + } // pluginSourceDirs; # Tweak our packages tweaks = hself: hsuper: