@@ -19,62 +19,19 @@ Let us assume for now that we have already generated a `pkgs.nix`
19
19
expression (see the links bellow). The following file then produces a package set:
20
20
21
21
``` nix
22
- # default.nix
23
- let
24
- # Import the Haskell.nix library,
25
- pkgs = import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs;
26
-
27
- # Import the file you will create in the stack-to-nix or cabal-to-nix step.
28
- my-pkgs = import ./pkgs.nix;
29
-
30
- # Stack projects use this:
31
- pkgSet = pkgs.haskell-nix.mkStackPkgSet {
32
- stack-pkgs = my-pkgs;
33
- pkg-def-extras = [
34
- # these extras will provide additional packages
35
- # ontop of the package set. E.g. extra-deps
36
- # for stack packages. or local packages for
37
- # cabal.projects
38
- ];
39
- modules = [
40
- # specific package overrides would go here
41
- # example:
42
- # packages.cbors.package.ghcOptions = "-Werror";
43
- # packages.cbors.patches = [ ./one.patch ];
44
- # packages.cbors.flags.optimize-gmp = false;
45
- # It may be better to set flags in stack.yaml instead
46
- # (`stack-to-nix` will include them as defaults).
47
- ];
48
- };
49
-
50
- # Cabal projects use this:
51
- pkgSet = pkgs.haskell-nix.mkCabalProjectPkgSet {
52
- plan-pkgs = my-pkgs;
53
- pkg-def-extras = [];
54
- modules = [
55
- # specific package overrides would go here
56
- # example:
57
- # packages.cbors.package.ghcOptions = "-Werror";
58
- # packages.cbors.patches = [ ./one.patch ];
59
- # packages.cbors.flags.optimize-gmp = false;
60
- # It may be better to set flags in `cabal.project` instead
61
- # (`plan-to-nix` will include them as defaults).
62
- ];
63
- };
64
-
65
- in pkgSet.config.hsPkgs // { _config = pkgSet.config; }
22
+ {{#include manually-generating-nix-expressions/default.nix}}
66
23
```
67
24
68
25
With this setup you can then start building the components of
69
26
interest:
70
27
71
- ``` bash
28
+ ``` shell
72
29
nix build -f default.nix $pkg .components.library
73
30
```
74
31
75
32
to build the library for ` $pkg ` or
76
33
77
- ``` bash
34
+ ``` shell
78
35
nix build -f default.nix $pkg .components.exes.$exe
79
36
```
80
37
@@ -85,7 +42,7 @@ to build a specific executable. The same holds for test suites and benchmarks.
85
42
With [ nix-tools installed] ( ./installing-nix-tools.md ) , we can simply run the
86
43
following command on a stack project:
87
44
88
- ``` bash
45
+ ``` shell
89
46
stack-to-nix --output . --stack-yaml stack.yaml
90
47
```
91
48
@@ -121,34 +78,36 @@ about how to choose a specific compiler version.
121
78
122
79
[ compiler ] : https://nixos.org/nixpkgs/manual/#how-to-install-a-compiler
123
80
124
- !!! note "Cabal version"
125
- The minimum Cabal version is 2.4. This version is available
126
- in the NixOS 19.03 release.
81
+ > ** Note:** Cabal version
82
+ >
83
+ > The minimum Cabal version is 2.4. This version is available
84
+ > in the NixOS 19.03 release.
127
85
128
86
For this example, we will run a ` nix-shell ` with the default GHC
129
87
version for Nixpkgs.
130
88
131
- ``` bash
89
+ ``` shell
132
90
nix-shell -p haskellPackages.cabal-install haskellPackages.ghc \
133
91
--run " cabal new-configure"
134
92
```
135
93
136
94
If all goes well, you should now have the file
137
95
` dist-newstyle/cache/plan.json ` .
138
96
139
- !!! tip "Specifying the GHC version"
140
- To use a specific compiler version, replace ` haskellPackages.ghc `
141
- with something like ` haskell-nix.compiler.ghc865 ` . The given compiler
142
- must exist in your Nixpkgs version, of course. See also the
143
- [ Nixpkgs Manual] [ compiler ] .
97
+ > ** Tip:** Specifying the GHC version
98
+ >
99
+ > To use a specific compiler version, replace ` haskellPackages.ghc `
100
+ > with something like ` haskell-nix.compiler.ghc865 ` . The given compiler
101
+ > must exist in your Nixpkgs version, of course. See also the
102
+ > [ Nixpkgs Manual] [ compiler ] .
144
103
145
104
### Using ` plan-to-nix `
146
105
147
106
With [ nix-tools installed] ( ./installing-nix-tools.md ) , we can then run the
148
107
following command on a Cabal project and its build plan. Omit the
149
108
` --cabal-project ` option if you don't have a project file.
150
109
151
- ``` bash
110
+ ``` shell
152
111
# convert the plan.json file into a pkgs.nix file
153
112
plan-to-nix --output . \
154
113
--plan-json dist-newstyle/cache/plan.json
0 commit comments