From b7d8e61781c98f29826045c016f1cea97ff8d39e Mon Sep 17 00:00:00 2001 From: Troels Henriksen Date: Sun, 25 Oct 2020 09:16:59 +0100 Subject: [PATCH] Use the newest version of 'versions'. (#1165) --- cabal.project | 2 +- default.nix | 80 ++++++++++++++++++++++++++-------------- futhark.cabal | 2 +- futhark.nix | 8 ++-- nix/sexp-grammar.nix | 27 ++++++++++++++ nix/versions.nix | 19 ++++++++++ src/Futhark/Pkg/Info.hs | 4 +- src/Futhark/Pkg/Types.hs | 7 ++-- stack.yaml | 1 + 9 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 nix/sexp-grammar.nix create mode 100644 nix/versions.nix diff --git a/cabal.project b/cabal.project index 87b88d1891..9e1400c514 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,5 @@ packages: futhark.cabal -index-state: 2020-08-27T09:04:41Z +index-state: 2020-10-24T05:40:24Z package futhark ghc-options: -Werror -j diff --git a/default.nix b/default.nix index 123ca3dcc4..e6d90b60b7 100644 --- a/default.nix +++ b/default.nix @@ -2,47 +2,73 @@ # Futhark binary and some manpages. Likely to only work on linux. # # Just run 'nix-build' and fish the tarball out of 'result/'. +# +# For the Haskell dependencies that diverge from our pinned Nixpkgs, +# we use cabal2nix like thus: +# +# $ cabal2nix cabal://sexp-grammar-2.2.1 > nix/sexp-grammar.nix +# +# And then import them into the configuration. +# +# Also remember this guide: https://github.com/Gabriel439/haskell-nix/blob/master/project1/README.md -{ compiler ? "ghc883", +{ compiler ? "ghc883", # ignored ATM suffix ? "nightly", commit ? "" }: let - sources = import ./nix/sources.nix; - pkgs = import sources.nixpkgs {}; + config = { + packageOverrides = pkgs: rec { + haskellPackages = pkgs.haskellPackages.override { + overrides = haskellPackagesNew: haskellPackagesOld: rec { + versions = + haskellPackagesNew.callPackage ./nix/versions.nix { }; - futhark = - pkgs.haskell.lib.overrideCabal - (pkgs.haskell.lib.addBuildTools - (pkgs.haskell.packages.${compiler}.callPackage ./futhark.nix { }) - [ pkgs.python37Packages.sphinx ]) - ( _drv: { - isLibrary = false; - isExecutable = true; - enableSharedExecutables = false; - enableSharedLibraries = false; - enableLibraryProfiling = false; - configureFlags = [ - "--ghc-option=-optl=-static" - "--ghc-option=-split-sections" - "--extra-lib-dirs=${pkgs.ncurses.override { enableStatic = true; }}/lib" - "--extra-lib-dirs=${pkgs.glibc.static}/lib" - "--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib" - "--extra-lib-dirs=${pkgs.zlib.static}/lib" - "--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib" - ]; + sexp-grammar = + haskellPackagesNew.callPackage ./nix/sexp-grammar.nix { }; - postBuild = (_drv.postBuild or "") + '' + futhark = + pkgs.haskell.lib.overrideCabal + (pkgs.haskell.lib.addBuildTools + (haskellPackagesNew.callPackage ./futhark.nix { }) + [ pkgs.python37Packages.sphinx ]) + ( _drv: { + isLibrary = false; + isExecutable = true; + enableSharedExecutables = false; + enableSharedLibraries = false; + enableLibraryProfiling = false; + configureFlags = [ + "--ghc-option=-optl=-static" + "--ghc-option=-split-sections" + "--extra-lib-dirs=${pkgs.ncurses.override { enableStatic = true; }}/lib" + "--extra-lib-dirs=${pkgs.glibc.static}/lib" + "--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib" + "--extra-lib-dirs=${pkgs.zlib.static}/lib" + "--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib" + ]; + + postBuild = (_drv.postBuild or "") + '' make -C docs man ''; - postInstall = (_drv.postInstall or "") + '' + postInstall = (_drv.postInstall or "") + '' mkdir -p $out/share/man/man1 cp docs/_build/man/*.1 $out/share/man/man1/ mkdir -p $out/share/futhark/ cp LICENSE $out/share/futhark/ ''; - } - ); + } + ); + }; + }; + }; + }; + + sources = import ./nix/sources.nix; + pkgs = import sources.nixpkgs { inherit config; }; + + futhark = pkgs.haskellPackages.futhark; + in pkgs.stdenv.mkDerivation rec { name = "futhark-" + suffix; version = futhark.version; diff --git a/futhark.cabal b/futhark.cabal index e8e2a4d82e..9c19f79a98 100644 --- a/futhark.cabal +++ b/futhark.cabal @@ -313,7 +313,7 @@ library , utf8-string >=1 , vector >=0.12 , vector-binary-instances >=0.2.2.0 - , versions >=3.3.1 + , versions >=4.0.1 , zip-archive >=0.3.1.1 , zlib >=0.6.1.2 default-language: Haskell2010 diff --git a/futhark.nix b/futhark.nix index b92c20a8e8..53db8f1b51 100644 --- a/futhark.nix +++ b/futhark.nix @@ -3,7 +3,7 @@ , directory-tree, dlist, file-embed, filepath, free, gitrev, happy , haskeline, language-c-quote, mainland-pretty, megaparsec, mtl , neat-interpolation, parallel, parser-combinators, pcg-random -, process, process-extras, QuickCheck, regex-tdfa, sexp-grammar_2_2_1 +, process, process-extras, QuickCheck, regex-tdfa, sexp-grammar , srcloc, stdenv, tasty, tasty-hunit, tasty-quickcheck , template-haskell, temporary, terminal-size, text, time , transformers, unordered-containers, utf8-string, vector @@ -11,7 +11,7 @@ }: mkDerivation { pname = "futhark"; - version = "0.17.0"; + version = "0.19.0"; src = ./.; isLibrary = true; isExecutable = true; @@ -20,7 +20,7 @@ mkDerivation { cmark-gfm containers directory directory-tree dlist file-embed filepath free gitrev haskeline language-c-quote mainland-pretty megaparsec mtl neat-interpolation parallel pcg-random process - process-extras regex-tdfa sexp-grammar_2_2_1 srcloc template-haskell + process-extras regex-tdfa sexp-grammar srcloc template-haskell temporary terminal-size text time transformers unordered-containers utf8-string vector vector-binary-instances versions zip-archive zlib @@ -29,7 +29,7 @@ mkDerivation { executableHaskellDepends = [ base text ]; testHaskellDepends = [ base containers megaparsec mtl parser-combinators QuickCheck - sexp-grammar_2_2_1 tasty tasty-hunit tasty-quickcheck text + sexp-grammar tasty tasty-hunit tasty-quickcheck text ]; homepage = "https://futhark-lang.org"; description = "An optimising compiler for a functional, array-oriented language"; diff --git a/nix/sexp-grammar.nix b/nix/sexp-grammar.nix new file mode 100644 index 0000000000..563ba1f61c --- /dev/null +++ b/nix/sexp-grammar.nix @@ -0,0 +1,27 @@ +{ mkDerivation, alex, array, base, bytestring, containers +, criterion, deepseq, happy, invertible-grammar, prettyprinter +, QuickCheck, recursion-schemes, scientific, semigroups, stdenv +, tasty, tasty-hunit, tasty-quickcheck, text, utf8-string +}: +mkDerivation { + pname = "sexp-grammar"; + version = "2.2.1"; + sha256 = "7f53a35fb6a5b8fba450874b1e0fdbfcb98bed94829c27d39622e215d958c359"; + libraryHaskellDepends = [ + array base bytestring containers deepseq invertible-grammar + prettyprinter recursion-schemes scientific semigroups text + utf8-string + ]; + libraryToolDepends = [ alex happy ]; + testHaskellDepends = [ + base containers invertible-grammar prettyprinter QuickCheck + scientific semigroups tasty tasty-hunit tasty-quickcheck text + utf8-string + ]; + benchmarkHaskellDepends = [ + base bytestring criterion deepseq text + ]; + homepage = "https://github.com/esmolanka/sexp-grammar"; + description = "Invertible grammar combinators for S-expressions"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/nix/versions.nix b/nix/versions.nix new file mode 100644 index 0000000000..d028bc018e --- /dev/null +++ b/nix/versions.nix @@ -0,0 +1,19 @@ +{ mkDerivation, base, deepseq, hashable, megaparsec, microlens +, parser-combinators, QuickCheck, stdenv, tasty, tasty-hunit +, tasty-quickcheck, text +}: +mkDerivation { + pname = "versions"; + version = "4.0.1"; + sha256 = "0a153d0ba4ad6ecb3bab917ab4138b3ac0e80d9d703bbd1ee7046b3570b70be9"; + libraryHaskellDepends = [ + base deepseq hashable megaparsec parser-combinators text + ]; + testHaskellDepends = [ + base megaparsec microlens QuickCheck tasty tasty-hunit + tasty-quickcheck text + ]; + homepage = "https://github.com/fosskers/versions"; + description = "Types and parsers for software version numbers"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/src/Futhark/Pkg/Info.hs b/src/Futhark/Pkg/Info.hs index bccffb860b..fcd3058aa0 100644 --- a/src/Futhark/Pkg/Info.hs +++ b/src/Futhark/Pkg/Info.hs @@ -284,7 +284,7 @@ ghglPkgInfo repo_url mk_archive_url mk_manifest_url mk_zip_dir owner repo versio | [hash, ref] <- T.words l, ["refs", "tags", t] <- T.splitOn "/" ref, "v" `T.isPrefixOf` t, - Right v <- semver $ T.drop 1 t, + Right v <- parseVersion $ T.drop 1 t, _svMajor v `elem` versions = do pinfo <- ghglLookupCommit @@ -359,7 +359,7 @@ glPkgInfo owner repo versions = <> "/" <> T.pack futharkPkg mk_zip_dir r - | Right _ <- semver r = repo <> "-v" <> r + | Right _ <- parseVersion r = repo <> "-v" <> r | otherwise = repo <> "-" <> r -- | A package registry is a mapping from package paths to information diff --git a/src/Futhark/Pkg/Types.hs b/src/Futhark/Pkg/Types.hs index 177d2e43a2..6110abeb48 100644 --- a/src/Futhark/Pkg/Types.hs +++ b/src/Futhark/Pkg/Types.hs @@ -41,12 +41,13 @@ import Control.Monad import Data.Either import Data.Foldable import Data.List (sortOn) +import qualified Data.List.NonEmpty as NE import qualified Data.Map as M import Data.Maybe import qualified Data.Text as T import qualified Data.Text.IO as T import Data.Traversable -import Data.Versions (SemVer (..), VUnit (..), prettySemVer, semver) +import Data.Versions (SemVer (..), VUnit (..), prettySemVer) import Data.Void import System.FilePath import qualified System.FilePath.Posix as Posix @@ -69,13 +70,13 @@ pkgPathFilePath = joinPath . Posix.splitPath . T.unpack -- @hash@ (typically the Git commit ID). This function detects such -- versions. isCommitVersion :: SemVer -> Maybe T.Text -isCommitVersion (SemVer 0 0 0 [_] [[Str s]]) = Just s +isCommitVersion (SemVer 0 0 0 [_] [Str s NE.:| []]) = Just s isCommitVersion _ = Nothing -- | @commitVersion timestamp commit@ constructs a commit version. commitVersion :: T.Text -> T.Text -> SemVer commitVersion time commit = - SemVer 0 0 0 [[Str time]] [[Str commit]] + SemVer 0 0 0 [Str time NE.:| []] [Str commit NE.:| []] -- | Unfortunately, Data.Versions has a buggy semver parser that -- collapses consecutive zeroes in the metadata field. So, we define diff --git a/stack.yaml b/stack.yaml index e58d95880a..f5cc651a35 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,6 +5,7 @@ packages: extra-deps: - sexp-grammar-2.2.1@sha256:a05a86f83e7d1d9767fbc1b0cba7859455a10c6365173b72c10f5b0e93140a50,2473 - invertible-grammar-0.1.3@sha256:aeae40093db800e1130b8f58ae47f4474b131c22d830913d1051d1ab083f6f13,1651 + - versions-4.0.1 flags: {}