on iko/ghcjs-patch-master help sign in
README: markdown and rewrite some parts (#635)

* README: markdown and rewrite some parts Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>

commit4242f2f3cd1b2d72fffcad7420986c53baa381d9 authorDomen Kožar <domen@dev.si> dateFri 29 May 2020, 16:03 (6 years ago) parentf66f6cb
2 files changed+115−117
README.md+115 README.org−117
README.mdnew file+115
@@ -0,0 +1,115 @@
1+# `haskell.nix` is infrastructure for building Haskell packages with Nix
2+
3+[![](https://badge.buildkite.com/d453edcd29bd2f8f3f3b32c9b7d6777a33773d9671c37a6ccc.svg?branch=master)](https://buildkite.com/input-output-hk/haskell-dot-nix)
4+[![](https://img.shields.io/buildkite/c8d5a20d3ff0f440f82adb9190b43c16c91e5e47e8adfa867a/master.svg?label=nightly%20updates)](https://buildkite.com/input-output-hk/haskell-dot-nix-nightly-updates)
5+
6+`haskell.nix` can automatically translate your Cabal or Stack project and
7+its dependencies into Nix code.
8+
9+## [Documentation](https://input-output-hk.github.io/haskell.nix/)
10+
11+## Getting started
12+
13+### a) Using `cabal.project`
14+
15+Add a `default.nix`:
16+
17+```nix
18+let
19+ # Fetch the latest haskell.nix and import its default.nix
20+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
21+
22+ # haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
23+ # you will be more likely to get cache hits when using these.
24+ # But you can also just use your own, e.g. '<nixpkgs>'
25+ nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
26+
27+ # haskell.nix provides some arguments to be passed to nixpkgs, including some patches
28+ # and also the haskell.nix functionality itself as an overlay.
29+ nixpkgsArgs = haskellNix.nixpkgsArgs;
30+in
31+{ pkgs ? import nixpkgsSrc nixpkgsArgs
32+, haskellCompiler ? "ghc865"
33+}:
34+
35+# 'cabalProject' generates a package set based on a cabal.project (and the corresponding .cabal files)
36+pkgs.haskell-nix.cabalProject {
37+ # 'cleanGit' cleans a source directory based on the files known by git
38+ src = pkgs.haskell-nix.haskellLib.cleanGit { name = "haskell-nix-project"; src = ./.; };
39+ compiler-nix-name = haskellCompiler;
40+}
41+```
42+
43+Note that you'll need to add a comment specifying the expected sha256
44+output for your `source-repository-packages` in your `cabal.project`
45+file:
46+
47+```
48+source-repository-package
49+ type: git
50+ location: https://github.com/input-output-hk/iohk-monitoring-framework
51+ subdir: plugins/backend-editor
52+ tag: 4956b32f039579a0e7e4fd10793f65b4c77d9044
53+ --sha256: 03lyb2m4i6p7rpjqarnhsx21nx48fwk6rzsrx15k6274a4bv0pix
54+```
55+
56+### b) Using `stack.yaml`
57+
58+Add a `default.nix`:
59+
60+```nix
61+let
62+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
63+ nixpkgsSrc = haskellNix.sources.nixpkgs-1909;
64+ nixpkgsArgs = haskellNix.nixpkgsArgs;
65+in
66+{ pkgs ? import nixpkgsSrc nixpkgsArgs
67+}:
68+pkgs.haskell-nix.stackProject {
69+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
70+}
71+```
72+
73+To build the library component of a package in the project run:
74+
75+```shell
76+nix build -f . your-package-name.components.library
77+```
78+
79+To build an executable:
80+
81+```shell
82+nix build -f . your-package-name.components.exes.your-exe-name
83+```
84+
85+To open a shell for use with `cabal` run:
86+
87+```shell
88+nix-shell -A shellFor
89+cabal new-build your-package-name
90+cabal new-repl your-package-name:library:your-package-name
91+```
92+
93+## Using binary Cache to speed up compilation
94+
95+To use precompiled binaries you'll need:
96+
97+- to configure a binary cache by following instructions on [iohk.cachix.org](https://iohk.cachix.org).
98+- to pin `nixpkgs` according to [nix/sources.json](nix/sources.json).
99+
100+
101+## Related repos
102+
103+The `haskell.nix` repository contains the runtime system for building
104+Haskell packages in Nix. It depends on other repos, which are:
105+
106+- [nix-tools](https://github.com/input-output-hk/nix-tools) — provides the programs for generating Nix expressions from Haskell projects.
107+
108+- [hackage.nix](https://github.com/input-output-hk/hackage.nix) — the latest contents of the [Hackage](https://hackage.haskell.org/) databases, converted to Nix expressions.
109+
110+- [stackage.nix](https://github.com/input-output-hk/stackage.nix) — all of the [Stackage](https://www.stackage.org/) snapshots, converted to Nix expressions.
111+
112+## IRC Channel
113+
114+Join the [#haskell.nix](https://www.irccloud.com/invite?channel=%23haskell.nix&hostname=irc.freenode.net&port=6697&ssl=1) channel on [irc.freenode.net](https://freenode.net/) to get help or discuss
115+the development of `haskell.nix` and `nix-tools`.
README.orgdeleted−117
@@ -1,117 +0,0 @@
1−#+STARTUP: showall hidestars
2−
3−* Alternative Haskell Infrastructure for Nixpkgs
4−
5−[[https://buildkite.com/input-output-hk/haskell-dot-nix][https://badge.buildkite.com/d453edcd29bd2f8f3f3b32c9b7d6777a33773d9671c37a6ccc.svg?branch=master]]
6−[[https://buildkite.com/input-output-hk/haskell-dot-nix-nightly-updates][https://img.shields.io/buildkite/c8d5a20d3ff0f440f82adb9190b43c16c91e5e47e8adfa867a/master.svg?label=nightly%20updates]]
7−
8−=haskell.nix= is an experimental new builder for Haskell packages.
9−
10−It works by automatically translating your Cabal or Stack project and
11−its dependencies into Nix code. It provides IFD (import from derivation)
12−functions that can minimize the amount of Nix code you need to add.
13−
14−For the documentation, see https://input-output-hk.github.io/haskell.nix/.
15−
16−** Quickstart
17−
18−For =cabal.project= project add a =default.nix=:
19−
20−#+begin_src sh
21−let
22− # Fetch the latest haskell.nix and import its default.nix
23− haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
24− # haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
25− # you will be more likely to get cache hits when using these.
26− # But you can also just use your own, e.g. '<nixpkgs>'
27− nixpkgsSrc = haskellNix.sources.nixpkgs-1909;
28− # haskell.nix provides some arguments to be passed to nixpkgs, including some patches
29− # and also the haskell.nix functionality itself as an overlay.
30− nixpkgsArgs = haskellNix.nixpkgsArgs;
31−in
32−{ pkgs ? import nixpkgsSrc nixpkgsArgs
33−, haskellCompiler ? "ghc865"
34−}:
35−# 'cabalProject' generates a package set based on a cabal.project (and the corresponding .cabal files)
36−pkgs.haskell-nix.cabalProject {
37− # 'cleanGit' cleans a source directory based on the files known by git
38− src = pkgs.haskell-nix.haskellLib.cleanGit { name = "haskell-nix-project"; src = ./.; };
39− compiler-nix-name = haskellCompiler;
40−}
41−#+end_src
42−
43−Note that you'll need to add a comment specifying the expected sha256
44−output for your =source-repository-packages= in your =cabal.project=
45−file:
46−
47−#+begin_src sh
48−source-repository-package
49− type: git
50− location: https://github.com/input-output-hk/iohk-monitoring-framework
51− subdir: plugins/backend-editor
52− tag: 4956b32f039579a0e7e4fd10793f65b4c77d9044
53− --sha256: 03lyb2m4i6p7rpjqarnhsx21nx48fwk6rzsrx15k6274a4bv0pix
54−#+end_src
55−
56−For a =stack.yaml= project add a =default.nix=:
57−
58−#+begin_src sh
59−let
60− haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
61− nixpkgsSrc = haskellNix.sources.nixpkgs-1909;
62− nixpkgsArgs = haskellNix.nixpkgsArgs;
63−in
64−{ pkgs ? import nixpkgsSrc nixpkgsArgs
65−}:
66−pkgs.haskell-nix.stackProject {
67− src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
68−}
69−#+end_src
70−
71−To build the library component of a package in the project run:
72−
73−#+begin_src sh
74−nix build -f . your-package-name.components.library
75−#+end_src
76−
77−To build an executable:
78−
79−#+begin_src sh
80−nix build -f . your-package-name.components.exes.your-exe-name
81−#+end_src
82−
83−To open a shell for use with `cabal` run:
84−
85−#+begin_src sh
86−nix-shell -A shellFor
87−cabal new-build your-package-name
88−cabal new-repl your-package-name:library:your-package-name
89−#+end_src
90−
91−** Cache
92−
93−CI pushes to [[https://cachix.org][cachix]] so you can benefit from the cache
94−if you pin a combination of =haskell.nix= and =nixpkgs= built by CI.
95−
96−You'll need to configure the [[https://iohk.cachix.org][iohk cachix]]
97−as a =substituter= for =nix= and add the public key found at the url to
98−=trusted-public-keys=.
99−
100−** Related repos
101−
102−The =haskell.nix= repository contains the runtime system for building
103−Haskell packages in Nix. It depends on other repos, which are:
104−
105−- [[https://github.com/input-output-hk/nix-tools][nix-tools]] — provides the programs for generating Nix expressions from
106− Haskell projects.
107−
108−- [[https://github.com/input-output-hk/hackage.nix][hackage.nix]] — the latest contents of the [[https://hackage.haskell.org/][Hackage]] databases,
109− converted to Nix expressions.
110−
111−- [[https://github.com/input-output-hk/stackage.nix][stackage.nix]] — all of the [[https://www.stackage.org/][Stackage]] snapshots, converted to Nix
112− expressions.
113−
114−** IRC Channel
115−
116−Join the [[https://www.irccloud.com/invite?channel=%23haskell.nix&hostname=irc.freenode.net&port=6697&ssl=1][#haskell.nix]] channel on [[https://freenode.net/][irc.freenode.net]] to get help or discuss
117−the development of =haskell.nix= and =nix-tools=.