diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2018-12-11 18:10:48 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2018-12-11 18:10:48 +0300 |
commit | 8b0968b2054d3bb8d90b5ac056727f7c2ebeaed3 (patch) | |
tree | d03b70f693463fc836a8dbe4240424d2547530c8 /modules/pkgs/xinclude2nix/xinclude2nix.hs | |
parent | c4273035cf5876e3ba8ed2c6b492d31c2de290ee (diff) | |
download | nixsap-8b0968b2054d3bb8d90b5ac056727f7c2ebeaed3.tar.gz |
(* HUGE *) Use nixpkgs overlays
Diffstat (limited to 'modules/pkgs/xinclude2nix/xinclude2nix.hs')
-rw-r--r-- | modules/pkgs/xinclude2nix/xinclude2nix.hs | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/modules/pkgs/xinclude2nix/xinclude2nix.hs b/modules/pkgs/xinclude2nix/xinclude2nix.hs deleted file mode 100644 index 369f103..0000000 --- a/modules/pkgs/xinclude2nix/xinclude2nix.hs +++ /dev/null @@ -1,49 +0,0 @@ -{-# LANGUAGE Arrows #-} - -{- - Takes a list of XML files - Parses them for xi:xinclude elements - Extract included files - Prints list of included files --} -module Main - ( main - ) where - -import Data.List (isPrefixOf, stripPrefix) -import Data.Maybe (fromMaybe) -import System.Environment (getArgs) -import Text.XML.HXT.Core - ((>>>), deep, getAttrValue, hasAttr, hasName, isElem, readDocument, - returnA, runX) - -getXIncludes :: FilePath -> IO [String] -getXIncludes xmlFileName = - runX $ - readDocument [] xmlFileName >>> - deep (isElem >>> hasName "xi:include" >>> hasAttr "href") >>> - proc d -> - do href <- getAttrValue "href" -< d - returnA -< href - -getFiles :: [String] -> [String] -getFiles = map stripScheme . filter isFile - where - fileScheme = "file://" - isFile s = "/" `isPrefixOf` s || (fileScheme `isPrefixOf` s) - stripScheme u = fromMaybe u (stripPrefix fileScheme u) - -unique :: [String] -> [String] -unique [] = [] -unique (x:xs) - | x `elem` xs = unique xs - | otherwise = x : unique xs - -toNix :: [String] -> String -toNix ss = "[" ++ unwords (map show ss) ++ "]" - -main :: IO () -main = do - paths <- getArgs - includedFiles <- unique . getFiles . concat <$> mapM getXIncludes paths - putStrLn $ toNix includedFiles |