@@ -1,4 +1,6 @@
1{-# LANGUAGE RecordWildCards #-}
1{-# LANGUAGE RecordWildCards #-}
3+{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE DeriveGeneric #-}
5{-# LANGUAGE DeriveGeneric #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -63,11 +65,24 @@ instance FromJSON Identifier where
63 parseJSON (String s) = pure (review ident (T.unpack s))
65 parseJSON (String s) = pure (review ident (T.unpack s))
64 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
66 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
68+-- aeson-0.11 introduces a general instance, so we just need a couple
70+#if MIN_VERSION_aeson(0,11,0)
71+instance (FromJSON v) => FromJSON (Map Identifier v) where
72+ parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
74+instance (FromJSON v) => FromJSON (Map PackageName v) where
75+ parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
77+parseKey :: (FromJSON k) => Text -> k
78+parseKey s = either error id (parseEither parseJSON (String s))
66instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where
80instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where
67 parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
81 parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
69 parseKey :: FromJSON k => Text -> k
83 parseKey :: FromJSON k => Text -> k
70 parseKey s = either error id (parseEither parseJSON (String s))
84 parseKey s = either error id (parseEither parseJSON (String s))
72readConfiguration :: FilePath -> IO Configuration
87readConfiguration :: FilePath -> IO Configuration
73readConfiguration path =
88readConfiguration path =