diff --git a/README.md b/README.md index 02f56e92..4ca6c30b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ If you have the [Nix package manager](https://nixos.org/) installed, the easiest $ cabal v2-run -- hackage-server run --static-dir=datafiles/ --base-uri=http://127.0.0.1:8080 hackage-server: Ready! Point your browser at http://127.0.0.1:8080 +`flake.nix` is provided; it uses [`srid/haskell-flake`](https://github.com/srid/haskell-flake). + +If you have [direnv](https://direnv.net/), `direnv allow` will load this `nix develop` shell automatically. + +`nix build` will build a `hackage-server` executable in `result/`. The Hackage dependencies are provided by the inputs specified in `flake.nix`. + ### Manually You can also install dependencies manually via your operating system's package diff --git a/flake.lock b/flake.lock index 01de1209..54646e9e 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1677714448, - "narHash": "sha256-Hq8qLs8xFu28aDjytfxjdC96bZ6pds21Yy09mSC156I=", + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "dc531e3a9ce757041e1afaff8ee932725ca60002", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "haskell-flake": { "locked": { - "lastModified": 1677789682, - "narHash": "sha256-xR5II4leMRvr07NJDTi5npE86LWSbeq4XInpF5cNo7k=", + "lastModified": 1678554320, + "narHash": "sha256-G00gAEh8NDaFzBoC53OShOAfcFzYMEdNIT+GDnKrOBA=", "owner": "srid", "repo": "haskell-flake", - "rev": "162c566cd2bae8e1fbb6e011f6274d12d9b759ca", + "rev": "ce6d0388d9d19b8e6b318b197a736fd916d028ac", "type": "github" }, "original": { @@ -48,6 +48,78 @@ "type": "github" } }, + "hls-floskell-plugin": { + "flake": false, + "locked": { + "dir": "plugins/hls-floskell-plugin", + "lastModified": 1678096645, + "narHash": "sha256-6ZW5+b8WeylAzI1zkkn38d5lr9N9KDvaWlxHfFmIaVQ=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "1ebb619d86350dbfa7bb3a05d51c516993e140a8", + "type": "github" + }, + "original": { + "dir": "plugins/hls-floskell-plugin", + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-graph": { + "flake": false, + "locked": { + "dir": "hls-graph", + "lastModified": 1678096645, + "narHash": "sha256-6ZW5+b8WeylAzI1zkkn38d5lr9N9KDvaWlxHfFmIaVQ=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "1ebb619d86350dbfa7bb3a05d51c516993e140a8", + "type": "github" + }, + "original": { + "dir": "hls-graph", + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-hlint-plugin": { + "flake": false, + "locked": { + "dir": "plugins/hls-hlint-plugin", + "lastModified": 1678096645, + "narHash": "sha256-6ZW5+b8WeylAzI1zkkn38d5lr9N9KDvaWlxHfFmIaVQ=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "1ebb619d86350dbfa7bb3a05d51c516993e140a8", + "type": "github" + }, + "original": { + "dir": "plugins/hls-hlint-plugin", + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-ormolu-plugin": { + "flake": false, + "locked": { + "dir": "plugins/hls-ormolu-plugin", + "lastModified": 1678096645, + "narHash": "sha256-6ZW5+b8WeylAzI1zkkn38d5lr9N9KDvaWlxHfFmIaVQ=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "1ebb619d86350dbfa7bb3a05d51c516993e140a8", + "type": "github" + }, + "original": { + "dir": "plugins/hls-ormolu-plugin", + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, "linear-generics": { "flake": false, "locked": { @@ -81,16 +153,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1677975396, - "narHash": "sha256-7YdypOfqlBvOlS/b5VJO+85ze1kmoWdhH7r7mBzq+AQ=", + "lastModified": 1678500213, + "narHash": "sha256-A5s2rXawJ+dCThkMXoMuYW8dgyUmkElcyfVJUot/Vr0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8749e1376bce3ab684244871c343ef4777d83ef7", + "rev": "2ce9b9842b5e63884dfc3dea6689769e2a1ea309", "type": "github" }, "original": { "owner": "nixos", - "ref": "haskell-updates", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -113,11 +185,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1677407201, - "narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", "type": "github" }, "original": { @@ -130,11 +202,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1675545634, - "narHash": "sha256-TbQeQcM5TA/wIho6xtzG+inUfiGzUXi8ewwttiQWYJE=", + "lastModified": 1677932085, + "narHash": "sha256-+AB4dYllWig8iO6vAiGGYl0NEgmMgGHpy9gzWJ3322g=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0591d6b57bfeb55dfeec99a671843337bc2c3323", + "rev": "3c5319ad3aa51551182ac82ea17ab1c6b0f0df89", "type": "github" }, "original": { @@ -144,28 +216,66 @@ "type": "github" } }, + "nothunks": { + "flake": false, + "locked": { + "lastModified": 1677662773, + "narHash": "sha256-5qUtCJ8Gf6fxt0t1WAyGb0pDFNxJBAy+VbtCIqz5tew=", + "owner": "input-output-hk", + "repo": "nothunks", + "rev": "c0609d27c27173bd7d0b5f2417d274a4eb57ea3d", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "nothunks", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", "flake-root": "flake-root", "haskell-flake": "haskell-flake", + "hls-floskell-plugin": "hls-floskell-plugin", + "hls-graph": "hls-graph", + "hls-hlint-plugin": "hls-hlint-plugin", + "hls-ormolu-plugin": "hls-ormolu-plugin", "linear-generics": "linear-generics", "mission-control": "mission-control", "nixpkgs": "nixpkgs", "nixpkgs-140774-workaround": "nixpkgs-140774-workaround", + "nothunks": "nothunks", + "stylish-haskell": "stylish-haskell", "treefmt-nix": "treefmt-nix" } }, + "stylish-haskell": { + "flake": false, + "locked": { + "lastModified": 1678437708, + "narHash": "sha256-XO4HCG1hWwEVr765GjfJwvLOCwICOZ/MkCj1xP2b/w8=", + "owner": "haskell", + "repo": "stylish-haskell", + "rev": "13f1db77f28b62ac6da6abb3c82244d5e740503b", + "type": "github" + }, + "original": { + "owner": "haskell", + "repo": "stylish-haskell", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1677433127, - "narHash": "sha256-vafj2WbhrlnwkU20yRDqtHFTUJIEygPfxJVswB3dJ9U=", + "lastModified": 1678277086, + "narHash": "sha256-fQ1G72KhLWWf2z+ug9+4ErTEayvlcVQMul0qusKKBgk=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "f7fcf3770c6cec6fd5f995ba94e6e6376019b9ff", + "rev": "ec39cfa24342fdf0b04ae44592a191c4765f9c74", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 618a5bdc..2fefb108 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/haskell-updates"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; haskell-flake.url = "github:srid/haskell-flake"; treefmt-nix.url = "github:numtide/treefmt-nix"; @@ -12,197 +12,132 @@ flake = false; }; - # bytestring_10 = { - # url = "github:haskell/bytestring/0.10.10.1"; - # flake = false; - # }; + stylish-haskell = { + url = "github:haskell/stylish-haskell"; + flake = false; + }; - # hspec = { - # url = "github:hspec/hspec/2.10.9"; - # flake = false; - # }; + nothunks = { + url = "github:input-output-hk/nothunks"; + flake = false; + }; + hls-hlint-plugin = { + url = "github:haskell/haskell-language-server?dir=plugins/hls-hlint-plugin"; + flake = false; + }; + hls-floskell-plugin = { + url = "github:haskell/haskell-language-server?dir=plugins/hls-floskell-plugin"; + flake = false; + }; + hls-ormolu-plugin = { + url = "github:haskell/haskell-language-server?dir=plugins/hls-ormolu-plugin"; + flake = false; + }; + hls-graph = { + url = "github:haskell/haskell-language-server?dir=hls-graph"; + flake = false; + }; nixpkgs-140774-workaround.url = "github:srid/nixpkgs-140774-workaround"; }; outputs = inputs@{ self, nixpkgs, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { - # systems = nixpkgs.lib.systems.flakeExposed; systems = [ "x86_64-linux" ]; imports = [ inputs.haskell-flake.flakeModule - inputs.treefmt-nix.flakeModule inputs.flake-root.flakeModule inputs.mission-control.flakeModule ]; perSystem = { self', system, lib, config, pkgs, ... }: { # The "main" project. You can have multiple projects, but this template # has only one. - haskellProjects.main = { - # basePackages = pkgs.haskell.packages.ghc902; - # basePackages = pkgs.haskell.packages.ghc926; - basePackages = pkgs.haskell.packages.ghc944; + # basePackages = pkgs.haskell.packages.ghc927; + # basePackages = pkgs.haskell.packages.ghc944; imports = [ inputs.nixpkgs-140774-workaround.haskellFlakeProjectModules.default ]; - # packages.haskell-template.root = ./.; # Auto-discovered by haskell-flake - overrides = self: super: with pkgs.haskell.lib; { - # Cabal = super.Cabal_3_8_1_0; - # Cabal-syntax = super.Cabal-syntax_3_8_1_0; - # doctest-parallel = super.doctest-parallel_0_3_0; - # haddock-library = pkgs.haskell.lib.doJailbreak (super.haddock-library_1_11_0); - # linear-generics = super.callCabal2nix "linear-generics" inputs.linear-generics {}; - - # transformers-compat = self.callCabal2nix "transformers-compat" (pkgs.fetchFromGitHub - # { - # owner = "ekmett"; - # repo = "transformers-compat"; - # rev = "17e38059a6e1fd942fe2bc3245bae9bc625a2917"; - # sha256 = "0wd3assqk5i9pf39wmxl5gchwdnmpmlgfw5gy2wdrcrzfgivihx1"; - # }) {}; - - # threads = pkgs.haskell.lib.dontCheck (self.callCabal2nix "threads" (pkgs.fetchFromGitHub - # { - # owner = "basvandijk"; - # repo = "threads"; - # rev = "e6160af9eef7d739a4070b74d9a5bedf7778273f"; - # sha256 = "1m63k7gmnw81ml93rgbsf11z24ikm2b9lsnax6cslmr9j3ygmjgs"; - # }) {}); - - # hedgehog = self.callHackage "hedgehog" "1.1.2" {}; - - # stylish-haskell = pkgs.haskell.lib.doJailbreak (self.callHackage "stylish-haskell" "0.14.4.0" {}); - # chell = pkgs.haskell.lib.doJailbreak (self.callHackage "chell" "0.5.0.1" {}); - - # ghc-lib-parser = self.callHackage "ghc-lib-parser" "9.2.7.20230228" {}; - # # ghc-lib-parser = self.callHackage "ghc-lib-parser" "9.4.4.20221225" {}; - # ormolu = self.callHackage "ormolu" "0.5.3.0" {}; - # fourmolu = self.callHackage "fourmolu" "0.10.1.0" {}; - - # # template-haskell = self.callHackage "template-haskell" "2.19.0.0" {}; - # # QuickCheck = self.callHackage "QuickCheck" "2.13.2" {}; - # text = self.callHackage "text" "2.0.2" {}; - # # ghc-boot-th = self.callHackage "ghc-boot-th" "9.4.1" {}; - - # # tasty-hedgehog = self.callHackage "tasty-hedgehog" "1.4.0.0" {}; - # hls-floskell-plugin = pkgs.haskell.lib.dontCheck ( - # self.callHackage "hls-floskell-plugin" "1.0.2.0" {} - # ); + packages.hackage-server.root = ./.; # Auto-discovered by haskell-flake + overrides = self: super: { + Cabal = super.Cabal_3_8_1_0; + Cabal-syntax = super.Cabal-syntax_3_8_1_0; + doctest-parallel = super.doctest-parallel_0_3_0; + + ghc-lib-parser = super.ghc-lib-parser_9_4_4_20221225; + ghc-lib-parser-ex = super.ghc-lib-parser-ex_9_4_0_0; + text = super.text_2_0_1; + parsec = self.callHackage "parsec" "3.1.16.1" {}; + + chell = pkgs.haskell.lib.doJailbreak (self.callHackage "chell" "0.5.0.1" {}); + ghc-boot-th = self.callHackage "ghc-boot-th" "9.2.1" {}; + hedgehog = self.callHackage "hedgehog" "1.2" {}; + tasty-hedgehog = self.callHackage "tasty-hedgehog" "1.4.0.0" {}; + optparse-applicative = pkgs.haskell.lib.doJailbreak (super.optparse-applicative_0_15_1_0); + haddock-library = pkgs.haskell.lib.doJailbreak (self.callHackage "haddock-library" "1.11.0" {}); + + th-abstraction = self.callHackage "th-abstraction" "0.4.5.0" {}; + stylish-haskell = super.callCabal2nix "stylish-haskell" inputs.stylish-haskell {}; + + nothunks = super.callCabal2nix "nothunks" inputs.nothunks {}; + + # requirements of HLS + # TODO: fix HLS https://github.com/haskell/haskell-language-server/issues/3518 + ormolu = self.callHackage "ormolu" "0.5.3.0" {}; + fourmolu = pkgs.haskell.lib.dontCheck (self.callHackage "fourmolu" "0.10.1.0" {}); + # hls-floskell-plugin = pkgs.haskell.lib.dontCheck (self.callHackage "hls-floskell-plugin" "1.0.2.0" {}); + # hls-floskell-plugin = self.callCabal2nix "hls-floskell-plugin" inputs.hls-floskell-plugin {}; + # hls-graph = self.callCabal2nix "hls-graph" inputs.hls-graph {}; + # hls-graph = self.callHackage "hls-graph" "1.9.0.0" {}; + # hls-hlint-plugin = self.callCabal2nix "hls-hlint-plugin" inputs.hls-hlint-plugin {}; + # hls-hlint-plugin = self.callHackage "hls-hlint-plugin" "1.1.2.0" {}; + # hls-ormolu-plugin = self.callCabal2nix "hls-ormolu-plugin" inputs.hls-ormolu-plugin {}; + # hls-ormolu-plugin = self.callHackage "hls-ormolu-plugin" "1.0.2.2" {}; + # hls-ormolu-plugin = self.callHackage "hls-ormolu-plugin" "1.0.3.0" {}; + # hls-plugin-api = self.callHackage "hls-plugin-api" "1.6.0.0" {}; + # hls-test-utils = self.callHackage "hls-test-utils" "1.5.0.0" {}; + + hlint = self.callHackage "hlint" "3.5" {}; + + ghcide = pkgs.haskell.lib.dontCheck (self.callHackage "ghcide" "1.9.0.0" {}); }; devShell = { - tools = hp: { - treefmt = config.treefmt.build.wrapper; - } // config.treefmt.build.programs; hlsCheck.enable = true; }; }; - # Auto formatters. This also adds a flake check to ensure that the - # source tree was auto formatted. - treefmt.config = { - inherit (config.flake-root) projectRootFile; - package = pkgs.treefmt; - - programs.ormolu.enable = true; - programs.nixpkgs-fmt.enable = true; - programs.cabal-fmt.enable = true; - programs.hlint.enable = true; - - # We use fourmolu - programs.ormolu.package = pkgs.haskellPackages.fourmolu; - settings.formatter.ormolu = { - options = [ - "--ghc-opt" - "-XImportQualifiedPost" - ]; - }; - }; - - # Dev shell scripts. - # mission-control.scripts = { - # docs = { - # description = "Start Hoogle server for project dependencies"; - # exec = '' - # echo http://127.0.0.1:8888 - # hoogle serve -p 8888 --local - # ''; - # category = "Dev Tools"; - # }; - # repl = { - # description = "Start the cabal repl"; - # exec = '' - # cabal repl "$@" - # ''; - # category = "Dev Tools"; - # }; - # fmt = { - # description = "Format the source tree"; - # exec = "${lib.getExe config.treefmt.build.wrapper}"; - # category = "Dev Tools "; - # }; - # run = { - # description = "Run the project with ghcid auto-recompile"; - # exec = '' - # ghcid -c "cabal repl exe:haskell-template" --warnings -T :main - # ''; - # category = "Primary"; - # }; - # }; - - # Default package. - packages.default = self'.packages.main-hackage-server; + packages.default = pkgs.haskell.lib.dontCheck (self'.packages.main-hackage-server); + # TODO: fix HLS https://github.com/haskell/haskell-language-server/issues/3518 # Default shell. - devShells.default = - config.mission-control.installToDevShell self'.devShells.main; + # devShells.default = + # config.mission-control.installToDevShell self'.devShells.main; + devShells.default = pkgs.mkShell { + buildInputs = + with pkgs; + [ cabal-install + ghc + + glibc + icu67 + zlib + openssl + cryptodev + pkg-config + brotli + + gd + libpng + libjpeg + fontconfig + freetype + expat + + ]; + }; }; }; - # outputs = { self, nixpkgs, flake-utils, haskellNix }: - # let - # supportedSystems = [ - # "x86_64-linux" - # "x86_64-darwin" - # "aarch64-linux" - # "aarch64-darwin" - # ]; - # in - # flake-utils.lib.eachSystem supportedSystems (system: - # let - # overlays = [ haskellNix.overlay - # (final: prev: { - # hixProject = - # final.haskell-nix.hix.project { - # src = ./.; - # evalSystem = "x86_64-linux"; - # projectFileName = "cabal.project"; - # # modules = [ - # # { reinstallableLibGhc = true; } - # # ]; - # }; - # }) - # ]; - # pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; - # flake = pkgs.hixProject.flake {}; - # in flake // { - # legacyPackages = pkgs; - - # packages = { - # default = flake.packages."hackage-server:exe:hackage-server"; - # }; - - # devShells.default = pkgs.hixProject.shellFor { - # tools = { - # cabal = "latest"; - # }; - # # buildInputs = - # # with pkgs; - # # [ haskellPackages.alex - # # ]; - # }; - # }); - nixConfig = { extra-substituters = ["https://hackage-server.cachix.org/"]; extra-trusted-public-keys = [ diff --git a/src/Distribution/Server/Features/UserNotify.hs b/src/Distribution/Server/Features/UserNotify.hs index bfcb0716..aa92bf39 100644 --- a/src/Distribution/Server/Features/UserNotify.hs +++ b/src/Distribution/Server/Features/UserNotify.hs @@ -3,6 +3,7 @@ RankNTypes, NamedFieldPuns, RecordWildCards, BangPatterns, DefaultSignatures, OverloadedStrings #-} {-# LANGUAGE TupleSections #-} +{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} module Distribution.Server.Features.UserNotify ( initUserNotifyFeature, UserNotifyFeature(..),