Skip to content

Commit

Permalink
Use the newest version of 'versions'. (#1165)
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Oct 25, 2020
1 parent 4bf4ba1 commit b7d8e61
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 38 deletions.
2 changes: 1 addition & 1 deletion 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
Expand Down
80 changes: 53 additions & 27 deletions default.nix
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion futhark.cabal
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions futhark.nix
Expand Up @@ -3,15 +3,15 @@
, 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
, vector-binary-instances, versions, zip-archive, zlib
}:
mkDerivation {
pname = "futhark";
version = "0.17.0";
version = "0.19.0";
src = ./.;
isLibrary = true;
isExecutable = true;
Expand All @@ -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
Expand All @@ -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";
Expand Down
27 changes: 27 additions & 0 deletions 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;
}
19 changes: 19 additions & 0 deletions 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;
}
4 changes: 2 additions & 2 deletions src/Futhark/Pkg/Info.hs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Futhark/Pkg/Types.hs
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Expand Up @@ -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: {}

Expand Down

0 comments on commit b7d8e61

Please sign in to comment.