@@ -1,12 +1,12 @@
11module Distribution.Nixpkgs.PackageMap where
22
33import qualified Data.Aeson as JSON
4+import qualified Data.ByteString.Lazy as LBS
45import Data.List.Split
56import qualified Data.Map as Map
67import Data.Map.Strict ( Map )
78import Data.Set ( Set )
89import qualified Data.Set as Set
9−import qualified Data.String.UTF8 as UTF8 ( fromString, toRep )
1010import System.Process
1111
1212type Attribute = String
@@ -14,9 +14,12 @@ type Path = [Attribute]
1414
1515readNixpkgAttributeSet :: FilePath -> IO (Set Attribute)
1616readNixpkgAttributeSet nixpkgs = do
17− buf <- readProcess "nix-env" ["-qaP", "--json", "-f"++nixpkgs] ""
17+ (_, Just h, _, _) <- createProcess (proc "nix-env" ["-qaP", "--json", "-f"++nixpkgs])
18+ { std_out = CreatePipe
19+ }
20+ buf <- LBS.hGetContents h
1821 let pkgmap :: Either String (Map Attribute JSON.Object)
19− pkgmap = JSON.eitherDecodeStrict (UTF8.toRep (UTF8.fromString buf))
22+ pkgmap = JSON.eitherDecode buf
2023 either fail (return . Map.keysSet) pkgmap
2124
2225parsePackage :: Attribute -> (Attribute, Path)