1module Main ( main ) where
6import Distribution.Text
9import Control.Exception ( assert )
11type Pkg = (String,Version,String) -- (Name, Version, Attribute)
14comparePkgByVersion :: Pkg -> Pkg -> Ordering -- prefers the latest version
15comparePkgByVersion (n1,v1,a1) (n2,v2,a2)
16 | a1 == a2 = assert (n1 == n2) (compare v2 v1)
17 | otherwise = compare a2 a1
19comparePkgByName :: Pkg -> Pkg-> Ordering
20comparePkgByName (n1,_,_) (n2,_,_) = compare (map toLower n1) (map toLower n2)
22parseHaskellPackageName :: String -> Maybe Pkg
23parseHaskellPackageName name =
24 case name `regsubmatch` "^(haskellPackages[^ \t]+)[ \t]+haskell-(.*)-ghc[0-9.]+-(.*)$" of
25 [attr,name',version] -> case simpleParse version of
26 Just version' -> Just (name',version',attr)
30getHaskellPackageList :: IO Pkgset
31getHaskellPackageList = do
32 allPkgs <- fmap lines (readProcess "bash" ["-c", "exec nix-env -qaP \\* 2>/dev/tty"] "")
33 return [ p | Just p <- map parseHaskellPackageName allPkgs ]
35stripProfilingVersions :: Pkgset -> Pkgset
36stripProfilingVersions pkgs = [ p | p@(_,_,attr) <- pkgs , not (attr =~ "ghc[0-9.]+_profiling") ]
38stripGhc721Versions :: Pkgset -> Pkgset
39stripGhc721Versions pkgs = [ p | p@(_,_,attr) <- pkgs , not (attr =~ "ghc721") ]
41selectLatestVersions :: Pkgset -> Pkgset
42selectLatestVersions = nubBy (\x y -> comparePkgByName x y == EQ) . sortBy comparePkgByVersion
44formatPackageLine :: Pkg -> String
45formatPackageLine (name,version,attr) = show (name, showVersion version, Just url)
47 url = "http://hydra.nixos.org/job/nixpkgs/trunk/" ++ attr
49regsubmatch :: String -> String -> [String]
50regsubmatch buf patt = let (_,_,_,x) = f in x
51 where f :: (String,String,String,[String])
52 f = match (makeRegexOpts compExtended execBlank patt) buf
56 pkgset <- fmap (selectLatestVersions . stripGhc721Versions . stripProfilingVersions) getHaskellPackageList
57 mapM_ (putStrLn . formatPackageLine) (sortBy comparePkgByName pkgset)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list