stack2nix 0.2.2 → 0.2.3
raw patch · 8 files changed
+45/−21 lines, 8 filesdep +bytestring
Dependencies added: bytestring
Files
- ChangeLog.md +12/−0
- src/Stack2nix.hs +5/−4
- src/Stack2nix/External/Cabal2nix.hs +2/−1
- src/Stack2nix/External/Stack.hs +3/−1
- src/Stack2nix/Render.hs +4/−1
- src/Stack2nix/Types.hs +14/−12
- stack2nix.cabal +3/−2
- stack2nix/Main.hs +2/−0
ChangeLog.md view
@@ -1,5 +1,17 @@ # Changelog +## v0.2.3 (2019-04-29)++Added:++- Add flag `--no-ensure-executables` to stop `stack2nix` from ensuring+ necessary executables exist #164+- Allow extra cabal2nix flags #156++Bug Fixes:++- When writing nix expressions to file (`-o` flag), force UTF-8 encoding #164+ ## v0.2.2 (2019-01-17) Bug fixes:
src/Stack2nix.hs view
@@ -8,7 +8,7 @@ , version ) where -import Control.Monad (unless, void)+import Control.Monad (unless, void, when) import Data.Maybe (isJust) import Data.Monoid ((<>)) import Paths_stack2nix (version)@@ -26,9 +26,10 @@ stack2nix :: Args -> IO () stack2nix args@Args{..} = do- ensureExecutableExists "cabal" "cabal-install"- ensureExecutableExists "git" "git"- ensureExecutableExists "nix-prefetch-git" "nix-prefetch-scripts"+ when argEnsureExecutables $ do+ ensureExecutableExists "cabal" "cabal-install"+ ensureExecutableExists "git" "git"+ ensureExecutableExists "nix-prefetch-git" "nix-prefetch-scripts" assertMinVer "git" "2" assertMinVer "cabal" "2" setEnv "GIT_QUIET" "y"
src/Stack2nix/External/Cabal2nix.hs view
@@ -8,7 +8,7 @@ import Cabal2nix (cabal2nixWithDB, parseArgs, optNixpkgsIdentifier, Options) import Control.Lens import Data.Bool (bool)-import Data.Maybe (fromMaybe)+import Data.Maybe (fromMaybe, maybeToList) import Data.Text (Text, unpack) import qualified Distribution.Nixpkgs.Haskell.Hackage as DB import Distribution.Nixpkgs.Haskell.Derivation (Derivation)@@ -32,6 +32,7 @@ args :: FilePath -> [String] args dir = concat [ maybe [] (\c -> ["--revision", unpack c]) commit+ , maybeToList argCabal2nixArgs , ["--subpath", dir] , ["--system", fromCabalPlatform argPlatform] , ["--compiler", "ghc-" ++ show ghcVersion]
src/Stack2nix/External/Stack.hs view
@@ -7,6 +7,7 @@ ) where import Control.Lens ((%~))+import Control.Monad (when) import Data.List (concat) import qualified Data.Map.Strict as M import Data.Maybe (fromJust)@@ -156,7 +157,8 @@ let stackFile = baseDir </> argStackYaml ghcVersion <- getGhcVersionIO globals stackFile- ensureExecutable ("haskell.compiler.ghc" ++ nixVersion ghcVersion)+ when argEnsureExecutables $+ ensureExecutable ("haskell.compiler.ghc" ++ nixVersion ghcVersion) withBuildConfig globals $ planAndGenerate buildOpts baseDir remoteUri args ghcVersion nixVersion :: Version -> String
src/Stack2nix/Render.hs view
@@ -8,12 +8,15 @@ import Control.Lens import Control.Monad (when)+import qualified Data.ByteString as BS import Data.Either (lefts, rights) import Data.List (filter, isPrefixOf, sort) import Data.Monoid ((<>)) import Data.Set (Set) import qualified Data.Set as Set+import qualified Data.Text as Text+import Data.Text.Encoding (encodeUtf8) import Distribution.Nixpkgs.Haskell.BuildInfo (haskell, pkgconfig, system, tool) import Distribution.Nixpkgs.Haskell.Derivation (Derivation,@@ -86,7 +89,7 @@ let out = defaultNix pp ghcnixversion $ renderedMissing ++ map (renderOne args locals) drvs case argOutFile args of- Just fname -> writeFile fname out+ Just fname -> BS.writeFile fname (encodeUtf8 $ Text.pack out) Nothing -> putStrLn out renderOne :: Args -> [String] -> Derivation -> Doc
src/Stack2nix/Types.hs view
@@ -5,18 +5,20 @@ import Distribution.System (Platform) data Args = Args- { argRev :: Maybe String- , argOutFile :: Maybe FilePath- , argStackYaml :: FilePath- , argThreads :: Int- , argTest :: Bool- , argBench :: Bool- , argHaddock :: Bool- , argHackageSnapshot :: Maybe UTCTime- , argPlatform :: Platform- , argUri :: String- , argIndent :: Bool- , argVerbose :: Bool+ { argRev :: Maybe String+ , argOutFile :: Maybe FilePath+ , argStackYaml :: FilePath+ , argThreads :: Int+ , argTest :: Bool+ , argBench :: Bool+ , argHaddock :: Bool+ , argHackageSnapshot :: Maybe UTCTime+ , argPlatform :: Platform+ , argUri :: String+ , argIndent :: Bool+ , argVerbose :: Bool+ , argCabal2nixArgs :: Maybe String+ , argEnsureExecutables :: Bool } deriving (Show)
stack2nix.cabal view
@@ -1,5 +1,5 @@ name: stack2nix-version: 0.2.2+version: 0.2.3 synopsis: Convert stack.yaml files into Nix build instructions. description: Convert stack.yaml files into Nix build instructions. license: MIT@@ -22,10 +22,11 @@ build-depends: base >=4.9 && <4.13 , Cabal >= 2.0.0.2 && < 2.5 , async >= 2.1.1.1 && < 2.3+ , bytestring , cabal2nix >= 2.10 , containers >= 0.5.7.1 && < 0.7 , directory >= 1.3 && < 1.4- , distribution-nixpkgs >= 1.1 && < 1.2+ , distribution-nixpkgs >= 1.1 && < 1.3 , filepath >= 1.4.1.1 && < 1.5 , hackage-db , optparse-applicative >= 0.13.2 && < 0.15
stack2nix/Main.hs view
@@ -26,6 +26,8 @@ <*> strArgument (metavar "URI") <*> flag True False (long "no-indent" <> help "disable indentation and place one item per line") <*> switch (long "verbose" <> help "verbose output")+ <*> optional (strOption $ long "cabal2nix-args" <> help "extra arguments for cabal2nix")+ <*> flag True False (long "no-ensure-executables" <> help "do not ensure required executables are installed") where -- | A parser for the date. Hackage updates happen maybe once or twice a month. -- Example: parseTime defaultTimeLocale "%FT%T%QZ" "2017-11-20T12:18:35Z" :: Maybe UTCTime