elm2nix 0.2.1 → 0.3.0
raw patch · 4 files changed
+30/−6 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- elm2nix.cabal +3/−3
- elm2nix/Main.hs +2/−1
- src/Elm2Nix.hs +20/−2
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for elm2nix +## 0.3.0 (2022-09-06)++- Prevent duplicates between src and test dependencies (@gpampara)+- #48 Aeson 2 support (@gpampara)+ ## 0.2.1 (2020-11-22) - #40 Fix compatibility with newer versions of uglify.js (@turboMaCk)
elm2nix.cabal view
@@ -3,14 +3,14 @@ -- see: https://github.com/sol/hpack name: elm2nix-version: 0.2.1+version: 0.3.0 synopsis: Turn your Elm project into buildable Nix project description: Please see the README on Github at <https://github.com/domenkozar/elm2nix#readme> homepage: https://github.com/domenkozar/elm2nix#readme bug-reports: https://github.com/domenkozar/elm2nix/issues-author: Domen Kožar+author: Domen Kozar maintainer: domen@dev.si-copyright: 2017-2019 Domen Kožar+copyright: 2017-2022 Domen Kozar license: BSD3 license-file: LICENSE build-type: Simple
elm2nix/Main.hs view
@@ -47,6 +47,7 @@ $ elm2nix init > default.nix $ elm2nix convert > elm-srcs.nix+ $ elm2nix snapshot $ nix-build Note: You have to run elm2nix from top-level directory of an Elm project.@@ -56,5 +57,5 @@ opts = subparser ( command "init" (infoH (pure Init) (progDesc "Generate default.nix (printed to stdout)")) <> command "convert" (infoH (pure Convert) (progDesc "Generate Nix expressions for elm.json using nix-prefetch-url"))- <> command "snapshot" (infoH (pure Snapshot) (progDesc "Generate versions.dat"))+ <> command "snapshot" (infoH (pure Snapshot) (progDesc "Generate registry.dat")) )
src/Elm2Nix.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP #-} module Elm2Nix ( convert@@ -13,14 +14,20 @@ import Control.Monad.Except (liftIO, MonadIO) import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE) import Data.Aeson (Value(..))-import Data.List (intercalate)+import Data.List (intercalate, nub) import Data.HashMap.Strict (HashMap) import Data.String.Here import Data.Text (Text) import System.Exit (exitFailure) import System.IO (hPutStrLn, stderr) +#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.Key as AK+import qualified Data.Aeson.KeyMap as HM+#else import qualified Data.HashMap.Strict as HM+#endif+ import qualified Data.ByteString.Lazy as LBS import qualified Data.Aeson as Json import qualified Data.Text as Text@@ -59,8 +66,13 @@ v -> Left (UnexpectedValue v) v -> Left (UnexpectedValue v) where+#if MIN_VERSION_aeson(2,0,0)+ parseDep :: Json.Key -> Value -> Either Elm2NixError Dep+ parseDep name (String ver) = Right (Text.unpack (AK.toText name), Text.unpack ver)+#else parseDep :: Text -> Value -> Either Elm2NixError Dep parseDep name (String ver) = Right (Text.unpack name, Text.unpack ver)+#endif parseDep _ v = Left (UnexpectedValue v) parseDeps :: Value -> Either Elm2NixError [Dep]@@ -71,9 +83,15 @@ maybeToRight _ (Just x) = Right x maybeToRight y Nothing = Left y +#if MIN_VERSION_aeson(2,0,0)+ tryLookup :: HM.KeyMap Value -> Text -> Either Elm2NixError Value+ tryLookup hm key =+ maybeToRight (KeyNotFound key) (HM.lookup (AK.fromText key) hm)+#else tryLookup :: HashMap Text Value -> Text -> Either Elm2NixError Value tryLookup hm key = maybeToRight (KeyNotFound key) (HM.lookup key hm)+#endif -- CMDs @@ -87,7 +105,7 @@ testDeps <- either throwErr return (parseElmJsonDeps "test-dependencies" elmJson) liftIO (hPutStrLn stderr "Prefetching tarballs and computing sha256 hashes ...") - sources <- liftIO (mapConcurrently (uncurry prefetch) (deps ++ testDeps))+ sources <- liftIO (mapConcurrently (uncurry prefetch) (nub $ deps ++ testDeps)) liftIO (putStrLn (generateNixSources sources)) initialize :: IO ()