diff --git a/cabal.project b/cabal.project index 2f1a8084..6c2f2036 100644 --- a/cabal.project +++ b/cabal.project @@ -8,5 +8,8 @@ tests: True constraints: hashable ^>=1.3 constraints: semigroups ^>=0.19 +allow-newer: aeson-1.4.2.0:hashable +allow-newer: aeson-1.4.2.0:semigroups + allow-newer: aeson-1.4.3.0:hashable allow-newer: aeson-1.4.3.0:semigroups diff --git a/default.nix b/default.nix index 4b04872b..1bf8f95a 100644 --- a/default.nix +++ b/default.nix @@ -1,26 +1,47 @@ -{ mkDerivation, aeson, attoparsec, base, base16-bytestring -, byteable, bytestring, case-insensitive, conduit, containers -, cryptohash, data-default, failure, hashable, hspec, HTTP -, http-conduit, http-types, network, old-locale, stdenv, text, time -, unordered-containers, vector +{ nixpkgs ? import ./nix/nixpkgs.nix +, cabal-v2 ? true }: -mkDerivation { - pname = "github"; - version = "0.14.0"; - src = ./.; - buildDepends = [ - aeson attoparsec base base16-bytestring byteable bytestring - case-insensitive conduit containers cryptohash data-default failure - hashable HTTP http-conduit http-types network old-locale text time - unordered-containers vector - ]; - testDepends = [ - aeson attoparsec base base16-bytestring byteable bytestring - case-insensitive conduit containers cryptohash data-default failure - hashable hspec HTTP http-conduit http-types network old-locale text - time unordered-containers vector - ]; - homepage = "https://github.com/fpco/github"; - description = "Access to the Github API, v3"; - license = stdenv.lib.licenses.bsd3; -} +let + pkgs = import nixpkgs {}; + + # Newer versions to meet `constraints` in `cabal.project` for v2 builds + v2-overrides = super: if cabal-v2 then + { + hashable = super.hashable_1_3_0_0; + semigroups = super.semigroups_0_19; + } + else + { + }; + + hp = pkgs.haskellPackages.override (with pkgs.haskell.lib; { + overrides = self: super: { + # Newer versions of things we need + ansi-terminal = super.ansi-terminal_0_9_1; + binary-orphans = super.binary-orphans_1_0_1; + QuickCheck = super.QuickCheck_2_13_1; + quickcheck-instances = super.quickcheck-instances_0_3_21; + tasty = super.tasty_1_2_2; + time-compat = super.time-compat_1_9_2_2; + unordered-containers = super.unordered-containers_0_2_10_0; + + # Things that work with our newer versions but don't know it yet + # hspec test failure looks like it relies on some RNG to be just + # right, not critical + ChasingBottoms = doJailbreak super.ChasingBottoms; + hspec-core = dontCheck (doJailbreak super.hspec-core); + optparse-applicative = doJailbreak super.optparse-applicative; + + # We subbed in the correct versions of things it needs to work + binary-instances = overrideCabal super.binary-instances (drv: { + broken = false; + }); + + # Break infinite recursion through QuickCheck test dep + splitmix = dontCheck super.splitmix; + + } // (v2-overrides super); + }); + github = hp.callCabal2nix "github" ./. {}; +in + github diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix new file mode 100644 index 00000000..ca8d22a5 --- /dev/null +++ b/nix/nixpkgs.nix @@ -0,0 +1,7 @@ +builtins.fetchGit { + # Descriptive name to make the store path easier to identify + name = "nixos-unstable-2019-05-30"; + url = https://github.com/nixos/nixpkgs/; + # `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-unstable` + rev = "eccb90a2d997d65dc514253b441e515d8e0241c3"; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..9e3741f2 --- /dev/null +++ b/shell.nix @@ -0,0 +1,5 @@ +{ nixpkgs ? import ./nix/nixpkgs.nix +, cabal-v2 ? true +}: + +(import ./. {inherit nixpkgs cabal-v2;}).env