Skip to content

Commit eded77c

Browse files
committed
Revert unnecessary changes to Fetch.hs
1 parent ec23351 commit eded77c

File tree

1 file changed

+4
-6
lines changed
  • nix-tools/lib/Distribution/Nixpkgs

1 file changed

+4
-6
lines changed

nix-tools/lib/Distribution/Nixpkgs/Fetch.hs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,22 @@ instance FromJSON DerivationSource where
7070
fromDerivationSource :: DerivationSource -> Source
7171
fromDerivationSource DerivationSource{..} = Source derivUrl derivRevision (Certain derivHash)
7272

73-
firstJust :: Monad m => [m (Maybe a)] -> m (Maybe a)
74-
firstJust [] = pure Nothing
75-
firstJust (x:xs) = x >>= maybe (firstJust xs) (pure . Just)
76-
7773
-- | Fetch a source, trying any of the various nix-prefetch-* scripts.
7874
fetch :: forall a. (String -> MaybeT IO a) -- ^ This function is passed the output path name as an argument.
7975
-- It should return 'Nothing' if the file doesn't match the expected format.
8076
-- This is required, because we cannot always check if a download succeeded otherwise.
8177
-> Source -- ^ The source to fetch from.
8278
-> IO (Maybe (DerivationSource, a)) -- ^ The derivation source and the result of the processing function. Returns Nothing if the download failed.
83-
fetch f source = firstJust . map runMaybeT . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)
79+
fetch f = runMaybeT . fetchers where
80+
fetchers :: Source -> MaybeT IO (DerivationSource, a)
81+
fetchers source = msum . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)
8482
[ (False, "url", [])
8583
, (True, "git", ["--fetch-submodules"])
8684
, (True, "hg", [])
8785
, (True, "svn", [])
8886
, (True, "bzr", [])
8987
]
90-
where
88+
9189
-- | Remove '/' from the end of the path. Nix doesn't accept paths that
9290
-- end in a slash.
9391
stripSlashSuffix :: String -> String

0 commit comments

Comments
 (0)