mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-10-26 09:37:17 +03:00
5884ab02be
The Overlays branch This is a major reorganization in how haskell.nix is used, and marks our 1.0 release. The branch doesn't build due to numerous issues that we believe to be with the CI and not this branch. We expect only very minor adjustments prior to calling this the official 1.0 release. * Move iohk-nix patches into haskell.nix This moves the customizations we did in iohk-nix into haskell.nix via overlays and config. Add bootPkgs logic this moves the nuking of bootPkgs where it belongs. This should eventually still be removed and replaced by a proper solution, that doesn't require the nuking of bootPkgs. Allow us to bootstrap binary ghcs and a cabal-install With this we can do the following: ``` $ nix repl compiler/old-ghc-nix nix-repl> :b (let pkgs = import <nixpkgs> {}; in with import ./. {}; import ./compiler/bootstrap/cabal-install.nix { inherit (pkgs) fetchurl stdenv zlib; inherit hackage ; ghc = ghc844; src = pkgs.fetchurl { url = "https://github.com/haskell/cabal/archive/Cabal-v3.0.0.0-rc3.tar.gz"; sha256 = "1zl2mgg8307ykq3v8nmafc6zdhhj1cw7w8ffpap16dsm6 5lbnx33"; }; }) ``` which wile it may look daunting, will allow us to bootstrap a cabal-install with a ghc. From that point onwards, we should be able to build any hackage package via haskell.nix. Pass through cabal-install version Better threading of arguments. Add bootstrap overlay Allow alex + happy to be built This still has a wart: we need nix-tools, and for that we use the ghc865 from nixpkgs. Ideally we'd build nix-tools against a specific ghc, but then we'd need a build expression for that. Make ghcjs work Building something like this: ``` nix build '(with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; }; (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; })).components.exes.hello' ``` will now work. Assuming `nixpkgs` has been appropriately patched to support the `js-unknown-ghcjs` triple. Also: this will need an additional `Cabal` patch, to make `Cabal` understand what it needs to do with: `dist/build/hello/hello: copyFile: does not exist (No such file or directory)` It needs to learn that `dist/build/hello/hello.jsexe` is what it wants to copy and that that is a directory. Luckily we do have some code in Cabal already that does this for `.exe` on windows. Build `js-unknown-ghcjs` packages with haskell.nix Using the following expression: ``` with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; }; let Cabal = buildPackages.haskell-nix.hackage-package { name = "Cabal"; version = "2.4.1.0"; modules = [ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; } ]; }; in (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; modules = [ ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; }) ];}).components.exes.hello ``` in a `test.nix` file. And running ``` nix build -f ./test.nix ``` on it, will produce ``` ./result ├── bin │ └── hello.jsexe │ ├── all.js │ ├── all.js.externs │ ├── index.html │ ├── lib.js │ ├── manifest.webapp │ ├── out.frefs.js │ ├── out.frefs.json │ ├── out.js │ ├── out.stats │ ├── rts.js │ └── runmain.js └── share └── doc └── x86_64-linux-ghc-8.6.5 └── hello-1.0.0.2 └── LICENSE 6 directories, 12 files ```
121 lines
4.8 KiB
Diff
121 lines
4.8 KiB
Diff
--- darcs-2.14.2/Setup.hs 2019-01-27 03:14:51.000000000 +1300
|
|
+++ darcs.net/Setup.hs 2019-10-18 02:41:57.000000000 +1300
|
|
@@ -11,7 +11,9 @@
|
|
, TestSuite(testBuildInfo)
|
|
, updatePackageDescription
|
|
, cppOptions, ccOptions
|
|
- , library, libBuildInfo, otherModules )
|
|
+ , library, libBuildInfo, otherModules
|
|
+ , ComponentName(CExeName)
|
|
+ )
|
|
import Distribution.Package
|
|
( packageVersion )
|
|
import Distribution.Version( Version )
|
|
@@ -21,24 +23,27 @@
|
|
import Distribution.Simple.Setup
|
|
(buildVerbosity, copyDest, copyVerbosity, fromFlag,
|
|
haddockVerbosity, installVerbosity, sDistVerbosity, replVerbosity )
|
|
-import Distribution.Simple.BuildPaths ( autogenModulesDir )
|
|
+import Distribution.Simple.BuildPaths ( autogenPackageModulesDir )
|
|
import Distribution.System
|
|
( OS(Windows), buildOS )
|
|
import Distribution.Simple.Utils
|
|
(copyFiles, createDirectoryIfMissingVerbose, rawSystemStdout,
|
|
- rewriteFile )
|
|
+ rewriteFileEx)
|
|
+import Distribution.Types.UnqualComponentName
|
|
import Distribution.Verbosity
|
|
- ( Verbosity )
|
|
+ ( Verbosity, silent )
|
|
import Distribution.Text
|
|
( display )
|
|
-import Control.Monad ( unless, void )
|
|
|
|
+import Control.Monad ( unless, when, void )
|
|
import System.Directory
|
|
( doesDirectoryExist, doesFileExist )
|
|
import System.IO
|
|
( openFile, IOMode(..) )
|
|
import System.Process (runProcess)
|
|
import Data.List( isInfixOf, lines )
|
|
+import qualified Data.Map as M
|
|
+import Data.Maybe ( isJust )
|
|
import System.FilePath ( (</>) )
|
|
import Foreign.Marshal.Utils ( with )
|
|
import Foreign.Storable ( peek )
|
|
@@ -75,8 +80,8 @@
|
|
verb = fromFlag $ sDistVerbosity flags
|
|
x <- versionPatches verb pkgVer
|
|
y <- context verb
|
|
- rewriteFile "release/distributed-version" $ show x
|
|
- rewriteFile "release/distributed-context" $ show y
|
|
+ rewriteFileEx silent "release/distributed-version" $ show x
|
|
+ rewriteFileEx silent "release/distributed-context" $ show y
|
|
putStrLn "about to hand over"
|
|
let pkg' = pkg { library = sanity (library pkg) }
|
|
sanity (Just lib) = Just $ lib { libBuildInfo = sanity' $ libBuildInfo lib }
|
|
@@ -105,8 +110,7 @@
|
|
littleEndian <- testEndianness
|
|
let args = ("-DPACKAGE_VERSION=" ++ show' version) :
|
|
[arg | (arg, True) <- -- include fst iff snd.
|
|
- [-- We have MAPI iff building on/for Windows.
|
|
- ("-DHAVE_MAPI", buildOS == Windows),
|
|
+ [
|
|
("-DLITTLEENDIAN", littleEndian),
|
|
("-DBIGENDIAN", not littleEndian)]]
|
|
bi = emptyBuildInfo { cppOptions = args, ccOptions = args }
|
|
@@ -133,20 +137,26 @@
|
|
-- man page
|
|
-- ---------------------------------------------------------------------
|
|
|
|
+hasDarcsExe :: LocalBuildInfo -> Bool
|
|
+hasDarcsExe = isJust . M.lookup darcsExe . componentNameMap where
|
|
+ darcsExe = CExeName (mkUnqualComponentName "darcs")
|
|
+
|
|
buildManpage :: LocalBuildInfo -> IO ()
|
|
-buildManpage lbi = do
|
|
- let darcs = buildDir lbi </> "darcs/darcs"
|
|
- manpage = buildDir lbi </> "darcs/darcs.1"
|
|
- manpageHandle <- openFile manpage WriteMode
|
|
- void $ runProcess darcs ["help","manpage"]
|
|
- Nothing Nothing Nothing (Just manpageHandle) Nothing
|
|
+buildManpage lbi =
|
|
+ when (hasDarcsExe lbi) $ do
|
|
+ let darcs = buildDir lbi </> "darcs/darcs"
|
|
+ manpage = buildDir lbi </> "darcs/darcs.1"
|
|
+ manpageHandle <- openFile manpage WriteMode
|
|
+ void $ runProcess darcs ["help","manpage"]
|
|
+ Nothing Nothing Nothing (Just manpageHandle) Nothing
|
|
|
|
-installManpage :: PackageDescription -> LocalBuildInfo
|
|
- -> Verbosity -> CopyDest -> IO ()
|
|
+installManpage :: PackageDescription -> LocalBuildInfo -> Verbosity -> CopyDest -> IO ()
|
|
installManpage pkg lbi verbosity copy =
|
|
- copyFiles verbosity
|
|
- (mandir (absoluteInstallDirs pkg lbi copy) </> "man1")
|
|
- [(buildDir lbi </> "darcs", "darcs.1")]
|
|
+ when (hasDarcsExe lbi) $
|
|
+ copyFiles
|
|
+ verbosity
|
|
+ (mandir (absoluteInstallDirs pkg lbi copy) </> "man1")
|
|
+ [(buildDir lbi </> "darcs", "darcs.1")]
|
|
|
|
-- ---------------------------------------------------------------------
|
|
-- version module
|
|
@@ -187,12 +197,13 @@
|
|
generateVersionModule :: Verbosity -> LocalBuildInfo
|
|
-> String -> String -> IO ()
|
|
generateVersionModule verbosity lbi version state = do
|
|
- let dir = autogenModulesDir lbi
|
|
+ let dir = autogenPackageModulesDir lbi
|
|
createDirectoryIfMissingVerbose verbosity True dir
|
|
ctx <- context verbosity
|
|
hash <- weakhash verbosity
|
|
- rewriteFile (dir </> "Version.hs") $ unlines
|
|
+ rewriteFileEx silent (dir </> "Version.hs") $ unlines
|
|
["module Version where"
|
|
+ ,"import Darcs.Prelude"
|
|
,"version, weakhash, context :: String"
|
|
,"version = \"" ++ version ++ " (" ++ state ++ ")\""
|
|
,"weakhash = " ++ case hash of
|