git.iko.soy/typeable/cabal2nix
on master help sign in
Strip slashes from end of path. Fixes #85

Nix doesn't accept paths that end with a slash, so we need to remove the slashes.

commitaa25762a878b93dea0e66725419f73af1adc2bee authorBenno Fünfstück <benno.fuenfstueck@gmail.com> dateMon 25 Aug 2014, 09:21 (12 years ago) parent3df9183
1 file changed+6−1
src/Distribution/NixOS/Fetch.hs+6−1
src/Distribution/NixOS/Fetch.hs+6−1
@@ -56,13 +56,18 @@ fetch f = runMaybeT . fetchers where
5656 , (True, "bzr")
5757 ]
5858
59+ -- | Remove '/' from the end of the path. Nix doesn't accept paths that
60+ -- end in a slash.
61+ stripSlashSuffix :: String -> String
62+ stripSlashSuffix = reverse . dropWhile (== '/') . reverse
63+
5964 fetchLocal :: Source -> MaybeT IO (DerivationSource, a)
6065 fetchLocal src = do
6166 let path = stripPrefix "file://" $ sourceUrl src
6267 existsFile <- liftIO $ doesFileExist path
6368 existsDir <- liftIO $ doesDirectoryExist path
6469 guard $ existsDir || existsFile
65− let path' | '/' `elem` path = path
70+ let path' | '/' `elem` path = stripSlashSuffix path
6671 | otherwise = "./" ++ path
6772 process (DerivationSource "" path' "" "", path') <|> localArchive path'
6873