on iko/ghcjs-patch-master help sign in
Merge pull request #47 from input-output-hk/rvl/hackage-stackage
7446d04Rodney Lorrimar
@@ -1,4 +1,34 @@
1−* haskell.nix
1+* Alternative Haskell Infrastructure for Nixpkgs
2
2
3+[[https://travis-ci.org/input-output-hk/haskell.nix][https://travis-ci.org/input-output-hk/haskell.nix.svg?branch=master]]
4+
5+=haskell.nix= is an experimental new builder for Haskell packages.
6+
7+It works by automatically translating your Cabal or Stack project and
8+its dependencies into Nix code. Most of your dependencies are already
9+translated, so you generally won't have too much generated code.
10+
11+For full documentation, see https://input-output-hk.github.io/haskell.nix
12+
13+** Quickstart
14+
15+This will download and build =nix-tools=.
16+
17+#+begin_src sh
18+nix build -f https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz nix-tools -o nt
19+./nt/bin/cabal-to-nix --help
20+#+end_src
21+
22+** Related repos
23+
3−This repository contains the runtime system for [[https://github.com/input-output-hk/nix-tools][nix-tools]].
24+The =haskell.nix= repository contains the runtime system for building
4−Please see [[https://github.com/input-output-hk/nix-tools][nix-tools]] for more details.
25+Haskell packages in Nix. It depends on other repos, which are:
26+
27+- [[https://github.com/input-output-hk/nix-tools][nix-tools]] — provides the programs for generating Nix expressions from
28+ Haskell projects.
29+
30+- [[https://github.com/input-output-hk/hackage.nix][hackage.nix]] — the latest contents of the [[https://hackage.haskell.org/][Hackage]] databases,
31+ converted to Nix expressions.
32+
33+- [[https://github.com/input-output-hk/stackage.nix][stackage.nix]] — all of the [[https://www.stackage.org/][Stackage]] snapshots, converted to Nix
34+ expressions.
default.nix+75−8
@@ -1,3 +1,6 @@
1+{ pkgs ? import <nixpkgs> {}
2+}:
3+
1let
4let
2 # pkg-def's may reference boot packages, but those
5 # pkg-def's may reference boot packages, but those
3 # are not guaranteed to be available on hackage, as
6 # are not guaranteed to be available on hackage, as
@@ -13,19 +16,83 @@ let
13 then filterAttrs (k: _: !(builtins.elem k boot-pkgs)) v
16 then filterAttrs (k: _: !(builtins.elem k boot-pkgs)) v
14 else v)
17 else v)
15 (pkg-def hackage);
18 (pkg-def hackage);
16−in
19+
17−hackage: let haskell = rec {
18 # ghc hackage patches.
20 # ghc hackage patches.
19 # these are patches that turn hackage packages into the same as the ones
21 # these are patches that turn hackage packages into the same as the ones
20 # ghc ships with the supposedly same version. See GHC Track Issue: 16199
22 # ghc ships with the supposedly same version. See GHC Track Issue: 16199
21 ghcHackagePatches = import ./patches;
23 ghcHackagePatches = import ./patches;
22
24
23− compat = import ./compat.nix;
25+ compat = import ./lib/compat.nix;
26+
27+ # Utility function for downloading a pinned git repo, that can be
28+ # overridden with NIX_PATH.
29+ fetchExternal = import ./lib/fetch-external.nix;
30+
31+ # All packages from Hackage as Nix expressions
32+ hackage = import (fetchExternal {
33+ name = "hackage-exprs-source";
34+ specJSON = ./hackage-src.json;
35+ override = "hackage";
36+ });
37+
38+ # The set of all Stackage snapshots
39+ stackage = import (fetchExternal {
40+ name = "stackage-snapshot-source";
41+ specJSON = ./stackage-src.json;
42+ override = "stackage";
43+ });
44+
45+ packages = self: ({
46+ # Utility functions for working with the component builder.
47+ haskellLib = let hl = import ./lib { inherit (pkgs) lib; haskellLib = hl; }; in hl;
24
48
49+ # Create a Haskell package set based on a cabal build plan (plan-to-nix)
50+ # and Nix expressions representing cabal packages (cabal-to-nix).
25− mkPkgSet
51+ mkPkgSet =
26− = { pkgs, pkg-def, pkg-def-overlays ? [], modules ? [] }@args:
52+ { pkg-def # Base package set. Either from stackage (via stack-to-nix) or from a cabal projects plan file (via plan-to-nix)
27− import ./package-set.nix (args // { inherit hackage; pkg-def = strip-pkg-def pkgs pkg-def; });
53+ , pkg-def-overlays ? [] # Additional packages to augment the Base package set `pkg-def` with.
54+ , modules ? []
55+ }@args:
28
56
29− mkNewPkgSet = args: builtins.trace "DEPRECATED: use mkPkgSet instead of mkNewPkgSet" (mkPkgSet args);
57+ import ./package-set.nix (args // {
58+ inherit hackage pkgs;
59+ pkg-def = strip-pkg-def pkgs pkg-def;
60+ });
30
61
31−}; in haskell
62+ # Create a Haskell package set based on a Stack configuration.
63+ mkStackPkgSet =
64+ { stack-pkgs # Path to the output of stack-to-nix
65+ , pkg-def-overlays ? []
66+ , modules ? []
67+ }@args:
68+
69+ let
70+ # The Stackage release referenced in the stack config
71+ pkg-def = stackage.${stack-pkgs.resolver};
72+ # The compiler referenced in the stack config
73+ compiler = (stack-pkgs.overlay hackage).compiler or (pkg-def hackage).compiler;
74+ in self.mkPkgSet {
75+ inherit pkg-def;
76+ pkg-def-overlays = [ stack-pkgs.overlay ] ++ pkg-def-overlays;
77+ modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules;
78+ };
79+
80+ # Programs for generating Nix expressions from Cabal and Stack
81+ # files.
82+ nix-tools = self.callPackage ./nix-tools {
83+ inherit fetchExternal;
84+ };
85+
86+ # Snapshots of Hackage and Stackage, converted to Nix expressions,
87+ # regularly updated.
88+ inherit hackage stackage;
89+
90+ # Scripts for keeping Hackage and Stackage up to date.
91+ maintainer-scripts = {
92+ update-hackage = self.callPackage ./scripts/update-hackage.nix {};
93+ update-stackage = self.callPackage ./scripts/update-stackage.nix {};
94+ };
95+ });
96+
97+in
98+ pkgs.lib.makeScope pkgs.newScope packages
doc/maintainer-scripts.mdnew file+18
@@ -0,0 +1,18 @@
1+# Updating Hackage and Stackage Nix expressions
2+
3+The [`hackage.nix`](https://github.com/input-output-hk/hackage.nix)
4+and [`stackage.nix`](https://github.com/input-output-hk/stackage.nix)
5+repos and corresponding files `hackage-src.json` and
6+`stackage-src.json` will be regularly and automatically updated using
7+scripts in this repo.
8+
9+To run the updater scripts manually, use:
10+
11+ nix-build -A maintainer-scripts.update-hackage -o update-hackage.sh
12+ ./update-hackage.sh
13+
14+ nix-build -A maintainer-scripts.update-stackage -o update-stackage.sh
15+ ./update-stackage.sh
16+
17+The scripts will clone the repo, generate the latest data, then
18+attempt to push back to the repo and update the source JSON file.
hackage-src.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "url": "https://github.com/input-output-hk/hackage.nix",
3+ "rev": "3180384b563ec7c7b46bca86b3ace0f32d04cde8",
4+ "date": "2019-02-05T17:32:14+08:00",
5+ "sha256": "19ndkn8pivli9plwq0wnx1cj126l89yk7jw9a0dj51ic3b2qhlb2",
6+ "fetchSubmodules": false
7+}
compat.nix → lib/compat.nixrenamed

The content is the same.

lib/fetch-external.nixnew file+16
@@ -0,0 +1,16 @@
1+# Provides a function for fetching a GitHub repo from a JSON spec,
2+# overridable with the given entry on the NIX_PATH.
3+
4+let
5+ overrideWith = import ./override-with.nix;
6+in
7+ { name, specJSON, override }:
8+ let
9+ spec = builtins.fromJSON (builtins.readFile specJSON);
10+ in
11+ overrideWith override
12+ (builtins.fetchTarball {
13+ inherit name;
14+ url = "${spec.url}/archive/${spec.rev}.tar.gz";
15+ inherit (spec) sha256;
16+ })
lib/override-with.nixnew file+9
@@ -0,0 +1,9 @@
1+# overrideWith - Allow the user to override the given default path
2+# with a NIX_PATH entry.
3+override: default:
4+ let
5+ try = builtins.tryEval (builtins.findFile builtins.nixPath override);
6+ in if try.success then
7+ builtins.trace "using search host <${override}>" try.value
8+ else
9+ default
nix-tools/default.nixnew file+15
@@ -0,0 +1,15 @@
1+{ symlinkJoin, fetchExternal, mkPkgSet }:
2+
3+let
4+ src = fetchExternal {
5+ name = "nix-tools-src";
6+ specJSON = ./nix-tools-src.json;
7+ override = "nix-tools";
8+ };
9+
10+ hsPkgs = import (src + "/pkgs.nix") { inherit mkPkgSet; };
11+in
12+ symlinkJoin {
13+ name = "nix-tools";
14+ paths = builtins.attrValues hsPkgs.nix-tools.components.exes;
15+ }
nix-tools/nix-tools-src.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "url": "https://github.com/input-output-hk/nix-tools",
3+ "rev": "232e4fde7f942ef234b649144016d5da0f7e2745",
4+ "date": "2019-02-11T12:59:38+08:00",
5+ "sha256": "1nrm9vcq443isk09z1fmlp8zxnw9p3cx95zbda29s5mky17ky2c0",
6+ "fetchSubmodules": false
7+}
scripts/update-external.nixnew file+26
@@ -0,0 +1,26 @@
1+{ stdenv, writeScript, glibc, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }:
2+
3+{ name, script }:
4+
5+with stdenv.lib;
6+
7+writeScript "update-${name}-nix.sh" ''
8+ #!${stdenv.shell}
9+
10+ set -euo pipefail
11+
12+ export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
13+
14+ ${script}
15+
16+ git add .
17+ git commit --allow-empty -m "Automatic update for $(date)"
18+
19+ rev=$(git rev-parse HEAD)
20+
21+ git push
22+
23+ cd ..
24+
25+ nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json
26+''
scripts/update-hackage.nixnew file+24
@@ -0,0 +1,24 @@
1+{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
2+
3+import ./update-external.nix args {
4+ name = "hackage";
5+ script = ''
6+ # Make sure the hackage index is recent.
7+ cabal new-update
8+
9+ # Clone or update the Hackage Nix expressions repo.
10+ if [ -d hackage.nix ]; then
11+ cd hackage.nix
12+ git pull --ff-only
13+ cd ..
14+ else
15+ git clone git@github.com:input-output-hk/hackage.nix.git
16+ fi
17+
18+ echo "Running hackage-to-nix..."
19+
20+ hackage-to-nix hackage.nix
21+
22+ cd hackage.nix
23+ '';
24+}
scripts/update-stackage.nixnew file+44
@@ -0,0 +1,44 @@
1+{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
2+
3+import ./update-external.nix args {
4+ name = "stackage";
5+ script = ''
6+ # Clone or update the main Stackage Nix expressions repo.
7+ # The upstream LTS and Nightly package sets are in submodules, which
8+ # should also be updated.
9+ if [ -d stackage.nix ]; then
10+ cd stackage.nix
11+ git pull --ff-only
12+ git submodule update --init
13+ git submodule foreach git pull origin master
14+ else
15+ git clone git@github.com:input-output-hk/stackage.nix.git
16+ cd stackage.nix
17+ git submodule update --init
18+ fi
19+
20+ echo "Running lts-to-nix for all snapshots..."
21+
22+ # update them all in parallel...
23+ N=$(getconf _NPROCESSORS_ONLN)
24+ for lts in {lts-haskell,stackage-nightly}/*.yaml
25+ do
26+ lts-to-nix $lts > $(basename ''${lts%.yaml}.nix) &
27+ while [[ $(jobs -r -p | wc -l) -gt $N ]]; do
28+ # can't use `wait -n` on older bash versions.
29+ # e.g. what ships with macOS High Sierra
30+ sleep 1;
31+ done
32+ done
33+ wait
34+
35+ # update nightlies
36+ echo "{" > nightlies.nix;
37+ for a in nightly-*.nix; do echo " \"''${a%%.nix}\" = import ./$a;" >> nightlies.nix; done;
38+ echo "}" >> nightlies.nix
39+ # update lts
40+ echo "{" > ltss.nix;
41+ for a in lts-*.nix; do echo " \"''${a%%.nix}\" = import ./$a;" >> ltss.nix; done;
42+ echo "}" >> ltss.nix
43+ '';
44+}
stackage-src.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "url": "https://github.com/input-output-hk/stackage.nix",
3+ "rev": "2615a4e6b1651215ee400e62fcdcb195062a3d35",
4+ "date": "2019-02-05T17:41:44+08:00",
5+ "sha256": "08c8lb8x047hndwm1cb2zxixnjmrswfp5y18xp1v79cjqlva0qj6",
6+ "fetchSubmodules": false
7+}
test/builder-haddock/default.nix+2−6
@@ -1,13 +1,9 @@
1−{ pkgs
2−, haskell
3−, stdenv
1+{ mkPkgSet, stdenv }:
4−}:
5
2
6with stdenv.lib;
3with stdenv.lib;
7
4
8let
5let
9− pkgSet = haskell.mkPkgSet {
6+ pkgSet = mkPkgSet {
10− inherit pkgs;
11 # generated with:
7 # generated with:
12 # cabal new-build
8 # cabal new-build
13 # plan-to-nix dist-newstyle/cache/plan.json > plan.nix
9 # plan-to-nix dist-newstyle/cache/plan.json > plan.nix
test/cabal-22/default.nix+8−12
@@ -1,13 +1,9 @@
1−{ pkgs
2−, haskell
3−, stdenv
1+{ stdenv, mkPkgSet }:
4−}:
5
2
6with stdenv.lib;
3with stdenv.lib;
7
4
8let
5let
9− pkgSet = haskell.mkPkgSet {
6+ pkgSet = mkPkgSet {
10− inherit pkgs;
11 pkg-def = import ./plan.nix;
7 pkg-def = import ./plan.nix;
12 pkg-def-overlays = [
8 pkg-def-overlays = [
13 { project = ./project.nix; }
9 { project = ./project.nix; }
@@ -32,23 +28,23 @@ in
32 "$exe"
28 "$exe"
33
29
34 printf "checking that executable is dynamically linked to system libraries... " >& 2
30 printf "checking that executable is dynamically linked to system libraries... " >& 2
35− '' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
31+ '' + optionalString stdenv.isLinux ''
36 ldd $exe | grep libpthread
32 ldd $exe | grep libpthread
37− '' + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
33+ '' + optionalString stdenv.isDarwin ''
38 otool -L $exe | grep "libSystem.B"
34 otool -L $exe | grep "libSystem.B"
39 '' + ''
35 '' + ''
40 # fixme: posix-specific
36 # fixme: posix-specific
41 printf "checking that dynamic library is produced... " >& 2
37 printf "checking that dynamic library is produced... " >& 2
42− '' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
38+ '' + optionalString stdenv.isLinux ''
43 sofile=$(find "${packages.project.components.library}" | grep -e '\.so$')
39 sofile=$(find "${packages.project.components.library}" | grep -e '\.so$')
44− '' + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
40+ '' + optionalString stdenv.isDarwin ''
45 sofile=$(find "${packages.project.components.library}" | grep -e '\.dylib$')
41 sofile=$(find "${packages.project.components.library}" | grep -e '\.dylib$')
46 '' + ''
42 '' + ''
47 echo "$sofile"
43 echo "$sofile"
48 printf "checking that dynamic library is dynamically linked to prim... " >& 2
44 printf "checking that dynamic library is dynamically linked to prim... " >& 2
49− '' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
45+ '' + optionalString stdenv.isLinux ''
50 ldd $sofile | grep libHSghc-prim
46 ldd $sofile | grep libHSghc-prim
51− '' + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
47+ '' + optionalString stdenv.isDarwin ''
52 otool -L $sofile | grep libHSghc-prim
48 otool -L $sofile | grep libHSghc-prim
53 '' + ''
49 '' + ''
54 touch $out
50 touch $out
test/cabal-simple/default.nix+4−10
@@ -1,9 +1,5 @@
1# Test a package set
1# Test a package set
2−{ pkgs
3−, haskell
4−, stdenv
2+{ stdenv, util, mkPkgSet }:
5−, util
6−}:
7
3
8with stdenv.lib;
4with stdenv.lib;
9
5
@@ -12,8 +8,7 @@ let
12 # 1. cabal-to-nix cabal-simple.cabal > cabal-simple.nix
8 # 1. cabal-to-nix cabal-simple.cabal > cabal-simple.nix
13 # 2. cabal new-build
9 # 2. cabal new-build
14 # 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix
10 # 3. plan-to-nix ./dist-newstyle/cache/plan.json > plan.nix
15− pkgSet = haskell.mkPkgSet {
11+ pkgSet = mkPkgSet {
16− inherit pkgs;
17 pkg-def = import ./plan.nix;
12 pkg-def = import ./plan.nix;
18 pkg-def-overlays = [
13 pkg-def-overlays = [
19 { cabal-simple = ./cabal-simple.nix;
14 { cabal-simple = ./cabal-simple.nix;
@@ -45,9 +40,9 @@ in
45 $exe
40 $exe
46
41
47 printf "checking that executable is dynamically linked to system libraries... " >& 2
42 printf "checking that executable is dynamically linked to system libraries... " >& 2
48− '' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
43+ '' + optionalString stdenv.isLinux ''
49 ldd $exe | grep libpthread
44 ldd $exe | grep libpthread
50− '' + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
45+ '' + optionalString stdenv.isDarwin ''
51 otool -L $exe |grep .dylib
46 otool -L $exe |grep .dylib
52 '' + ''
47 '' + ''
53
48
@@ -68,6 +63,5 @@ in
68 # Used for testing externally with nix-shell (../tests.sh).
63 # Used for testing externally with nix-shell (../tests.sh).
69 # This just adds cabal-install to the existing shells.
64 # This just adds cabal-install to the existing shells.
70 test-shell = util.addCabalInstall packages.cabal-simple.components.all;
65 test-shell = util.addCabalInstall packages.cabal-simple.components.all;
71−
72 };
66 };
73}
67}
test/default.nix+7−14
@@ -3,29 +3,22 @@
3with pkgs;
3with pkgs;
4
4
5let
5let
6− # all packages from hackage as nix expressions
7− hackage = import (fetchFromGitHub { owner = "angerman";
8− repo = "hackage.nix";
9− rev = "5223a45e08b1b0d738fdd292b39e49f39f21536f";
10− sha256 = "09r662kn2qs444fmqni9jamaxnrk9jrg6whqmxbwhfgd5vy3yynq";
11− name = "hackage-exprs-source"; });
12
6
13 # The new Haskell infra applied to nix representation of Hackage
7 # The new Haskell infra applied to nix representation of Hackage
14− haskell = import ../. hackage;
8+ haskell = pkgs.callPackage ../. { };
15−
16− haskellLib = let hl = import ../lib { inherit lib; haskellLib = hl; }; in hl;
17
9
18 util = callPackage ./util.nix {};
10 util = callPackage ./util.nix {};
19
11
20in {
12in {
21− cabal-simple = callPackage ./cabal-simple { inherit haskell util; };
13+ cabal-simple = callPackage ./cabal-simple { inherit (haskell) mkPkgSet; inherit util; };
22− cabal-22 = callPackage ./cabal-22 { inherit haskell; };
14+ cabal-22 = callPackage ./cabal-22 { inherit (haskell) mkPkgSet; };
23− with-packages = callPackage ./with-packages { inherit haskell util; };
15+ with-packages = callPackage ./with-packages { inherit (haskell) mkPkgSet; inherit util; };
24− builder-haddock = callPackage ./builder-haddock { inherit haskell; };
16+ builder-haddock = callPackage ./builder-haddock { inherit (haskell) mkPkgSet; };
17+ stack-simple = callPackage ./stack-simple { inherit (haskell) mkStackPkgSet; };
25
18
26 # Run unit tests with: nix-instantiate --eval --strict -A unit
19 # Run unit tests with: nix-instantiate --eval --strict -A unit
27 # An empty list means success.
20 # An empty list means success.
28− unit = callPackage ./unit.nix { inherit haskellLib; };
21+ unit = callPackage ./unit.nix { inherit (haskell) haskellLib; };
29}
22}
30
23
31## possible test cases
24## possible test cases
test/stack-simple/.gitignorenew file+3
@@ -0,0 +1,3 @@
1+.stack-work/
2+stack-simple.cabal
3+*~
test/stack-simple/.stack.nix/stack-simple.nixnew file+32
@@ -0,0 +1,32 @@
1+{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }:
2+ ({
3+ flags = {};
4+ package = {
5+ specVersion = "0";
6+ identifier = { name = "stack-simple"; version = "0.1.0.0"; };
7+ license = "BSD-3-Clause";
8+ copyright = "2019 Author name here";
9+ maintainer = "example@example.com";
10+ author = "Author name here";
11+ homepage = "https://github.com/githubuser/stack-simple#readme";
12+ url = "";
13+ synopsis = "";
14+ description = "Please see the README on GitHub at <https://github.com/githubuser/stack-simple#readme>";
15+ buildType = "Simple";
16+ };
17+ components = {
18+ "library" = { depends = [ (hsPkgs.base) ]; };
19+ exes = {
20+ "stack-simple-exe" = {
21+ depends = [ (hsPkgs.base) (hsPkgs.stack-simple) ];
22+ };
23+ };
24+ tests = {
25+ "stack-simple-test" = {
26+ depends = [ (hsPkgs.base) (hsPkgs.stack-simple) ];
27+ };
28+ };
29+ };
30+ } // rec { src = (pkgs.lib).mkDefault ../.; }) // {
31+ cabal-generator = "hpack";
32+ }
test/stack-simple/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
test/stack-simple/app/Main.hsnew file+6
@@ -0,0 +1,6 @@
1+module Main where
2+
3+import Lib
4+
5+main :: IO ()
6+main = someFunc
test/stack-simple/default.nixnew file+35
@@ -0,0 +1,35 @@
1+{ stdenv, mkStackPkgSet }:
2+
3+with stdenv.lib;
4+
5+let
6+ # ./stack-pkgs.nix and ./.stack.nix/stack-simple are
7+ # generated by running hpack then stack-to-nix.
8+ pkgSet = mkStackPkgSet {
9+ stack-pkgs = import ./stack-pkgs.nix;
10+ pkg-def-overlays = [];
11+ modules = [];
12+ };
13+
14+ packages = pkgSet.config.hsPkgs;
15+
16+in
17+ stdenv.mkDerivation {
18+ name = "stack-simple-test";
19+
20+ buildCommand = ''
21+ exe="${packages.stack-simple.components.exes.stack-simple-exe}/bin/stack-simple-exe"
22+
23+ printf "checking whether executable runs... " >& 2
24+ $exe
25+
26+ touch $out
27+ '';
28+
29+ meta.platforms = platforms.all;
30+
31+ passthru = {
32+ # Attributes used for debugging with nix repl
33+ inherit pkgSet packages;
34+ };
35+ }
test/stack-simple/package.yamlnew file+48
@@ -0,0 +1,48 @@
1+name: stack-simple
2+version: 0.1.0.0
3+github: "githubuser/stack-simple"
4+license: BSD3
5+author: "Author name here"
6+maintainer: "example@example.com"
7+copyright: "2019 Author name here"
8+
9+extra-source-files:
10+- README.md
11+- ChangeLog.md
12+
13+# Metadata used when publishing your package
14+# synopsis: Short description of your package
15+# category: Web
16+
17+# To avoid duplicated efforts in documentation and dealing with the
18+# complications of embedding Haddock markup inside cabal files, it is
19+# common to point users to the README.md file.
20+description: Please see the README on GitHub at <https://github.com/githubuser/stack-simple#readme>
21+
22+dependencies:
23+- base >= 4.7 && < 5
24+
25+library:
26+ source-dirs: src
27+
28+executables:
29+ stack-simple-exe:
30+ main: Main.hs
31+ source-dirs: app
32+ ghc-options:
33+ - -threaded
34+ - -rtsopts
35+ - -with-rtsopts=-N
36+ dependencies:
37+ - stack-simple
38+
39+tests:
40+ stack-simple-test:
41+ main: Spec.hs
42+ source-dirs: test
43+ ghc-options:
44+ - -threaded
45+ - -rtsopts
46+ - -with-rtsopts=-N
47+ dependencies:
48+ - stack-simple
test/stack-simple/src/Lib.hsnew file+6
@@ -0,0 +1,6 @@
1+module Lib
2+ ( someFunc
3+ ) where
4+
5+someFunc :: IO ()
6+someFunc = putStrLn "someFunc"
test/stack-simple/stack-pkgs.nixnew file+5
@@ -0,0 +1,5 @@
1+{
2+ overlay = hackage:
3+ { packages = {} // { stack-simple = ./.stack.nix/stack-simple.nix; }; };
4+ resolver = "lts-13.6";
5+ }
test/stack-simple/stack-simple.cabalnew file+61
@@ -0,0 +1,61 @@
1+cabal-version: 1.12
2+
3+-- This file has been generated from package.yaml by hpack version 0.31.1.
4+--
5+-- see: https://github.com/sol/hpack
6+--
7+-- hash: 0df70dbda375296766e47fd09b809934bff5ee3edb5a16e93681d4cb37cef875
8+
9+name: stack-simple
10+version: 0.1.0.0
11+description: Please see the README on GitHub at <https://github.com/githubuser/stack-simple#readme>
12+homepage: https://github.com/githubuser/stack-simple#readme
13+bug-reports: https://github.com/githubuser/stack-simple/issues
14+author: Author name here
15+maintainer: example@example.com
16+copyright: 2019 Author name here
17+license: BSD3
18+build-type: Simple
19+extra-source-files:
20+ README.md
21+ ChangeLog.md
22+
23+source-repository head
24+ type: git
25+ location: https://github.com/githubuser/stack-simple
26+
27+library
28+ exposed-modules:
29+ Lib
30+ other-modules:
31+ Paths_stack_simple
32+ hs-source-dirs:
33+ src
34+ build-depends:
35+ base >=4.7 && <5
36+ default-language: Haskell2010
37+
38+executable stack-simple-exe
39+ main-is: Main.hs
40+ other-modules:
41+ Paths_stack_simple
42+ hs-source-dirs:
43+ app
44+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
45+ build-depends:
46+ base >=4.7 && <5
47+ , stack-simple
48+ default-language: Haskell2010
49+
50+test-suite stack-simple-test
51+ type: exitcode-stdio-1.0
52+ main-is: Spec.hs
53+ other-modules:
54+ Paths_stack_simple
55+ hs-source-dirs:
56+ test
57+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
58+ build-depends:
59+ base >=4.7 && <5
60+ , stack-simple
61+ default-language: Haskell2010
test/stack-simple/stack.yamlnew file+64
@@ -0,0 +1,64 @@
1+# This file was automatically generated by 'stack init'
2+#
3+# Some commonly used options have been documented as comments in this file.
4+# For advanced use and comprehensive documentation of the format, please see:
5+# https://docs.haskellstack.org/en/stable/yaml_configuration/
6+
7+# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8+# A snapshot resolver dictates the compiler version and the set of packages
9+# to be used for project dependencies. For example:
10+#
11+# resolver: lts-3.5
12+# resolver: nightly-2015-09-21
13+# resolver: ghc-7.10.2
14+#
15+# The location of a snapshot can be provided as a file or url. Stack assumes
16+# a snapshot provided as a file might change, whereas a url resource does not.
17+#
18+# resolver: ./custom-snapshot.yaml
19+# resolver: https://example.com/snapshots/2018-01-01.yaml
20+resolver: lts-13.6
21+
22+# User packages to be built.
23+# Various formats can be used as shown in the example below.
24+#
25+# packages:
26+# - some-directory
27+# - https://example.com/foo/bar/baz-0.0.2.tar.gz
28+# - location:
29+# git: https://github.com/commercialhaskell/stack.git
30+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
31+# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
32+# subdirs:
33+# - auto-update
34+# - wai
35+packages:
36+- .
37+# Dependency packages to be pulled from upstream that are not in the resolver
38+# using the same syntax as the packages field.
39+# (e.g., acme-missiles-0.3)
40+# extra-deps: []
41+
42+# Override default flag values for local packages and extra-deps
43+# flags: {}
44+
45+# Extra package databases containing global packages
46+# extra-package-dbs: []
47+
48+# Control whether we use the GHC we find on the path
49+# system-ghc: true
50+#
51+# Require a specific version of stack, using version ranges
52+# require-stack-version: -any # Default
53+# require-stack-version: ">=1.9"
54+#
55+# Override the architecture used by stack, especially useful on Windows
56+# arch: i386
57+# arch: x86_64
58+#
59+# Extra directories used by stack for building
60+# extra-include-dirs: [/path/to/dir]
61+# extra-lib-dirs: [/path/to/dir]
62+#
63+# Allow a newer minor version of GHC than the snapshot specifies
64+# compiler-check: newer-minor
test/stack-simple/test/Spec.hsnew file+2
@@ -0,0 +1,2 @@
1+main :: IO ()
2+main = putStrLn "Test suite not yet implemented"
test/with-packages/default.nix+2−7
@@ -1,15 +1,10 @@
1−{ pkgs
2−, haskell
3−, stdenv
1+{ stdenv, util, mkPkgSet }:
4−, util
5−}:
6
2
7with stdenv.lib;
3with stdenv.lib;
8with util;
4with util;
9
5
10let
6let
11− pkgSet = haskell.mkPkgSet {
7+ pkgSet = mkPkgSet {
12− inherit pkgs;
13 # generated with:
8 # generated with:
14 # cabal new-build
9 # cabal new-build
15 # plan-to-nix dist-newstyle/cache/plan.json > plan.nix
10 # plan-to-nix dist-newstyle/cache/plan.json > plan.nix