diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 064d8f59f3..59d0419342 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -18,7 +18,6 @@ jobs: runs-on: ubuntu-latest outputs: should_skip_develop: ${{ steps.skip_check.outputs.should_skip }} - should_skip_build: ${{ steps.skip_check_no_nix.outputs.should_skip }} steps: - id: skip_check uses: fkirc/skip-duplicate-actions@v5.3.1 @@ -35,11 +34,6 @@ jobs: , ".gitlab-ci.yaml" , ".gitlab/**" ]' - - id: skip_check_no_nix - uses: fkirc/skip-duplicate-actions@v5.3.1 - with: - cancel_others: false - paths: '[ "**.nix" ]' # Enter the development shell and run `cabal build` develop: @@ -63,66 +57,15 @@ jobs: - uses: cachix/cachix-action@v12 with: name: haskell-language-server - # Disable pushing, we will do that in job `build` - skipPush: true + authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - run: | nix develop --print-build-logs --command cabal update nix develop --print-build-logs --command cabal build - # Build and then push HLS binaries with developmet shell to cachix - # This job runs when - # 1. PRs are merged to master (runs on master) - # 2. Nix files are changed (runs on PR) - build: - needs: pre_job - runs-on: ${{ matrix.os }} - env: - HAS_TOKEN: ${{ secrets.HLS_CACHIX_AUTH_TOKEN != '' }} - if: (needs.pre_job.outputs.should_skip_build != 'true' && needs.pre_job.outputs.should_skip_pr != 'true') || (github.repository_owner == 'haskell' && github.ref == 'refs/heads/master') - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macOS-latest] - - steps: - - uses: actions/checkout@v3 - - - uses: cachix/install-nix-action@v23 - with: - extra_nix_config: | - experimental-features = nix-command flakes - nix_path: nixpkgs=channel:nixos-unstable - - uses: cachix/cachix-action@v12 - with: - name: haskell-language-server - authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - - name: Build development shell - run: nix develop --print-build-logs --profile dev - - name: Build all development shell (without nix dependencies) - run: nix develop --print-build-logs .#all-simple-dev-shells --profile dev - # We only build nix dev shell for current GHC version because some are - # failing with different GHC version on darwin. - - name: Build development shell with nix dependencies for current GHC version - if: matrix.os == 'macOS-latest' - run: nix develop --print-build-logs .#haskell-language-server-dev-nix --profile dev - - name: Build development shells with nix dependencies - if: matrix.os == 'ubuntu-latest' - run: nix develop --print-build-logs .#all-nix-dev-shells --profile dev - - name: Push development shell - if: ${{ env.HAS_TOKEN == 'true' }} - run: cachix push haskell-language-server dev - - name: Build binaries - run: nix build --print-build-logs - - name: Build all binaries - run: nix build --print-build-logs .#all-haskell-language-server - - name: Push binaries - if: ${{ env.HAS_TOKEN == 'true' }} - run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server - nix_post_job: if: always() runs-on: ubuntu-latest - needs: [pre_job, develop, build] + needs: [pre_job, develop] steps: - run: | echo "jobs info: ${{ toJSON(needs) }}" diff --git a/configuration-ghc-90.nix b/configuration-ghc-90.nix deleted file mode 100644 index 8152f110fa..0000000000 --- a/configuration-ghc-90.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ pkgs, inputs }: - -let - disabledPlugins = [ "hls-stylish-haskell-plugin" ]; - - hpkgsOverride = hself: hsuper: - with pkgs.haskell.lib; - { - hlsDisabledPlugins = disabledPlugins; - # YOLO - mkDerivation = args: - hsuper.mkDerivation (args // { - jailbreak = true; - doCheck = false; - }); - } // (builtins.mapAttrs (_: drv: disableLibraryProfiling drv) { - Cabal = hself.Cabal_3_6_3_0; - - Cabal-syntax = hself.Cabal-syntax_3_8_1_0; - - ghc-lib-parser = hsuper.ghc-lib-parser_9_4_5_20230430; - - lsp = hself.callCabal2nix "lsp" inputs.lsp {}; - lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {}; - lsp-test = hself.callCabal2nix "lsp-test" inputs.lsp-test {}; - - hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-35 {}) "-fghc-lib"; - - hls-hlint-plugin = hself.callCabal2nixWithOptions "hls-hlint-plugin" - ./plugins/hls-hlint-plugin - (pkgs.lib.concatStringsSep " " [ "-fhlint34" "-fghc-lib" ]) { }; - - OneTuple = overrideCabal hsuper.OneTuple (drv: { - libraryHaskellDepends = drv.libraryHaskellDepends or [] ++ [ - hself.base-orphans - ]; - }); - - ormolu = hself.callCabal2nix "ormolu" inputs.ormolu-052 {}; - - fourmolu = hsuper.fourmolu_0_10_1_0; - - # Re-generate HLS drv excluding some plugins - haskell-language-server = - hself.callCabal2nixWithOptions "haskell-language-server" ./. - (pkgs.lib.concatStringsSep " " [ "-f-stylishhaskell" ]) - { }; - - }); -in { - inherit disabledPlugins; - tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride; -} diff --git a/configuration-ghc-92.nix b/configuration-ghc-92.nix deleted file mode 100644 index 01402a6497..0000000000 --- a/configuration-ghc-92.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ pkgs, inputs }: - -let - disabledPlugins = [ - # That one is not technically a plugin, but by putting it in this list, we - # get it removed from the top level list of requirement and it is not pull - # in the nix shell. - "shake-bench" - ]; - - hpkgsOverride = hself: hsuper: - with pkgs.haskell.lib; - { - hlsDisabledPlugins = disabledPlugins; - # YOLO - mkDerivation = args: - hsuper.mkDerivation (args // { - jailbreak = true; - doCheck = false; - }); - } // (builtins.mapAttrs (_: drv: disableLibraryProfiling drv) { - apply-refact = hsuper.apply-refact_0_13_0_0; - - Cabal-syntax = hself.Cabal-syntax_3_8_1_0; - - ghc-lib-parser = hsuper.ghc-lib-parser_9_4_5_20230430; - - hlint = appendConfigureFlag (hself.callCabal2nix "hlint" inputs.hlint-35 {}) "-fghc-lib"; - - ormolu = hself.callCabal2nix "ormolu" inputs.ormolu-052 {}; - - fourmolu = hsuper.fourmolu_0_10_1_0; - - stylish-haskell = hsuper.stylish-haskell_0_14_4_0; - - hie-bios = hself.callCabal2nix "hie-bios" inputs.haskell-hie-bios { }; - - implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.haskell-implicit-hie-cradle { }; - - lsp = hself.callCabal2nix "lsp" inputs.lsp {}; - lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {}; - lsp-test = dontCheck (hself.callCabal2nix "lsp-test" inputs.lsp-test {}); - - # Re-generate HLS drv excluding some plugins - haskell-language-server = - hself.callCabal2nixWithOptions "haskell-language-server" ./. - (pkgs.lib.concatStringsSep " " [ "-fpedantic" "-f-hlint" ]) { }; - - }); -in { - inherit disabledPlugins; - tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride; -} diff --git a/configuration-ghc-94.nix b/configuration-ghc-94.nix deleted file mode 100644 index e561496955..0000000000 --- a/configuration-ghc-94.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ pkgs, inputs }: - -let - disabledPlugins = [ - # That one is not technically a plugin, but by putting it in this list, we - # get it removed from the top level list of requirement and it is not pull - # in the nix shell. - "shake-bench" - ]; - - hpkgsOverride = hself: hsuper: - with pkgs.haskell.lib; - { - hlsDisabledPlugins = disabledPlugins; - } // (builtins.mapAttrs (_: drv: disableLibraryProfiling drv) { - apply-refact = hsuper.apply-refact_0_13_0_0; - - fourmolu = dontCheck (hself.callCabal2nix "fourmolu" inputs.fourmolu-011 {}); - - stylish-haskell = appendConfigureFlag hsuper.stylish-haskell "-fghc-lib"; - - lsp = hself.callCabal2nix "lsp" inputs.lsp {}; - lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {}; - lsp-test = dontCheck (hself.callCabal2nix "lsp-test" inputs.lsp-test {}); - - # Re-generate HLS drv excluding some plugins - haskell-language-server = - hself.callCabal2nixWithOptions "haskell-language-server" ./. - # Pedantic cannot be used due to -Werror=unused-top-binds - # Check must be disabled due to some missing required files - (pkgs.lib.concatStringsSep " " [ "--no-check" "-f-pedantic" "-f-hlint" ]) { }; - }); -in { - inherit disabledPlugins; - tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride; -} diff --git a/configuration-ghc-96.nix b/configuration-ghc-96.nix deleted file mode 100644 index 744e7047d1..0000000000 --- a/configuration-ghc-96.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ pkgs, inputs }: - -let - disabledPlugins = [ - # That one is not technically a plugin, but by putting it in this list, we - # get it removed from the top level list of requirement and it is not pull - # in the nix shell. - "shake-bench" - "hls-retrie-plugin" - "hls-splice-plugin" - "hls-class-plugin" - "hls-rename-plugin" - "hls-gadt-plugin" - "hls-refactor-plugin" - ]; - - hpkgsOverride = hself: hsuper: - with pkgs.haskell.lib; - { - hlsDisabledPlugins = disabledPlugins; - - # Override for all derivation - # If they are considered as broken, we just disable jailbreak and hope for the best - mkDerivation = args: - hsuper.mkDerivation (args // - { - jailbreak = true; - broken = false; - doCheck = false; - }); - apply-refact = hsuper.apply-refact_0_13_0_0; - tagged = hsuper.tagged_0_8_7; - primitive = hsuper.primitive_0_8_0_0; - MonadRandom = hsuper.MonadRandom_0_6; - hie-bios = hself.callCabal2nix "hie-bios" inputs.haskell-hie-bios { }; - hlint = hself.callCabal2nix "hlint" inputs.hlint-36 {}; - implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.haskell-implicit-hie-cradle { }; - - fourmolu = hself.callCabal2nix "fourmolu" inputs.fourmolu-012 {}; - - ghc-lib-parser-ex = hsuper.ghc-lib-parser-ex_9_6_0_0; - - ormolu = hself.callCabal2nix "ormolu" inputs.ormolu-07 {}; - - stylish-haskell = hself.callCabal2nix "stylish-haskell" inputs.stylish-haskell-0145 {}; - - lsp = hself.callCabal2nix "lsp" inputs.lsp {}; - lsp-types = hself.callCabal2nix "lsp-types" inputs.lsp-types {}; - lsp-test = dontCheck (hself.callCabal2nix "lsp-test" inputs.lsp-test {}); - - # Re-generate HLS drv excluding some plugins - haskell-language-server = - hself.callCabal2nixWithOptions "haskell-language-server" ./. - # Pedantic cannot be used due to -Werror=unused-top-binds - # Check must be disabled due to some missing required files - (pkgs.lib.concatStringsSep " " [ "--no-check" "-f-pedantic" "-f-hlint" "-f-refactor" "-f-retrie" "-f-class" "-f-gadt" "-f-splice" "-f-rename" ]) { }; - }; -in { - inherit disabledPlugins; - tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride; -} diff --git a/docs/contributing/contributing.md b/docs/contributing/contributing.md index 8f4aaaceb9..096ae8b826 100644 --- a/docs/contributing/contributing.md +++ b/docs/contributing/contributing.md @@ -50,16 +50,11 @@ $ 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-901-dev` - GHC 9.0.1 (substitute GHC version as appropriate) +* `nix develop` - default GHC version +* `nix develop .#shell-ghc90` - GHC 9.0.1 (substitute GHC version as appropriate) 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-901` - GHC 9.0.1 (substitute GHC version as appropriate) - ## Testing The tests make use of the [Tasty](https://github.com/feuerbach/tasty) test framework. diff --git a/flake.lock b/flake.lock index e64c8ea36e..dc8f1eb9ab 100644 --- a/flake.lock +++ b/flake.lock @@ -34,146 +34,13 @@ "type": "github" } }, - "fourmolu-011": { - "flake": false, - "locked": { - "narHash": "sha256-g/yDZXeLCHq/iXoZTaTYSb8l9CMny3AKsRQgWElagZI=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.11.0.0/fourmolu-0.11.0.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.11.0.0/fourmolu-0.11.0.0.tar.gz" - } - }, - "fourmolu-012": { - "flake": false, - "locked": { - "narHash": "sha256-yru8ls67DMM6WSeVU6xDmmwa48I8S9CUv9NBaxSQ29M=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.12.0.0/fourmolu-0.12.0.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/fourmolu-0.12.0.0/fourmolu-0.12.0.0.tar.gz" - } - }, - "gitignore": { - "flake": false, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "haskell-hie-bios": { - "flake": false, - "locked": { - "lastModified": 1686930638, - "narHash": "sha256-gfcxxHtZ2jUsiKNn/O4jEkfWF/2H04aTnaIvPDbtNlQ=", - "owner": "haskell", - "repo": "hie-bios", - "rev": "3d4fadfb0dc44cb287db9897ecfb503899d33513", - "type": "github" - }, - "original": { - "owner": "haskell", - "repo": "hie-bios", - "type": "github" - } - }, - "haskell-implicit-hie-cradle": { - "flake": false, - "locked": { - "lastModified": 1686495518, - "narHash": "sha256-OAe+zOkMZuoTfVEMnxnCT1cmPgRF/riAR8nVdomnwxo=", - "owner": "smunix", - "repo": "implicit-hie-cradle", - "rev": "d6aa00355898469af56cfd5e62f7fc8bd9959ded", - "type": "github" - }, - "original": { - "owner": "smunix", - "ref": "smunix-patch-hls-0.5-1", - "repo": "implicit-hie-cradle", - "type": "github" - } - }, - "hlint-35": { - "flake": false, - "locked": { - "narHash": "sha256-qQNUlQQnahUGEO92Lm0RwjTGBGr2Yaw0KRuFRMoc5No=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz" - } - }, - "hlint-36": { - "flake": false, - "locked": { - "narHash": "sha256-fH4RYnWeuBqJI5d3Ba+Xs0BxYr0IYFH1OWO3k2iHGlU=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.6.1/hlint-3.6.1.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/hlint-3.6.1/hlint-3.6.1.tar.gz" - } - }, - "lsp": { - "flake": false, - "locked": { - "narHash": "sha256-HcEfdYUrCHufEa+10M2wESjnK41xM/msd+t6r6JwQO0=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/lsp-2.2.0.0/lsp-2.2.0.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/lsp-2.2.0.0/lsp-2.2.0.0.tar.gz" - } - }, - "lsp-test": { - "flake": false, - "locked": { - "narHash": "sha256-E1D3X2+I9ZTZLpHDEDTXexQFYpyG5byOFRIvRTeBsn8=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/lsp-test-0.16.0.0/lsp-test-0.16.0.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/lsp-test-0.16.0.0/lsp-test-0.16.0.0.tar.gz" - } - }, - "lsp-types": { - "flake": false, - "locked": { - "narHash": "sha256-Oa5HuKdsdTSQUKtuSt06zVAq19Qxq5IJZObrnPwlB6s=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/lsp-types-2.0.2.0/lsp-types-2.0.2.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/lsp-types-2.0.2.0/lsp-types-2.0.2.0.tar.gz" - } - }, "nixpkgs": { "locked": { - "lastModified": 1686874404, - "narHash": "sha256-u2Ss8z+sGaVlKtq7sCovQ8WvXY+OoXJmY1zmyxITiaY=", + "lastModified": 1694477507, + "narHash": "sha256-RtUmM5s6vnx1W+tnrGzXArVScJ/IoGmqCLM177k5O5A=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "efc10371d5c5b8d2d58bab6c1100753efacfe550", + "rev": "ff303118b2ec262eb342eab88ae79318fac66d52", "type": "github" }, "original": { @@ -183,60 +50,11 @@ "type": "github" } }, - "ormolu-052": { - "flake": false, - "locked": { - "narHash": "sha256-H7eqId488RBRxcf7flgJefAZmRgFJASJva+Oy7GG4q4=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/ormolu-0.5.2.0/ormolu-0.5.2.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/ormolu-0.5.2.0/ormolu-0.5.2.0.tar.gz" - } - }, - "ormolu-07": { - "flake": false, - "locked": { - "narHash": "sha256-5M5gNzSvsiQH1+0oexRByzf5EIET+0BFwR4fLIr2P7g=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/ormolu-0.7.1.0/ormolu-0.7.1.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/ormolu-0.7.1.0/ormolu-0.7.1.0.tar.gz" - } - }, "root": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "fourmolu-011": "fourmolu-011", - "fourmolu-012": "fourmolu-012", - "gitignore": "gitignore", - "haskell-hie-bios": "haskell-hie-bios", - "haskell-implicit-hie-cradle": "haskell-implicit-hie-cradle", - "hlint-35": "hlint-35", - "hlint-36": "hlint-36", - "lsp": "lsp", - "lsp-test": "lsp-test", - "lsp-types": "lsp-types", - "nixpkgs": "nixpkgs", - "ormolu-052": "ormolu-052", - "ormolu-07": "ormolu-07", - "stylish-haskell-0145": "stylish-haskell-0145" - } - }, - "stylish-haskell-0145": { - "flake": false, - "locked": { - "narHash": "sha256-EE7RFQ6q4Ek8daRgOpNMGepYLa9o8cM4OLjTNUSHQf0=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/stylish-haskell-0.14.5.0/stylish-haskell-0.14.5.0.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/stylish-haskell-0.14.5.0/stylish-haskell-0.14.5.0.tar.gz" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index b68f43c2d1..f0f92aa476 100644 --- a/flake.nix +++ b/flake.nix @@ -1,231 +1,26 @@ -# 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"; + description = "haskell-language-server development flake"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/haskell-updates"; + flake-utils.url = "github:numtide/flake-utils"; + # for default.nix flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; - flake-utils.url = "github:numtide/flake-utils"; - gitignore = { - url = "github:hercules-ci/gitignore.nix"; - flake = false; - }; - - # List of hackage dependencies - hlint-35 = { - url = "https://hackage.haskell.org/package/hlint-3.5/hlint-3.5.tar.gz"; - flake = false; - }; - hlint-36 = { - url = "https://hackage.haskell.org/package/hlint-3.6.1/hlint-3.6.1.tar.gz"; - flake = false; - }; - fourmolu-011 = { - url = "https://hackage.haskell.org/package/fourmolu-0.11.0.0/fourmolu-0.11.0.0.tar.gz"; - flake = false; - }; - fourmolu-012 = { - url = "https://hackage.haskell.org/package/fourmolu-0.12.0.0/fourmolu-0.12.0.0.tar.gz"; - flake = false; - }; - ormolu-052 = { - url = "https://hackage.haskell.org/package/ormolu-0.5.2.0/ormolu-0.5.2.0.tar.gz"; - flake = false; - }; - ormolu-07 = { - url = "https://hackage.haskell.org/package/ormolu-0.7.1.0/ormolu-0.7.1.0.tar.gz"; - flake = false; - }; - stylish-haskell-0145 = { - url = "https://hackage.haskell.org/package/stylish-haskell-0.14.5.0/stylish-haskell-0.14.5.0.tar.gz"; - flake = false; - }; - - # not sure if this is the correct way to get lsp* packages in - lsp = { - url = "https://hackage.haskell.org/package/lsp-2.2.0.0/lsp-2.2.0.0.tar.gz"; - flake = false; - }; - lsp-types = { - url = "https://hackage.haskell.org/package/lsp-types-2.0.2.0/lsp-types-2.0.2.0.tar.gz"; - flake = false; - }; - lsp-test = { - url = "https://hackage.haskell.org/package/lsp-test-0.16.0.0/lsp-test-0.16.0.0.tar.gz"; - flake = false; - }; - - haskell-hie-bios = { - url = "github:haskell/hie-bios"; - flake = false; - }; - # smunix: github:haskell/hie-bios defines - # 'CabalType :: Maybe String -> Maybe FilePath -> CabalType' - # while the original githcom:Avi-D-coder/hie-bios still has this: - # 'CabalType :: Maybe String -> CabalType' - # We need a patched version of implicit-hie-cradle that works with hls, so I've created - # the repository below. Obviously, this is not sustainable as it adds more technical debt. - # We need a better strategy to streamline changes required by HLS from other hie-bios related - # packages. - # See details here: https://github.com/Avi-D-coder/implicit-hie-cradle/compare/master...smunix:implicit-hie-cradle:smunix-patch-hls-1?expand=1 - # - haskell-implicit-hie-cradle = { - url = "github:smunix/implicit-hie-cradle?ref=smunix-patch-hls-0.5-1"; - flake = false; - }; }; - outputs = - inputs@{ self, nixpkgs, flake-compat, flake-utils, gitignore, ... }: - { - overlays.default = final: prev: - with prev; - let - haskellOverrides = 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; - # Library profiling is disabled as it causes long compilation time - # on our CI jobs. Nix users are free tor revert this anytime. - enableLibraryProfiling = false; - doHaddock = false; - }); - }; - 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 = ./.; - ghcide = ./ghcide; - ghcide-bench = ./ghcide-bench; - hls-graph = ./hls-graph; - shake-bench = ./shake-bench; - hie-compat = ./hie-compat; - hls-plugin-api = ./hls-plugin-api; - hls-test-utils = ./hls-test-utils; - ghcide-test-utils = ./ghcide/test; - } // pluginSourceDirs; - - # Tweak our packages - # Don't use `callHackage`, it requires us to override `all-cabal-hashes` - tweaks = hself: hsuper: - with haskell.lib; { - # Patches don't apply - github = overrideCabal hsuper.github (drv: { patches = []; }); - - # https://github.com/NixOS/nixpkgs/issues/140774 - ormolu = - if final.system == "aarch64-darwin" - then overrideCabal hsuper.ormolu (_: { enableSeparateBinOutput = false; }) - else hsuper.ormolu; - }; - - hlsSources = - builtins.mapAttrs (_: dir: gitignoreSource dir) sourceDirs; - - # Disable tests, but only for the packages mentioned in this overlay - # - # We don't want to disable tests for *all* packages - dontCheck = overlay: hself: hsuper: - builtins.mapAttrs (_: haskell.lib.dontCheck) - (overlay hself hsuper); - - applyHaskellOverlays = overlays: hpkgs: hpkgs.override (old: { - overrides = - lib.fold - lib.composeExtensions - (old.overrides or (_: _: { })) - overlays; - }); - - extended = forHlsCI: - applyHaskellOverlays - (prev.lib.optional forHlsCI haskellOverrides - ++ [ (dontCheck (haskell.lib.packageSourceOverrides hlsSources)) - tweaks - ] - ); - in { - inherit hlsSources; - - # Haskell packages extended with our packages - hlsHpkgs = compiler: extended true haskell.packages.${compiler}; - # Haskell packages extended with our packages; reusing the nixpkgs set as much as possible - hlsHpkgsNixpkgs = compiler: extended false haskell.packages.${compiler}; - - # Support of GenChangelogs.hs - gen-hls-changelogs = hpkgs: - let myGHC = hpkgs.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" "aarch64-linux" "aarch64-darwin" ]) + outputs = + inputs@{ self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ] (system: let pkgs = import nixpkgs { inherit system; - overlays = [ self.overlays.default ]; config = { allowBroken = true; }; }; - ghc90Config = (import ./configuration-ghc-90.nix) { inherit pkgs inputs; }; - ghc92Config = (import ./configuration-ghc-92.nix) { inherit pkgs inputs; }; - ghc94Config = (import ./configuration-ghc-94.nix) { inherit pkgs inputs; }; - ghc96Config = (import ./configuration-ghc-96.nix) { inherit pkgs inputs; }; - - # GHC versions - # While HLS still works fine with 8.10 GHCs, we only support the versions that are cached - # by upstream nixpkgs, which now only includes GHC version 9+ - supportedGHCs = let - ghcVersion = "ghc" + (builtins.concatStringsSep "" (pkgs.lib.lists.init (builtins.splitVersion pkgs.haskellPackages.ghc.version))); - cases = { - ghc90 = ghc90Config.tweakHpkgs (pkgs.hlsHpkgs "ghc90"); - ghc92 = ghc92Config.tweakHpkgs (pkgs.hlsHpkgs "ghc92"); - ghc94 = ghc94Config.tweakHpkgs (pkgs.hlsHpkgs "ghc94"); - ghc96 = ghc96Config.tweakHpkgs (pkgs.hlsHpkgs "ghc96"); - }; - in { default = cases."${ghcVersion}"; } // cases; - - ghc90 = supportedGHCs.ghc90; - ghc92 = supportedGHCs.ghc92; - ghc94 = supportedGHCs.ghc94; - ghc96 = supportedGHCs.ghc96; - ghcDefault = supportedGHCs.default; - pythonWithPackages = pkgs.python3.withPackages (ps: [ps.sphinx ps.myst-parser ps.sphinx_rtd_theme ps.pip]); docs = pkgs.stdenv.mkDerivation { @@ -237,23 +32,32 @@ dontInstall = true; }; - mkDevShell = hpkgs: cabalProject: with pkgs; mkShell { + # Support of GenChangelogs.hs + gen-hls-changelogs = hpkgs: with pkgs; + let myGHC = hpkgs.ghcWithPackages (p: with p; [ github ]); + in pkgs.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 + ''; + + mkDevShell = hpkgs: with pkgs; mkShell { name = "haskell-language-server-dev-ghc${hpkgs.ghc.version}"; - # For theses tools packages, we use ghcDefault + # For binary Haskell tools, we use the default nixpkgs GHC # This removes a rebuild with a different GHC version - # Theses programs are tools, used as binary, independently of the - # version of GHC. # The drawback of this approach is that our shell may pull two GHC - # version in scope (the default one, an - # The advantage is that we won't have to rebuild theses tools (and - # dependencies) with a recent GHC which may not be supported by - # them. + # version in scope. buildInputs = [ # our compiling toolchain hpkgs.ghc - hpkgs.cabal-install - # @guibou: I'm not sure hie-bios is needed - # pkgs.haskellPackages.hie-bios + pkgs.haskellPackages.cabal-install # Dependencies needed to build some parts of hackage gmp zlib ncurses # Changelog tooling @@ -285,124 +89,26 @@ # Install pre-commit hook pre-commit install - - # If the cabal project file is not the default one. - # Print a warning and generate an alias. - if [ ${cabalProject} != "cabal.project" ] - then - echo "Cabal won't be able to build your project without using the project file "${cabalProject}", such as:" - echo " cabal --project-file=${cabalProject}" - echo "An alias "cabal_project" is available. Use it like:" - echo " cabal_project build" - - alias cabal_project='cabal --project-file=${cabalProject}' - fi ''; }; - # Create a development shell of hls project - # See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319 - mkDevShellWithNixDeps = hpkgs: cabalProject: - with pkgs; - let simpleShell = mkDevShell hpkgs cabalProject; - in - hpkgs.shellFor { - name = "haskell-language-server-dev-nix-ghc${hpkgs.ghc.version}"; - inherit (simpleShell) shellHook buildInputs; - - doBenchmark = true; - packages = p: - with builtins; - map (name: p.${name}) (attrNames - # Disable dependencies should not be part of the shell. - (removeAttrs hlsSources (hpkgs.hlsDisabledPlugins or []))); - - src = null; - }; - - mkEnvShell = hpkgs: - pkgs.lib.mapAttrs (name: value: hpkgs.${name}.env) pkgs.hlsSources; - - # Create a hls executable - # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79428/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16 - mkExe = hpkgs: - with pkgs.haskell.lib; - (enableSharedExecutables (overrideCabal hpkgs.haskell-language-server - (_: { - postInstall = '' - 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 - ''; - }))).overrideAttrs(old: { - pname = old.pname + "-ghc${hpkgs.ghc.version}"; - }); in with pkgs; rec { - # Developement shell with only compiler - simpleDevShells = { - haskell-language-server-dev = mkDevShell ghcDefault "cabal.project"; - haskell-language-server-90-dev = mkDevShell ghc90 "cabal.project"; - haskell-language-server-92-dev = mkDevShell ghc92 "cabal.project"; - haskell-language-server-94-dev = mkDevShell ghc94 "cabal.project"; - haskell-language-server-96-dev = mkDevShell ghc96 "cabal.project"; - }; - - # Developement shell, haskell packages are also provided by nix - nixDevShells = { - haskell-language-server-dev-nix = mkDevShellWithNixDeps ghcDefault "cabal.project"; - haskell-language-server-90-dev-nix = mkDevShellWithNixDeps ghc90 "cabal.project"; - haskell-language-server-92-dev-nix = mkDevShellWithNixDeps ghc92 "cabal.project"; - haskell-language-server-94-dev-nix = mkDevShellWithNixDeps ghc94 "cabal.project"; - haskell-language-server-96-dev-nix = mkDevShellWithNixDeps ghc96 "cabal.project"; - }; - - # The default shell provided by Nixpkgs for a Haskell package (i.e. the - # one that comes in the `.env` attribute) - envShells = { - haskell-language-server-dev-env = mkEnvShell ghcDefault; - haskell-language-server-90-dev-env = mkEnvShell ghc90; - haskell-language-server-92-dev-env = mkEnvShell ghc92; - haskell-language-server-94-dev-env = mkEnvShell ghc94; - haskell-language-server-96-dev-env = mkEnvShell ghc96; + # Developement shell with only dev tools + devShells = { + default = mkDevShell pkgs.haskellPackages; + shell-ghc90 = mkDevShell pkgs.haskell.packages.ghc90; + shell-ghc92 = mkDevShell pkgs.haskell.packages.ghc92; + shell-ghc94 = mkDevShell pkgs.haskell.packages.ghc94; + shell-ghc96 = mkDevShell pkgs.haskell.packages.ghc96; }; - allPackages = { - haskell-language-server = mkExe ghcDefault; - haskell-language-server-90 = mkExe ghc90; - haskell-language-server-92 = mkExe ghc92; - haskell-language-server-94 = mkExe ghc94; - haskell-language-server-96 = mkExe ghc96; - }; - - devShells = simpleDevShells // nixDevShells // envShells // { - default = simpleDevShells.haskell-language-server-dev; - }; - - packages = allPackages // { - default = allPackages.haskell-language-server; - - # See https://github.com/NixOS/nix/issues/5591 - # nix flake cannot build a list/set of derivation in one command. - # Using a linkFarmFromDrvs, I'm creating a unique entry point to - # build all HLS versions. - # This is used in CI to test and populate cache for packages - # distributed using nix. - all-haskell-language-server = linkFarmFromDrvs "all-haskell-language-server" (lib.unique (builtins.attrValues allPackages)); - - all-nix-dev-shells = linkFarmFromDrvs "all-dev-shells" - (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues nixDevShells))); - - all-simple-dev-shells = linkFarmFromDrvs "all-simple-dev-shells" - (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues simpleDevShells))); - + packages = { docs = docs; }; # The attributes for the default shell and package changed in recent versions of Nix, # these are here for backwards compatibility with the old versions. devShell = devShells.default; - defaultPackage = packages.default; }); nixConfig = {