git.iko.soy/typeable/cabal2nix
on master help sign in
Fix generation from local archives and rel. paths

`nix-prefetch-zip` cannot handle relative paths. Therefore, we need to resolve the relative path before passing it to `nix-prefetch-zip`. You also probably don't want a relative path in your derivation when generating from an archive file. Also, `cabal2nix` now automatically adds a `./` in front of paths that contain no slash (this is needed for nix to recognize the path).

commitb217210538e51c79d222fd71e82e374edce0dec9 authorBenno Fünfstück <benno.fuenfstueck@gmail.com> dateMon 18 Aug 2014, 11:45 (12 years ago) parent37f1a2c
1 file changed+6−3
src/Distribution/NixOS/Fetch.hs+6−3
src/Distribution/NixOS/Fetch.hs+6−3
@@ -62,12 +62,15 @@ fetch f = runMaybeT . fetchers where
6262 existsFile <- liftIO $ doesFileExist path
6363 existsDir <- liftIO $ doesDirectoryExist path
6464 guard $ existsDir || existsFile
65− process (DerivationSource "" path "" "", path) <|> localArchive path
65+ let path' | '/' `elem` path = path
66+ | otherwise = "./" ++ path
67+ process (DerivationSource "" path' "" "", path') <|> localArchive path'
6668
6769 localArchive :: FilePath -> MaybeT IO (DerivationSource, a)
6870 localArchive path = do
69− unpacked <- snd <$> fetchWith (False, "zip") (Source ("file://" ++ path) "" Nothing)
70− process (DerivationSource "" path "" "", unpacked)
71+ absolutePath <- liftIO $ canonicalizePath path
72+ unpacked <- snd <$> fetchWith (False, "zip") (Source ("file://" ++ absolutePath) "" Nothing)
73+ process (DerivationSource "" absolutePath "" "", unpacked)
7174
7275 process :: (DerivationSource, FilePath) -> MaybeT IO (DerivationSource, a)
7376 process (derivSource, file) = (,) derivSource <$> f file