git.iko.soy/typeable/cabal2nix
on master help sign in
Merge pull request #108 from abbradar/master

Fetch submodules for git sources

commit7731d3b87c20cab9a419264a00b7f9dfec65d957 authorPeter Simons <simons@cryp.to> dateFri 21 Nov 2014, 15:35 (12 years ago) parent9f3de320e338a2
2 files changed+11−11
src/Cabal2Nix/Package.hs+1−1 src/Distribution/NixOS/Fetch.hs+10−10
src/Cabal2Nix/Package.hs+1−1
@@ -83,7 +83,7 @@ sourceFromHackage optHash pkgId = do
8383
8484 -- Use the cached hash (either from cache file or given on cmdline via sha256 opt)
8585 -- if available, otherwise download from hackage to compute hash.
86− maybeHash <- runMaybeT $ cachedHash <|> derivHash . fst <$> fetchWith (False, "url") (Source url "" Nothing)
86+ maybeHash <- runMaybeT $ cachedHash <|> derivHash . fst <$> fetchWith (False, "url", []) (Source url "" Nothing)
8787 case maybeHash of
8888 Just hash ->
8989 -- We need to force the hash here. If we didn't do this, then when reading the
src/Distribution/NixOS/Fetch.hs+10−10
@@ -48,12 +48,12 @@ fetch :: forall a. (String -> MaybeT IO a) -- ^ This function is passed the
4848fetch f = runMaybeT . fetchers where
4949 fetchers :: Source -> MaybeT IO (DerivationSource, a)
5050 fetchers source = msum . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)
51− [ (False, "zip")
52− , (False, "url")
53− , (True, "git")
54− , (True, "hg")
55− , (True, "svn")
56− , (True, "bzr")
51+ [ (False, "zip", [])
52+ , (False, "url", [])
53+ , (True, "git", ["--fetch-submodules"])
54+ , (True, "hg", [])
55+ , (True, "svn", [])
56+ , (True, "bzr", [])
5757 ]
5858
5959 -- | Remove '/' from the end of the path. Nix doesn't accept paths that
@@ -74,15 +74,15 @@ fetch f = runMaybeT . fetchers where
7474 localArchive :: FilePath -> MaybeT IO (DerivationSource, a)
7575 localArchive path = do
7676 absolutePath <- liftIO $ canonicalizePath path
77− unpacked <- snd <$> fetchWith (False, "zip") (Source ("file://" ++ absolutePath) "" Nothing)
77+ unpacked <- snd <$> fetchWith (False, "zip", []) (Source ("file://" ++ absolutePath) "" Nothing)
7878 process (DerivationSource "" absolutePath "" "", unpacked)
7979
8080 process :: (DerivationSource, FilePath) -> MaybeT IO (DerivationSource, a)
8181 process (derivSource, file) = (,) derivSource <$> f file
8282
8383-- | Like 'fetch', but allows to specify which script to use.
84−fetchWith :: (Bool, String) -> Source -> MaybeT IO (DerivationSource, FilePath)
85−fetchWith (supportsRev, kind) source = do
84+fetchWith :: (Bool, String, [String]) -> Source -> MaybeT IO (DerivationSource, FilePath)
85+fetchWith (supportsRev, kind, addArgs) source = do
8686 unless ((sourceRevision source /= "") || isNothing (sourceHash source) || not supportsRev) $
8787 liftIO (hPutStrLn stderr "** need a revision for VCS when the hash is given. skipping.") >> mzero
8888
@@ -106,7 +106,7 @@ fetchWith (supportsRev, kind) source = do
106106 script = "nix-prefetch-" ++ kind
107107
108108 args :: [String]
109− args = sourceUrl source : [ sourceRevision source | supportsRev ] ++ maybeToList (sourceHash source)
109+ args = addArgs ++ sourceUrl source : [ sourceRevision source | supportsRev ] ++ maybeToList (sourceHash source)
110110
111111 processOutputWithRev :: [String] -> IO (DerivationSource, FilePath)
112112 processOutputWithRev [rev,hash,path] = return (DerivationSource kind (sourceUrl source) (extractRevision rev) hash, path)