packages feed

stack2nix 0.2 → 0.2.1

raw patch · 6 files changed

+46/−25 lines, 6 files

Files

ChangeLog.md view
@@ -1,5 +1,15 @@ # Changelog +## v0.2.1 (2018-09-04)++Bug fixes:++- null bin-package-db for GHC 7.10 #118+- Bump cabal2nix and remove upper bound #120+- Parse mac operating system as osx or darwin #123+- Don't use `src = ./.` #121+- Pass --compiler to calls to cabal2nix #115+ ## v0.2 (2018-07-24)  Major changes:
src/Stack2nix/External/Cabal2nix.hs view
@@ -14,12 +14,13 @@ import           Distribution.System         (Platform(..), Arch(..), OS(..)) import           Language.Nix import           System.IO                   (hPutStrLn, stderr)+import           Stack.Types.Version         (Version) import           Stack2nix.Types             (Args (..))  import           Text.PrettyPrint.HughesPJClass (Doc) -cabal2nix :: Args -> FilePath -> Maybe Text -> Maybe FilePath -> DB.HackageDB -> IO (Either Doc Derivation)-cabal2nix Args{..} uri commit subpath hackageDB = do+cabal2nix :: Args -> Version -> FilePath -> Maybe Text -> Maybe FilePath -> DB.HackageDB -> IO (Either Doc Derivation)+cabal2nix Args{..} ghcVersion uri commit subpath hackageDB = do   let runCmdArgs = args $ fromMaybe "." subpath   hPutStrLn stderr $ unwords ("+ cabal2nix":runCmdArgs)   options <- parseArgs runCmdArgs@@ -31,6 +32,7 @@       [ maybe [] (\c -> ["--revision", unpack c]) commit       , ["--subpath", dir]       , ["--system", fromCabalPlatform argPlatform]+      , ["--compiler", "ghc-" ++ show ghcVersion]       , [uri]       ] 
src/Stack2nix/External/Stack.hs view
@@ -30,9 +30,7 @@                                                                  withBuildConfig) import           Stack.Types.BuildPlan                          (PackageLocation (..),                                                                  Repo (..))-import           Stack.Types.Compiler                           (CVType (..),-                                                                 CompilerVersion,-                                                                 getGhcVersion)+import           Stack.Types.Compiler                           (getGhcVersion) import           Stack.Types.Config import           Stack.Types.Config.Build                       (BuildCommand (..)) import           Stack.Types.Nix@@ -46,6 +44,7 @@                                                                  packageIdentifierString) import           Stack.Types.PackageName                        (PackageName) import           Stack.Types.Runner+import           Stack.Types.Version                            (Version) import           Stack2nix.External.Cabal2nix                   (cabal2nix) import           Stack2nix.Hackage                              (loadHackageDB) import           Stack2nix.Render                               (render)@@ -66,20 +65,20 @@   | NonHackagePackage PackageIdentifier (PackageLocation FilePath)   deriving (Eq, Show) -genNixFile :: Args -> FilePath -> Maybe String -> Maybe String -> DB.HackageDB -> PackageRef -> IO (Either Doc Derivation)-genNixFile args baseDir uri argRev hackageDB pkgRef = do+genNixFile :: Args -> Version -> FilePath -> Maybe String -> Maybe String -> DB.HackageDB -> PackageRef -> IO (Either Doc Derivation)+genNixFile args ghcVersion baseDir uri argRev hackageDB pkgRef = do   cwd <- getCurrentDirectory   case pkgRef of     NonHackagePackage _ident PLArchive {} -> error "genNixFile: No support for archive package locations"     HackagePackage (PackageIdentifierRevision pkg _) ->-      cabal2nix args ("cabal://" <> packageIdentifierString pkg) Nothing Nothing hackageDB+      cabal2nix args ghcVersion ("cabal://" <> packageIdentifierString pkg) Nothing Nothing hackageDB     NonHackagePackage _ident (PLRepo repo) ->-      cabal2nix args (unpack $ repoUrl repo) (Just $ repoCommit repo) (Just (repoSubdirs repo)) hackageDB+      cabal2nix args ghcVersion (unpack $ repoUrl repo) (Just $ repoCommit repo) (Just (repoSubdirs repo)) hackageDB     NonHackagePackage _ident (PLFilePath path) -> do       relPath <- makeRelativeToCurrentDirectory path       projRoot <- canonicalizePath $ cwd </> baseDir       let defDir = baseDir </> makeRelative projRoot path-      cabal2nix args (fromMaybe defDir uri) (pack <$> argRev) (const relPath <$> uri) hackageDB+      cabal2nix args ghcVersion (fromMaybe defDir uri) (pack <$> argRev) (const relPath <$> uri) hackageDB  -- TODO: remove once we use flags, options sourceMapToPackages :: Map PackageName PackageSource -> [PackageRef]@@ -99,9 +98,9 @@   -> FilePath   -> Maybe String   -> Args-  -> String+  -> Version   -> RIO env ()-planAndGenerate boptsCli baseDir remoteUri args@Args {..} ghcnixversion = do+planAndGenerate boptsCli baseDir remoteUri args@Args {..} ghcVersion = do   (_targets, _mbp, _locals, _extraToBuild, sourceMap) <- loadSourceMapFull     NeedTargets     boptsCli@@ -114,11 +113,11 @@     argThreads     (\p ->       fmap (addGhcOptions buildConf p)-        <$> genNixFile args baseDir remoteUri argRev hackageDB p+        <$> genNixFile args ghcVersion baseDir remoteUri argRev hackageDB p     )     pkgs   let locals = map (\l -> show (packageName (lpPackage l))) _locals-  liftIO $ render drvs args locals ghcnixversion+  liftIO . render drvs args locals $ nixVersion ghcVersion  -- | Add ghc-options declared in stack.yaml to the nix derivation for a package --   by adding to the configureFlags attribute of the derivation@@ -150,18 +149,21 @@   let stackFile = baseDir </> argStackYaml    ghcVersion <- getGhcVersionIO globals stackFile-  let ghcnixversion = filter (/= '.') $ show (getGhcVersion ghcVersion)-  ensureExecutable ("haskell.compiler.ghc" ++ ghcnixversion)-  withBuildConfig globals $ planAndGenerate buildOpts baseDir remoteUri args ghcnixversion+  ensureExecutable ("haskell.compiler.ghc" ++ nixVersion ghcVersion)+  withBuildConfig globals $ planAndGenerate buildOpts baseDir remoteUri args ghcVersion -getGhcVersionIO :: GlobalOpts -> FilePath -> IO (CompilerVersion 'CVWanted)+nixVersion :: Version -> String+nixVersion =+  filter (/= '.') . show++getGhcVersionIO :: GlobalOpts -> FilePath -> IO Version getGhcVersionIO go stackFile = do   cp <- canonicalizePath stackFile   fp <- parseAbsFile cp   lc <- withRunner LevelError True False ColorAuto Nothing False $ \runner ->     -- https://www.fpcomplete.com/blog/2017/07/the-rio-monad     runRIO runner $ loadConfig mempty Nothing (SYLOverride fp)-  loadCompilerVersion go lc+  getGhcVersion <$> loadCompilerVersion go lc  globalOpts :: FilePath -> FilePath -> Args -> GlobalOpts globalOpts currentDir stackRoot Args{..} =
src/Stack2nix/Render.hs view
@@ -42,6 +42,8 @@ basePackages = Set.fromList   [ "array"   , "base"+  -- bin-package-db is in GHC 7.10's boot libraries+  , "bin-package-db"   , "binary"   , "bytestring"   , "Cabal"@@ -137,8 +139,6 @@ defaultNix :: (Doc -> String) -> String -> [Doc] -> String defaultNix pp ghcnixversion drvs = unlines $  [ "# Generated using stack2nix " <> display version <> "."- , "#"- , "# Only works with sufficiently recent nixpkgs, e.g. \"NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/21a8239452adae3a4717772f4e490575586b2755.tar.gz\"."  , ""  , "{ pkgs ? (import <nixpkgs> {})"  , ", compiler ? pkgs.haskell.packages.ghc" ++ ghcnixversion
stack2nix.cabal view
@@ -1,5 +1,5 @@ name:                stack2nix-version:             0.2+version:             0.2.1 synopsis:            Convert stack.yaml files into Nix build instructions. description:         Convert stack.yaml files into Nix build instructions. license:             MIT@@ -22,7 +22,7 @@   build-depends:       base >=4.9 && <4.12                      , Cabal >= 2.0.0.2 && < 2.3                      , async >= 2.1.1.1 && < 2.3-                     , cabal2nix >= 2.10 && < 2.11+                     , cabal2nix >= 2.10                      , containers >= 0.5.7.1 && < 0.6                      , directory >= 1.3 && < 1.4                      , distribution-nixpkgs >= 1.1 && < 1.2
stack2nix/Main.hs view
@@ -39,9 +39,16 @@     -- | Copied from cabal2nix/src/Cabal2nix.hs     platformReader :: P.ReadP r Platform     platformReader = do-      arch <- P.choice [P.string "i686" >> return I386, P.string "x86_64" >> return X86_64]+      arch <- P.choice+          [ P.string "i686" >> return I386+          , P.string "x86_64" >> return X86_64+          ]       _ <- P.char '-'-      os <- P.choice [P.string "linux" >> return Linux, P.string "darwin" >> return OSX]+      os <- P.choice+          [ P.string "linux" >> return Linux+          , P.string "osx" >> return OSX+          , P.string "darwin" >> return OSX+          ]       return (Platform arch os)      readP :: P.ReadP a a -> ReadM a