@@ -1,4 +1,6 @@
11{-# LANGUAGE RecordWildCards #-}
2+{-# LANGUAGE CPP #-}
3+{-# LANGUAGE FlexibleInstances #-}
24{-# LANGUAGE OverloadedStrings #-}
35{-# LANGUAGE DeriveGeneric #-}
46{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -63,11 +65,24 @@ instance FromJSON Identifier where
6365 parseJSON (String s) = pure (review ident (T.unpack s))
6466 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
6567
68+-- aeson-0.11 introduces a general instance, so we just need a couple
69+-- of specific ones
70+#if MIN_VERSION_aeson(0,11,0)
71+instance (FromJSON v) => FromJSON (Map Identifier v) where
72+ parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
73+
74+instance (FromJSON v) => FromJSON (Map PackageName v) where
75+ parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
76+
77+parseKey :: (FromJSON k) => Text -> k
78+parseKey s = either error id (parseEither parseJSON (String s))
79+#else
6680instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where
6781 parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
6882 where
6983 parseKey :: FromJSON k => Text -> k
7084 parseKey s = either error id (parseEither parseJSON (String s))
85+#endif
7186
7287readConfiguration :: FilePath -> IO Configuration
7388readConfiguration path =