File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
nix-tools/lib/Distribution/Nixpkgs Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -70,24 +70,22 @@ instance FromJSON DerivationSource where
70
70
fromDerivationSource :: DerivationSource -> Source
71
71
fromDerivationSource DerivationSource {.. } = Source derivUrl derivRevision (Certain derivHash)
72
72
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
-
77
73
-- | Fetch a source, trying any of the various nix-prefetch-* scripts.
78
74
fetch :: forall a . (String -> MaybeT IO a ) -- ^ This function is passed the output path name as an argument.
79
75
-- It should return 'Nothing' if the file doesn't match the expected format.
80
76
-- This is required, because we cannot always check if a download succeeded otherwise.
81
77
-> Source -- ^ The source to fetch from.
82
78
-> 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)
84
82
[ (False , " url" , [] )
85
83
, (True , " git" , [" --fetch-submodules" ])
86
84
, (True , " hg" , [] )
87
85
, (True , " svn" , [] )
88
86
, (True , " bzr" , [] )
89
87
]
90
- where
88
+
91
89
-- | Remove '/' from the end of the path. Nix doesn't accept paths that
92
90
-- end in a slash.
93
91
stripSlashSuffix :: String -> String
You can’t perform that action at this time.
0 commit comments