git.iko.soy/typeable/stackage2nix
on master help sign in
CHANGELOG.md+5
since splitsnapshots
unifiedsplit
@@ -1,3 +1,8 @@
1+# 0.7.2
2+- Build with ghc-8.4
3+- Drop compatibility with Cabal<2.2
4+- Don't check extra-deps when generating derivation from stack.yaml
5+
1# 0.7.1
6# 0.7.1
2- Generate stack packages `stack-yaml-packages.nix`
7- Generate stack packages `stack-yaml-packages.nix`
3
8
README.md+7−6
@@ -1,4 +1,4 @@
1−# stackage2nix
1+# stackage2nix (DEPRECATED)
2
2
3[![Build Status](https://travis-ci.org/typeable/stackage2nix.svg?branch=master)](https://travis-ci.org/typeable/stackage2nix)
3[![Build Status](https://travis-ci.org/typeable/stackage2nix.svg?branch=master)](https://travis-ci.org/typeable/stackage2nix)
4
4
@@ -36,11 +36,12 @@ stack exec -- stackage2nix \
36 ./stack.yaml
36 ./stack.yaml
37```
37```
38
38
39−To generate Stackage packages, you should supply additional
39+To generate Stackage packages, supply the `--all-cabal-hashes` flag
40−`--all-cabal-hashes` and `--lts-haskell` flags that points to
40+with the path to a local clone of
41−[commercialhaskell/all-cabal-hashes](https://github.com/commercialhaskell)
41+[all-cabal-hashes](https://github.com/commercialhaskell/all-cabal-hashes)
42−checked out to `hackage` branch and
42+checked out on the `hackage` branch and supply the `--lts-haskell` flag
43+with the path to a local clone of
43−[fpco/lts-haskell](https://github.com/fpco/lts-haskell) respectively.
44+[lts-haskell](https://github.com/commercialhaskell/lts-haskell).
44
45
45### stackage2nix wrapper
46### stackage2nix wrapper
46
47
nix/lib.nix+1−1
@@ -23,7 +23,7 @@ rec {
23 buildInputs = [ git ];
23 buildInputs = [ git ];
24 installPhase = ''
24 installPhase = ''
25 mkdir -p $out
25 mkdir -p $out
26− git clone --branch hackage https://github.com/commercialhaskell/all-cabal-hashes.git $out
26+ git clone --bare --branch hackage https://github.com/commercialhaskell/all-cabal-hashes.git $out
27 '';
27 '';
28 SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt";
28 SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt";
29 };
29 };
src/AllCabalHashes.hs+25−18
@@ -3,8 +3,9 @@ module AllCabalHashes where
3import Control.Lens hiding ((<.>))
3import Control.Lens hiding ((<.>))
4import Data.Aeson as A
4import Data.Aeson as A
5import Data.ByteString as BS
5import Data.ByteString as BS
6−import Data.ByteString.Lazy as BSL
6+import Data.ByteString.Char8 as B8
7import Data.Map as M
7import Data.Map as M
8+import Data.Tagged (Tagged(..))
8import Data.Text as T
9import Data.Text as T
9import Distribution.Nixpkgs.Hashes as NH
10import Distribution.Nixpkgs.Hashes as NH
10import Distribution.Package
11import Distribution.Package
@@ -40,28 +41,34 @@ readPackageByHash repoDir sha1Hash = do
40 let repoOpts = defaultRepositoryOptions { repoPath = repoDir }
41 let repoOpts = defaultRepositoryOptions { repoPath = repoDir }
41 repo <- openLgRepository repoOpts
42 repo <- openLgRepository repoOpts
42 buf <- runLgRepository repo $ do
43 buf <- runLgRepository repo $ do
43− BlobObj (Blob _ contents) <- lookupObject =<< parseOid sha1Hash
44+ oid <- parseOid sha1Hash
44− case contents of
45+ catBlob (Tagged oid)
45− BlobString bs -> return bs
46− BlobStringLazy bsl -> return $ BSL.toStrict bsl
47− _ -> fail $ "Git SHA1 " ++ show sha1Hash ++ ": expected single Blob"
48− cabal <- let (_, res) = runParseResult (parseGenericPackageDescription buf)
49− in case res of Right a -> return a
50− Left (_, err) -> fail ("Git SHA1 " ++ show sha1Hash ++ ": " ++ show err)
46+ parseCabal ("Git SHA1 " ++ show sha1Hash) buf
51− let
52− hash = printSHA256 (digest (digestByName "sha256") buf)
53− pkg = setCabalFileHash hash cabal
54− return (pkg, hash)
55
47
56readPackageByName :: FilePath -> PackageIdentifier -> IO (GenericPackageDescription, SHA256Hash)
48readPackageByName :: FilePath -> PackageIdentifier -> IO (GenericPackageDescription, SHA256Hash)
57readPackageByName repoDir (PackageIdentifier name version) = do
49readPackageByName repoDir (PackageIdentifier name version) = do
58− let cabalFile = repoDir </> unPackageName name </> display version </> unPackageName name <.> "cabal"
50+ let cabalFile = unPackageName name </> display version </> unPackageName name <.> "cabal"
59− buf <- BS.readFile cabalFile
51+ let repoOpts = defaultRepositoryOptions { repoPath = repoDir }
52+ repo <- openLgRepository repoOpts
53+ buf <- runLgRepository repo $ do
54+ headCommit <- resolveReference "HEAD" >>= \case
55+ Nothing -> fail "Failed to parse HEAD ref"
56+ Just oid -> lookupCommit $ Tagged oid
57+ blobOid <- commitTreeEntry headCommit (B8.pack cabalFile) >>= \case
58+ Nothing -> fail (cabalFile ++ ": no such file at HEAD")
59+ Just (BlobEntry oid PlainBlob) -> pure oid
60+ Just (BlobEntry _ _) -> fail (cabalFile ++ " is not a plain blob")
61+ _ -> fail (cabalFile ++ " points to a non-blob!")
62+ catBlob blobOid
63+ parseCabal cabalFile buf
64+
65+parseCabal :: String -> BS.ByteString -> IO (GenericPackageDescription, SHA256Hash)
66+parseCabal what blob = do
60− cabal <- let (_, res) = runParseResult (parseGenericPackageDescription buf)
67+ cabal <- let (_, res) = runParseResult (parseGenericPackageDescription blob)
61 in case res of Right a -> return a
68 in case res of Right a -> return a
62− Left (_, err) -> fail (cabalFile ++ ": " ++ show err)
69+ Left (_, err) -> fail (what ++ ": " ++ show err)
63 let
70 let
64− hash = NH.printSHA256 (SSL.digest (SSL.digestByName "sha256") buf)
71+ hash = NH.printSHA256 (SSL.digest (SSL.digestByName "sha256") blob)
65 pkg = setCabalFileHash hash cabal
72 pkg = setCabalFileHash hash cabal
66 return (pkg, hash)
73 return (pkg, hash)
67
74
stackage2nix.cabal+2−1
@@ -1,5 +1,5 @@
1name: stackage2nix
1name: stackage2nix
2−version: 0.7.1
2+version: 0.7.2
3synopsis: Convert Stack files into Nix build instructions.
3synopsis: Convert Stack files into Nix build instructions.
4homepage: https://github.com/typeable/stackage2nix#readme
4homepage: https://github.com/typeable/stackage2nix#readme
5license: BSD3
5license: BSD3
@@ -51,6 +51,7 @@ library
51 , optparse-applicative
51 , optparse-applicative
52 , pretty
52 , pretty
53 , stackage-curator >= 0.15
53 , stackage-curator >= 0.15
54+ , tagged
54 , text
55 , text
55 , unordered-containers
56 , unordered-containers
56 , yaml
57 , yaml