git.iko.soy/typeable/stackage2nix
on b5b1a6e help sign in
CHANGELOG.md−5
since splitsnapshots
unifiedsplit
@@ -1,8 +1,3 @@
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−
6# 0.7.1
1# 0.7.1
7- Generate stack packages `stack-yaml-packages.nix`
2- Generate stack packages `stack-yaml-packages.nix`
8
3
README.md+6−7
@@ -1,4 +1,4 @@
1−# stackage2nix (DEPRECATED)
1+# stackage2nix
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,12 +36,11 @@ stack exec -- stackage2nix \
36 ./stack.yaml
36 ./stack.yaml
37```
37```
38
38
39−To generate Stackage packages, supply the `--all-cabal-hashes` flag
39+To generate Stackage packages, you should supply additional
40−with the path to a local clone of
40+`--all-cabal-hashes` and `--lts-haskell` flags that points to
41−[all-cabal-hashes](https://github.com/commercialhaskell/all-cabal-hashes)
41+[commercialhaskell/all-cabal-hashes](https://github.com/commercialhaskell)
42−checked out on the `hackage` branch and supply the `--lts-haskell` flag
42+checked out to `hackage` branch and
43−with the path to a local clone of
44−[lts-haskell](https://github.com/commercialhaskell/lts-haskell).
43+[fpco/lts-haskell](https://github.com/fpco/lts-haskell) respectively.
45
44
46### stackage2nix wrapper
45### stackage2nix wrapper
47
46
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 --bare --branch hackage https://github.com/commercialhaskell/all-cabal-hashes.git $out
26+ git clone --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+18−25
@@ -3,9 +3,8 @@ 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.Char8 as B8
6+import Data.ByteString.Lazy as BSL
7import Data.Map as M
7import Data.Map as M
8−import Data.Tagged (Tagged(..))
9import Data.Text as T
8import Data.Text as T
10import Distribution.Nixpkgs.Hashes as NH
9import Distribution.Nixpkgs.Hashes as NH
11import Distribution.Package
10import Distribution.Package
@@ -41,34 +40,28 @@ readPackageByHash repoDir sha1Hash = do
41 let repoOpts = defaultRepositoryOptions { repoPath = repoDir }
40 let repoOpts = defaultRepositoryOptions { repoPath = repoDir }
42 repo <- openLgRepository repoOpts
41 repo <- openLgRepository repoOpts
43 buf <- runLgRepository repo $ do
42 buf <- runLgRepository repo $ do
44− oid <- parseOid sha1Hash
43+ BlobObj (Blob _ contents) <- lookupObject =<< parseOid sha1Hash
45− catBlob (Tagged oid)
44+ case contents of
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
46− parseCabal ("Git SHA1 " ++ show sha1Hash) buf
50+ Left (_, err) -> fail ("Git SHA1 " ++ show sha1Hash ++ ": " ++ show err)
51+ let
52+ hash = printSHA256 (digest (digestByName "sha256") buf)
53+ pkg = setCabalFileHash hash cabal
54+ return (pkg, hash)
47
55
48readPackageByName :: FilePath -> PackageIdentifier -> IO (GenericPackageDescription, SHA256Hash)
56readPackageByName :: FilePath -> PackageIdentifier -> IO (GenericPackageDescription, SHA256Hash)
49readPackageByName repoDir (PackageIdentifier name version) = do
57readPackageByName repoDir (PackageIdentifier name version) = do
50− let cabalFile = unPackageName name </> display version </> unPackageName name <.> "cabal"
58+ let cabalFile = repoDir </> unPackageName name </> display version </> unPackageName name <.> "cabal"
51− let repoOpts = defaultRepositoryOptions { repoPath = repoDir }
59+ buf <- BS.readFile cabalFile
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
67− cabal <- let (_, res) = runParseResult (parseGenericPackageDescription blob)
60+ cabal <- let (_, res) = runParseResult (parseGenericPackageDescription buf)
68 in case res of Right a -> return a
61 in case res of Right a -> return a
69− Left (_, err) -> fail (what ++ ": " ++ show err)
62+ Left (_, err) -> fail (cabalFile ++ ": " ++ show err)
70 let
63 let
71− hash = NH.printSHA256 (SSL.digest (SSL.digestByName "sha256") blob)
64+ hash = NH.printSHA256 (SSL.digest (SSL.digestByName "sha256") buf)
72 pkg = setCabalFileHash hash cabal
65 pkg = setCabalFileHash hash cabal
73 return (pkg, hash)
66 return (pkg, hash)
74
67
stackage2nix.cabal+1−2
@@ -1,5 +1,5 @@
1name: stackage2nix
1name: stackage2nix
2−version: 0.7.2
2+version: 0.7.1
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,7 +51,6 @@ library
51 , optparse-applicative
51 , optparse-applicative
52 , pretty
52 , pretty
53 , stackage-curator >= 0.15
53 , stackage-curator >= 0.15
54− , tagged
55 , text
54 , text
56 , unordered-containers
55 , unordered-containers
57 , yaml
56 , yaml