diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/nix-shell.yml.off b/.github/workflows/nix-flake.yml similarity index 71% rename from .github/workflows/nix-shell.yml.off rename to .github/workflows/nix-flake.yml index f6c20790c..68bda9863 100644 --- a/.github/workflows/nix-shell.yml.off +++ b/.github/workflows/nix-flake.yml @@ -1,21 +1,25 @@ -name: "Test nix-shell" +name: "Test Nix Flake" on: push: branches: - master - - ci* pull_request: branches: - master - - ci* jobs: - nix-shell: - runs-on: ubuntu-latest + nix: + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + - macos-latest + name: Nix on ${{ matrix.os }} + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3.1.0 - - uses: cachix/install-nix-action@v18 + - uses: cachix/install-nix-action@v20 with: - nix_path: nixpkgs=channel:nixos-21.11 extra_nix_config: | trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hackage-server.cachix.org-1:iw0iRh6+gsFIrxROFaAt5gKNgIHejKjIfyRdbpPYevY= substituters = https://hydra.iohk.io https://cache.nixos.org/ https://hackage-server.cachix.org/ @@ -24,4 +28,5 @@ jobs: # https://nix.dev/tutorials/continuous-integration-github-actions#setting-up-github-actions name: hackage-server authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - run: nix-shell --pure --run ./.github/workflows/test-nix-shell.sh \ No newline at end of file + - run: nix build + # - run: nix flake check diff --git a/.github/workflows/test-nix-shell.sh b/.github/workflows/test-nix-shell.sh deleted file mode 100755 index b48799885..000000000 --- a/.github/workflows/test-nix-shell.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cabal update hackage.haskell.org,2022-08-27T00:00:00Z -cabal build all --enable-tests diff --git a/.gitignore b/.gitignore index 054ef68b0..537890585 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ tags *.swp TAGS *~ +.direnv + +result* \ No newline at end of file diff --git a/README.md b/README.md index 4ae354678..f1d0e8952 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/haskell/hackage-server.png?branch=master)](https://travis-ci.org/haskell/hackage-server) [![Build status](https://github.com/haskell/hackage-server/actions/workflows/haskell-ci.yml/badge.svg)](https://github.com/haskell/hackage-server/actions/workflows/haskell-ci.yml) -[![Build status](https://github.com/haskell/hackage-server/actions/workflows/nix-shell.yml/badge.svg)](https://github.com/haskell/hackage-server/actions/workflows/nix-shell.yml) +[![Build status](https://github.com/haskell/hackage-server/actions/workflows/nix-flake.yml/badge.svg)](https://github.com/haskell/hackage-server/actions/workflows/nix-flake.yml) This is the `hackage-server` code. This is what powers , and many other private hackage instances. The `master` branch is suitable for general usage. Specific policy and documentation for the central hackage instance exists in the `central-server` branch. @@ -10,17 +10,24 @@ This is the `hackage-server` code. This is what powers = 1.6.14` diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..54646e9e5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,290 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1671378805, + "narHash": "sha256-yqGxyzMN2GuppwG3dTWD1oiKxi+jGYP7D1qUSc5vKhI=", + "owner": "srid", + "repo": "flake-root", + "rev": "dc7ba6166e478804a9da6881aa48c45d300075cf", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1678554320, + "narHash": "sha256-G00gAEh8NDaFzBoC53OShOAfcFzYMEdNIT+GDnKrOBA=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "ce6d0388d9d19b8e6b318b197a736fd916d028ac", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "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": { + "lastModified": 1676406075, + "narHash": "sha256-TiL2AqBo+/irNckInOX8sYhp0lFddVL81+5VxwzB3xM=", + "owner": "linear-generics", + "repo": "linear-generics", + "rev": "2d62f4c0c2880650179a73059c1421622a8a9bf6", + "type": "github" + }, + "original": { + "owner": "linear-generics", + "repo": "linear-generics", + "type": "github" + } + }, + "mission-control": { + "locked": { + "lastModified": 1675195908, + "narHash": "sha256-nQv35C7svZFluwy2uoZFxwPqiT16XoKAoMlIQYmvg3A=", + "owner": "Platonic-Systems", + "repo": "mission-control", + "rev": "feb06872ac4dc977f70f6388c87d36fc3c3c3693", + "type": "github" + }, + "original": { + "owner": "Platonic-Systems", + "repo": "mission-control", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678500213, + "narHash": "sha256-A5s2rXawJ+dCThkMXoMuYW8dgyUmkElcyfVJUot/Vr0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2ce9b9842b5e63884dfc3dea6689769e2a1ea309", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-140774-workaround": { + "locked": { + "lastModified": 1677708284, + "narHash": "sha256-syAhlmvVlVDwgoKS6b3EfrQKfaeCY3zjT2q7VBk/yx8=", + "owner": "srid", + "repo": "nixpkgs-140774-workaround", + "rev": "5fe054e8560cf474b3c89622c1ea7688023425c1", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "nixpkgs-140774-workaround", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1677932085, + "narHash": "sha256-+AB4dYllWig8iO6vAiGGYl0NEgmMgGHpy9gzWJ3322g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3c5319ad3aa51551182ac82ea17ab1c6b0f0df89", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "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": 1678277086, + "narHash": "sha256-fQ1G72KhLWWf2z+ug9+4ErTEayvlcVQMul0qusKKBgk=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "ec39cfa24342fdf0b04ae44592a191c4765f9c74", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..eaa0c4d7a --- /dev/null +++ b/flake.nix @@ -0,0 +1,148 @@ +{ + inputs = { + 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"; + flake-root.url = "github:srid/flake-root"; + mission-control.url = "github:Platonic-Systems/mission-control"; + + linear-generics = { + url = "github:linear-generics/linear-generics"; + flake = false; + }; + + stylish-haskell = { + url = "github:haskell/stylish-haskell"; + 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 = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + imports = [ + inputs.haskell-flake.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.ghc927; + # basePackages = pkgs.haskell.packages.ghc944; + imports = [ + inputs.nixpkgs-140774-workaround.haskellFlakeProjectModules.default + ]; + 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 = { + hlsCheck.enable = false; + }; + }; + + 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 = pkgs.mkShell { + buildInputs = + with pkgs; + [ cabal-install + ghc + + glibc + icu67 + zlib + openssl + cryptodev + pkg-config + brotli + + gd + libpng + libjpeg + fontconfig + freetype + expat + + ]; + }; + }; + }; + + nixConfig = { + extra-substituters = ["https://hackage-server.cachix.org/"]; + extra-trusted-public-keys = [ + "hackage-server.cachix.org-1:iw0iRh6+gsFIrxROFaAt5gKNgIHejKjIfyRdbpPYevY=" + ]; + allow-import-from-derivation = "true"; + }; +} diff --git a/hackage-server.cabal b/hackage-server.cabal index 1cad58fe7..b10f5e1a5 100644 --- a/hackage-server.cabal +++ b/hackage-server.cabal @@ -645,7 +645,6 @@ test-suite DocTests type: exitcode-stdio-1.0 main-is: DocTestMain.hs - build-depends: , lib-server , doctest-parallel ^>= 0.3.0 diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 909e7de85..000000000 --- a/shell.nix +++ /dev/null @@ -1,35 +0,0 @@ -let - nixpkgs = builtins.fetchTarball { - # master on 2022-05-14 - url = "https://github.com/NixOS/nixpkgs/archive/1d370bd07399fb52cea6badfbffbc90ac9b0f8f0.tar.gz"; - sha256 = "1ln4vwy185gwhbf4f8vanrlj4w4bhwrcsb2m8fnm99f4zqzvp7fs"; - }; - - pkgs = import nixpkgs { config = { }; }; - -in -with pkgs; pkgs.mkShell rec { - buildInputs = [ - # Haskell development - cabal-install - ghc - - # Dependencies - glibc - icu67 - zlib - openssl - cryptodev - pkg-config - brotli - - gd - libpng - libjpeg - fontconfig - freetype - expat - ]; - - # LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; -} diff --git a/src/Distribution/Server/Features/UserNotify.hs b/src/Distribution/Server/Features/UserNotify.hs index bfcb0716a..aa92bf398 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(..),