on iko/ghcjs-patch-master help sign in
Remove `components.all` (#776)

It causes a lot of issues. To make this work: * `shellFor` is updated to use `getAllComponents` instead of `.all`. * `getAllComponents` is updated to work on the package rather than the package config. * Tests updated to not use `.library` or `.exes.X` where appropriate. * Documentation updated. * Out of date examples removed. As a bonus `shellFor` now takes a `components` argument that might be useful for limiting the dependencies of the shell to just the ones needed for the components you intend to work on.

commitb6de6ef3b8ab338504f4961581a4c4fbfdd7ceed authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateTue 21 Jul 2020, 16:06 (6 years ago) parentcacfba0
29 files changed+56−618
builder/comp-builder.nix+3−5 builder/shell-for.nix+14−4 changelog.md+5 docs/reference/library.md+1−4 docs/tutorials/development.md+2−18 examples/Cabal-install-folder.diff−41 examples/cardano-sl-args.nix−150 examples/cardano-sl-mingw32.nix−3 examples/cardano-sl.nix−3 examples/cardano-wallet-args.nix−103 examples/cardano-wallet-ghcjs.nix−39 examples/cardano-wallet-mingw32.nix−3 examples/cardano-wallet-rpi.nix−39 examples/cardano-wallet.nix−3 examples/plutus-args.nix−74 examples/plutus-mingw32.nix−3 examples/plutus.nix−3 lib/default.nix+5−12 modules/package.nix−34 test/cabal-22/default.nix+1−1 test/cabal-hpack/default.nix−9 test/cabal-simple-prof/default.nix−4 test/cabal-simple/default.nix+1−7 test/cabal-sublib/default.nix−9 test/exe-only/default.nix−9 test/extra-hackage/default.nix−4 test/sublib-docs/default.nix−9 test/tests.sh+1−1 test/with-packages/default.nix+23−24
builder/comp-builder.nix+3−5
@@ -65,9 +65,7 @@ let
6565 then builtins.trace ("Cleaning component source not supported for hpack package: " + name) src
6666 else haskellLib.cleanCabalComponent package component src;
6767
68− nameOnly = if haskellLib.isAll componentId
69− then "${package.identifier.name}-all"
70− else "${package.identifier.name}-${componentId.ctype}-${componentId.cname}";
68+ nameOnly = "${package.identifier.name}-${componentId.ctype}-${componentId.cname}";
7169
7270 fullName = "${nameOnly}-${package.identifier.version}";
7371
@@ -293,7 +291,7 @@ let
293291 in ''
294292 runHook preInstall
295293 $SETUP_HS copy ${lib.concatStringsSep " " setupInstallFlags}
296− ${lib.optionalString (haskellLib.isLibrary componentId || haskellLib.isAll componentId) ''
294+ ${lib.optionalString (haskellLib.isLibrary componentId) ''
297295 $SETUP_HS register --gen-pkg-config=${name}.conf
298296 ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
299297 if [ -d "${name}.conf" ]; then
@@ -326,7 +324,7 @@ let
326324 echo "package-id $id" >> $out/envDep
327325 fi
328326 ''}
329− ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
327+ ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId) ''
330328 mkdir -p $out/bin
331329 if [ -f ${testExecutable} ]; then
332330 mkdir -p $(dirname $out/bin/${exeName})
builder/shell-for.nix+14−4
@@ -1,11 +1,20 @@
11{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, compiler }:
22
3−{ packages ? ps:
3+{ # `packages` function selects packages that will be worked on in the shell itself.
4+ # These packages will not be built by `shellFor`, but their
5+ # dependencies will be included in the shell's `ghc-pkg list`.
6+ packages ? ps:
47 let
58 selected = haskellLib.selectLocalPackages ps;
69 in
710 builtins.trace ("Shell for " + toString (builtins.attrNames selected))
811 (builtins.attrValues selected)
12+ # `components` function selects components that will be worked on in the shell itself.
13+ # By default `shellFor` will include the dependencies of all of the components
14+ # in the selected packages. If only as subset of the components will be
15+ # worked on in the shell then we can pass a different `components` function
16+ # to select those.
17+, components ? ps: lib.concatMap haskellLib.getAllComponents (packages hsPkgs)
918, additional ? _: []
1019, withHoogle ? true
1120, exactDeps ? false
@@ -16,8 +25,9 @@ let
1625 # TODO find out why hoogle index creation can be made to work for cross compilers
1726 withHoogle' = withHoogle && !haskellLib.isCrossHost;
1827 selected = packages hsPkgs;
28+ selectedComponents = components hsPkgs;
1929 additionalSelected = additional hsPkgs;
20− selectedConfigs = map (p: p.components.all.config) selected;
30+ selectedConfigs = map (c: c.config) selectedComponents;
2131
2232 name = if lib.length selected == 1
2333 then "ghc-shell-for-${(lib.head selected).identifier.name}"
@@ -45,9 +55,9 @@ let
4555 # Add the system libraries and build tools of the selected haskell
4656 # packages to the shell.
4757 systemInputs = removeSelectedInputs (lib.concatMap
48− (p: p.components.all.buildInputs ++ p.components.all.propagatedBuildInputs) selected);
58+ (c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents);
4959 nativeBuildInputs = removeSelected
50− (lib.concatMap (p: p.components.all.executableToolDepends) selected);
60+ (lib.concatMap (c: c.executableToolDepends) selectedComponents);
5161
5262 # Set up a "dummy" component to use with ghcForComponent.
5363 component = {
changelog.md+5
@@ -1,6 +1,11 @@
11This file contains a summary of changes to Haskell.nix and `nix-tools`
22that will impact users.
33
4+## July 21, 2020
5+* Removed `components.all`, use `symlinkJoin` on components.exes or
6+ `shellFor` if you need a shell.
7+* Added `components` arguemnt to `shellFor`.
8+
49## July 21, 2020
510* Added GHC 8.8.4 and replaced 8.8.3 in tests and as the ghc
611 used to build nix-tools for stack projects.
docs/reference/library.md+1−4
@@ -70,7 +70,6 @@ components = {
7070 exes = { NAME = COMPONENT; };
7171 tests = { NAME = COMPONENT; };
7272 benchmarks = { NAME = COMPONENT; };
73− all = COMPONENT;
7473}
7574```
7675
@@ -80,9 +79,6 @@ In [Haskell.nix][], a _component_ is a derivation corresponding to a
8079[Cabal component](https://www.haskell.org/cabal/users-guide/developing-packages.html)
8180of a package.
8281
83−[Haskell.nix][] also defines a special `all` component, which is the
84−union of all components in the package.
85−
8682## Identifier
8783
8884A package identifier is an attrset pair of `name` and `version`.
@@ -427,6 +423,7 @@ shellFor =
427423| Argument | Type | Description |
428424|----------------|------|---------------------|
429425| `packages` | Function | Package selection function. It takes a list of [Haskell packages](#haskell-package) and returns a subset of these packages. |
426+| `components` | Function | Similar to `packages`, by default all the components of the selected packages are selected. |
430427| `additional` | Function | Similar to `packages`, but the selected packages are built and included in `ghc-pkg list` (not just their dependencies). |
431428| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
432429| `exactDeps` | Boolean | Prevents the Cabal solver from choosing any package dependency other than what are in the package set. |
docs/tutorials/development.md+2−18
@@ -24,25 +24,9 @@ it exists in a file called `default.nix`.
2424 on it. Starting Cabal 3.0 `cabal build` will work out of the box, as
2525 new style builds are the default.
2626
27−## How to get a development shell for a package
27+## How to get a development shell
2828
29−Run a `nix‑shell` on `components.all` of your package. `all` is a
30−synthetic component whose dependencies are the union of the
31−dependencies of all components in the package. Therefore, you will be
32−able to build the test suites because their dependencies will be
33−included.
34−
35−```nix
36−# shell.nix
37−let
38− hsPkgs = import ./default.nix {};
39−in
40− hsPkgs.my-package.components.all
41−```
42−
43−## How to get a development shell for a multi-package project
44−
45−If you have a Cabal or Stack project with multiple packages
29+If you have a Cabal or Stack project with one or more packages
4630(i.e. multiple `.cabal` files, not a single package with multiple
4731components), then you will need a development environment that
4832contains the _dependencies_ of your packages, but not the packages
examples/Cabal-install-folder.diffdeleted−41
@@ -1,41 +0,0 @@
1−diff --git a/Distribution/Simple/GHC.hs b/Distribution/Simple/GHC.hs
2−index 547776046..176e59111 100644
3−--- a/Distribution/Simple/GHC.hs
4−+++ b/Distribution/Simple/GHC.hs
5−@@ -1,6 +1,7 @@
6− {-# LANGUAGE FlexibleContexts #-}
7− {-# LANGUAGE RankNTypes #-}
8− {-# LANGUAGE TupleSections #-}
9−+{-# LANGUAGE LambdaCase #-}
10− {-# LANGUAGE CPP #-}
11−
12− -----------------------------------------------------------------------------
13−@@ -1755,13 +1756,27 @@ installExe verbosity lbi binDir buildPref
14− let exeName' = unUnqualComponentName $ exeName exe
15− exeFileName = exeTargetName (hostPlatform lbi) exe
16− fixedExeBaseName = progprefix ++ exeName' ++ progsuffix
17−- installBinary dest = do
18−+ exePath = buildPref </> exeName' </> exeFileName
19−+ installBinary dest = doesFileExist exePath >>= \case
20−+ True -> do
21− installExecutableFile verbosity
22− (buildPref </> exeName' </> exeFileName)
23− (dest <.> exeExtension (hostPlatform lbi))
24− when (stripExes lbi) $
25− Strip.stripExe verbosity (hostPlatform lbi) (withPrograms lbi)
26− (dest <.> exeExtension (hostPlatform lbi))
27−+ False -> do
28−+ putStrLn "Hello!"
29−+ -- The executable exists but is not a simple file.
30−+ -- Deligate installation to the compiler
31−+ runDbProgram verbosity ghcProgram (withPrograms lbi) $
32−+ [ "--install-executable"
33−+ , buildPref </> exeName' </> exeFileName
34−+ , "-o", dest
35−+ ] ++
36−+ case (stripExes lbi, lookupProgram stripProgram $ withPrograms lbi) of
37−+ (True, Just strip) -> ["-strip-program", programPath strip]
38−+ _ -> []
39− installBinary (binDir </> fixedExeBaseName)
40−
41− -- |Install foreign library for GHC.
examples/cardano-sl-args.nixdeleted−150
@@ -1,150 +0,0 @@
1−let iohk-archive = name: hash: "https://github.com/input-output-hk/${name}/archive/${hash}.tar.gz";
2−in rec {
3− src = builtins.fetchTarball (iohk-archive "cardano-sl" "1a792d7cd0f0c93a0f0c28f66372bce3c3808dbd");
4− pkgs = [
5− "cardano-sl-crypto-test"
6− "cardano-sl-crypto"
7− "cardano-sl-cluster"
8− "cardano-sl-infra"
9− "cardano-sl-infra-test"
10− "cardano-sl-tools"
11− "cardano-sl-tools-post-mortem"
12− "cardano-sl-core"
13− "cardano-sl-core-test"
14− "cardano-sl-util-test"
15− "cardano-sl-util"
16− "cardano-sl-script-runner"
17− "cardano-sl-auxx"
18− "cardano-sl-networking"
19− "cardano-sl-explorer"
20− "cardano-sl-chain-test"
21− "cardano-sl-chain"
22− "cardano-sl-mnemonic"
23− "cardano-sl-generator"
24− "cardano-sl-x509"
25− "cardano-sl-utxo"
26− "cardano-sl-node-ipc"
27− "cardano-wallet"
28− "cardano-sl"
29− "cardano-sl-db-test"
30− "cardano-sl-db"
31− "cardano-sl-faucet"
32− "cardano-sl-binary-test"
33− "cardano-sl-binary"
34− "cardano-sl-node"
35− "cardano-sl-client"
36− ];
37− cache = [
38− { name = "cardano-crypto";
39− url = "https://github.com/input-output-hk/cardano-crypto";
40− rev = "4590efa638397e952a51a8994b5543e4ea3c1ecd";
41− sha256 = "0hl2n3bba5v2j0lmxhs7hs01z3aznh2bwf9cb434icq2g0bl8ms3"; }
42− { name = "haskell-ip";
43− cabal-file = "ip.cabal";
44− url = "https://github.com/andrewthad/haskell-ip";
45− rev = "9bb453139aa82cc973125091800422a523e1eb8f";
46− sha256 = "199mfpbgca7rvwvwk2zsmcpibc0sk0ni7c5zlf4gk3cps8s85gyr"; }
47− { name = "time-units";
48− url = "https://github.com/serokell/time-units.git";
49− rev = "6c3747c1ac794f952de996dd7ba8a2f6d63bf132";
50− sha256 = "0psdr1if0rgnn24698x3583m0603rwd3sd7yb9whj03hskmkwpgs";
51− }
52− { name = "kademlia";
53− url = "https://github.com/serokell/kademlia.git";
54− rev = "7120bb4d28e708acd52dfd61d3dca7914fac7d7f";
55− sha256 = "1k1wp9dwhzzqfivxc28vhxfqplnyh916crr7bhsiv829d6qifhw1";
56− }
57− { name = "network-transport";
58− url = "https://github.com/serokell/network-transport";
59− rev = "018a50b9042c2115c3ec9c9fd5ca5f28737dd29c";
60− sha256 = "0lqa26l2ikpq6a4s7qm9b2favx59w82i0wngakhfyax66fpixp8q";
61− }
62− { name = "network-transport-tcp";
63− url = "https://github.com/avieth/network-transport-tcp";
64− rev = "2634e5e32178bb0456d800d133f8664321daa2ef";
65− sha256 = "03shp9prflhgqzw7pymw1pq2q7s1wf46pyjm2csx8646snrhf35i";
66− }
67− { name = "network-transport-inmemory";
68− url = "https://github.com/avieth/network-transport-inmemory";
69− rev = "5d8ff2b07b9df35cf61329a3d975e2c8cf95c12a";
70− sha256 = "0ak64rks3lk3kk5wyndrrk2swmd84h9diribzix305xwz1jhjj9w";
71− }
72− { name = "acid-state";
73− url = "https://github.com/parsonsmatt/acid-state";
74− rev = "a1b23e2056f134e53f705a694ab85deeecabec5c";
75− sha256 = "0mgdk8252g7wbb0afyn21pcn3bwh4vainy3h2d0xsv4hlpgqgnw8";
76− }
77− { name = "socket-io";
78− url = "https://github.com/input-output-hk/engine.io";
79− rev = "d3c55f51bb81cee7d0d551de930ce65fe7d76756";
80− sha256 = "139c0yfnj57cpwg4k0am2rp35sh959394nvlb98011rjy68200qc";
81− subdir = "socket-io";
82− }
83− { name = "engine-io";
84− url = "https://github.com/input-output-hk/engine.io";
85− rev = "d3c55f51bb81cee7d0d551de930ce65fe7d76756";
86− sha256 = "139c0yfnj57cpwg4k0am2rp35sh959394nvlb98011rjy68200qc";
87− subdir = "engine-io";
88− }
89− { name = "engine-io-wai";
90− url = "https://github.com/input-output-hk/engine.io";
91− rev = "d3c55f51bb81cee7d0d551de930ce65fe7d76756";
92− sha256 = "139c0yfnj57cpwg4k0am2rp35sh959394nvlb98011rjy68200qc";
93− subdir = "engine-io-wai";
94− }
95− { name = "canonical-json";
96− url = "https://github.com/well-typed/canonical-json.git";
97− rev = "ddfe3593b80b5ceb88842bb7a6f2268df75d2c2f";
98− sha256 = "02fzn1xskis1lc1pkz0j92v6ipd89ww0k2p3dvwpm3yap5dpnm7k";
99− }
100− { name = "clock";
101− url = "https://github.com/corsis/clock.git";
102− rev = "ef60bd51a3587a173adf565c33bf2886df6e3842";
103− sha256 = "1r4n9imls483f7wd61fi1jk16z2k7w36gpx798sqidvwbnc831q1";
104− }
105− { name = "rocksdb-haskell-ng";
106− url = "https://github.com/input-output-hk/rocksdb-haskell-ng.git";
107− rev = "49f501a082d745f3b880677220a29cafaa181452";
108− sha256 = "02jvri8ik8jgrxwa6qmh3xcwqvm4s27iv3sxpjpny79nlhlxvfzp";
109− }
110− { name = "log-warper";
111− url = "https://github.com/input-output-hk/log-warper";
112− rev = "5271ab6c33541b8155ca203e714875974ec116be";
113− sha256 = "1h14004a8iwr8nw31pqq6kfdhfsyzzl8a50hrmj2acjqq6mbdl2m";
114− }
115− { name = "universum";
116− url = "https://github.com/input-output-hk/universum";
117− rev = "15f7db758ff5a24b874de2247f6f7a4576562da5";
118− sha256 = "127bs29zpjcc40777dv7figk05gd00b9ja57sp11w440qr5h72hk";
119− }
120− { name = "serokell-util";
121− url = "https://github.com/input-output-hk/serokell-util";
122− rev = "457f1d149c6e238841f283a1faf7bc8fb021b27d";
123− sha256 = "0llbryqna9p03db3ka4933vzf4jw1yxdbsf7cqi2pivsy1vp6kp0";
124− }
125− { name = "inspector";
126− url = "https://github.com/primetype/inspector.git";
127− rev = "c975f4329365f0379c04358138e616fb96fb0b79";
128− sha256 = "12q1v7a8kcw7qi4lws4j3mvxwfkhni6zmp870kmnkgbgwvrax9gs";
129− }
130− ];
131− # This is needed due to some deficiencies in stackage snapshots.
132− # maybe we should make this part of some `stack-default-pkg-def-extras`?
133− # We have similar logic in the snapshots.nix file to deal with this in
134− # snapshots.
135− #
136− # TODO: move this somewhere into stackProject
137− pkg-def-extras = [
138− (hackage: {
139− packages = {
140− "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
141− "process" = (((hackage.process)."1.6.5.0").revisions).default;
142− };
143− })
144− (hackage: {
145− packages = {
146− "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
147− };
148− })
149− ];
150−}
examples/cardano-sl-mingw32.nixdeleted−3
@@ -1,3 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs (nixpkgsArgs // { crossSystem.config = "x86_64-pc-mingw32"; });
3−in (pkgs.haskell-nix.stackProject (import ./cardano-sl-args.nix)).cardano-sl.components.all
examples/cardano-sl.nixdeleted−3
@@ -1,3 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs nixpkgsArgs;
3−in (pkgs.haskell-nix.stackProject (import ./cardano-sl-args.nix)).cardano-sl.components.all
examples/cardano-wallet-args.nixdeleted−103
@@ -1,103 +0,0 @@
1−let iohk-archive = name: hash: "https://github.com/input-output-hk/${name}/archive/${hash}.tar.gz";
2− src = builtins.fetchTarball (iohk-archive "cardano-wallet" "1fbd206bf6b368f08d603db130648ebd4efcedbc");
3− iohkLib = import (src + "/nix/iohk-common.nix") {};
4− jmPkgs = import (src + "/nix/jormungandr.nix") { inherit iohkLib; };
5−
6−in rec {
7− inherit src;
8− pkgs = [
9− "bech32"
10− "text-class"
11− "cardano-wallet-http-bridge"
12− "cardano-wallet-launcher"
13− "cardano-wallet-test-utils"
14− "cardano-wallet-core"
15− "cardano-wallet-jormungandr"
16− "cardano-wallet-cli"
17− "cardano-crypto"
18− "cardano-wallet-core-integration"
19− ];
20− # wee need these, as they are referenced in the stack.yaml file; however we can't
21− # fetch them at IFD time as they don't provide the sha256. Hence we use the cache-file
22− # facility on stack-to-nix and pre-populate the cache file with the relevant hashes.
23− cache = [
24− { name = "cardano-crypto";
25− url = "https://github.com/input-output-hk/cardano-crypto";
26− rev = "3c5db489c71a4d70ee43f5f9b979fcde3c797f2a";
27− sha256 = "0lss4x41m0ylhximqjc56ps0y3pag3x58wm480pzfa48lpk4gqpk"; }
28− { name = "persistent";
29− url = "https://github.com/input-output-hk/persistent";
30− rev = "107787ecc4c8a112375493cd66574f788f950fce";
31− sha256 = "1livmfslqzadir5sc523r111wrd14s5k2nmvsxayk45hx3nnngfb";
32− subdir = "persistent"; }
33− { name = "persistent-sqlite";
34− url = "https://github.com/input-output-hk/persistent";
35− rev = "107787ecc4c8a112375493cd66574f788f950fce";
36− sha256 = "1livmfslqzadir5sc523r111wrd14s5k2nmvsxayk45hx3nnngfb";
37− subdir = "persistent-sqlite"; }
38− { name = "persistent-template";
39− url = "https://github.com/input-output-hk/persistent";
40− rev = "107787ecc4c8a112375493cd66574f788f950fce";
41− sha256 = "1livmfslqzadir5sc523r111wrd14s5k2nmvsxayk45hx3nnngfb";
42− subdir = "persistent-template"; }
43− { name = "iohk-monitoring";
44− url = "https://github.com/input-output-hk/iohk-monitoring-framework";
45− rev = "bd31cd2f3922010ddb76bb869f29c4e63bb8001b";
46− subdir = "iohk-monitoring";
47− sha256 = "1dfk505qbpk6p3gcpxa31wmg98qvx9hlrxlf0khaj7hizf3b8b60"; }
48− { name = "contra-tracer";
49− url = "https://github.com/input-output-hk/iohk-monitoring-framework";
50− rev = "bd31cd2f3922010ddb76bb869f29c4e63bb8001b";
51− subdir = "contra-tracer";
52− sha256 = "1dfk505qbpk6p3gcpxa31wmg98qvx9hlrxlf0khaj7hizf3b8b60"; }
53− ];
54− # This is needed due to some deficiencies in stackage snapshots.
55− # maybe we should make this part of some `stack-default-pkg-def-extras`?
56− # We have similar logic in the snapshots.nix file to deal with this in
57− # snapshots.
58− #
59− # TODO: move this somewhere into stackProject
60− pkg-def-extras = [
61− (hackage: {
62− packages = {
63− "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
64− };
65− })
66− ];
67−
68− modules = [
69− # Add dependencies
70− {
71− packages.cardano-wallet-jormungandr.components.tests = {
72− # Some tests want to write ~/.local/share/cardano-wallet
73− integration.preBuild = "export HOME=`pwd`";
74− # provide jormungandr command to test suites
75− integration.build-tools = [
76− jmPkgs.jormungandr
77− jmPkgs.jormungandr-cli
78− ];
79− unit.build-tools = [ jmPkgs.jormungandr ];
80− };
81−
82− packages.cardano-wallet-core.components.tests.unit.preBuild = ''
83− export SWAGGER_YAML=${src + "/specifications/api/swagger.yaml"}
84− '';
85− }
86−
87− # Misc. build fixes for dependencies
88− {
89− # Cut down iohk-monitoring deps
90− packages.iohk-monitoring.flags = {
91− disable-ekg = true;
92− disable-examples = true;
93− disable-graylog = true;
94− disable-gui = true;
95− disable-prometheus = true;
96− disable-systemd = true;
97− };
98−
99− # Katip has Win32 (>=2.3 && <2.6) constraint
100− packages.katip.doExactConfig = true;
101− }
102− ];
103−}
examples/cardano-wallet-ghcjs.nixdeleted−39
@@ -1,39 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs (nixpkgsArgs // { crossSystem.config = "js-unknown-ghcjs"; });
3− Cabal = pkgs.buildPackages.haskell-nix.hackage-package {
4− name = "Cabal"; version = "2.4.1.0";
5− modules = [
6− { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
7− ];
8−}; in
9−# (haskell-nix.stackProject {
10−# src = ../cardano-wallet;
11−# modules = [
12−# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
13−# ];}).cardano-wallet.components.all
14−(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
15− in let pkg-set = pkgs.haskell-nix.mkStackPkgSet
16− { inherit stack-pkgs;
17− pkg-def-extras = [(hackage: {
18− packages = {
19− "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
20− "process" = (((hackage.process)."1.6.5.0").revisions).default;
21− Win32 = hackage.Win32."2.8.3.0".revisions.default;
22− };
23− })
24− (hackage: {
25− packages = {
26− "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
27− };
28− })];
29− modules = [
30− { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
31− { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
32− { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
33− { doHaddock = false; }
34− ];
35− # ++ (args.modules or [])
36− # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
37− };
38− in pkg-set.config.hsPkgs
39−).cardano-wallet.components.all
examples/cardano-wallet-mingw32.nixdeleted−3
@@ -1,3 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs (nixpkgsArgs // { crossSystem.config = "x86_64-pc-mingw32"; });
3−in (pkgs.haskell-nix.stackProject (import ./cardano-wallet-args.nix)).cardano-wallet.components.all
examples/cardano-wallet-rpi.nixdeleted−39
@@ -1,39 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs (nixpkgsArgs // { crossSystem.config = "armv6l-unknown-linux-gnueabihf"; });
3− Cabal = pkgs.buildPackages.haskell-nix.hackage-package {
4− name = "Cabal"; version = "2.4.1.0";
5− modules = [
6− { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
7− ];
8−}; in
9−# (haskell-nix.stackProject {
10−# src = ../cardano-wallet;
11−# modules = [
12−# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
13−# ];}).cardano-wallet.components.all
14−(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
15− in let pkg-set = pkgs.haskell-nix.mkStackPkgSet
16− { inherit stack-pkgs;
17− pkg-def-extras = [(hackage: {
18− packages = {
19− "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
20− "process" = (((hackage.process)."1.6.5.0").revisions).default;
21− Win32 = hackage.Win32."2.8.3.0".revisions.default;
22− };
23− })
24− (hackage: {
25− packages = {
26− "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
27− };
28− })];
29− modules = [
30− { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
31− { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
32− { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
33− { doHaddock = false; }
34− ];
35− # ++ (args.modules or [])
36− # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
37− };
38− in pkg-set.config.hsPkgs
39−).cardano-wallet.components.all
examples/cardano-wallet.nixdeleted−3
@@ -1,3 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs nixpkgsArgs;
3−in (pkgs.haskell-nix.stackProject (import ./cardano-wallet-args.nix)).cardano-wallet.components.all
examples/plutus-args.nixdeleted−74
@@ -1,74 +0,0 @@
1−let iohk-archive = name: hash: "https://github.com/input-output-hk/${name}/archive/${hash}.tar.gz";
2−in rec {
3− src = builtins.fetchTarball (iohk-archive "plutus" "0d76e98ab267d621ad15002b5f824cad71797754");
4− pkgs = [
5− "language-plutus-core"
6− "plutus-core-interpreter"
7− "plutus-exe"
8− "plutus-ir"
9− "plutus-tx"
10− "plutus-use-cases"
11− "playground-common"
12− "marlowe"
13− "marlowe-playground-server"
14− "plutus-wallet-api"
15− "plutus-playground-server"
16− "plutus-playground-lib"
17− "plutus-tutorial"
18− "plutus-book"
19− "plutus-contract"
20− "plutus-emulator"
21− "deployment-server"
22− "iots-export"
23− "marlowe-symbolic"
24− ];
25− cache = [
26− { name = "row-types";
27− url = "https://github.com/target/row-types";
28− rev = "1e8d5e084ffd46f6c7842826a1f62c60820885df";
29− sha256 = "0ly5m4r8wkm8gdqyrqzsjfmp189yxsd4qp0zi3idrbgfaf45sk9k"; }
30− { name = "purescript-bridge";
31− url = "https://github.com/shmish111/purescript-bridge.git";
32− rev = "0042602f8a195b1fe185138f9ccca02020b8dd62";
33− sha256 = "1vl88g41f4vvgw9iyn7zd7i52qshpnk02z0y6czg4zy7wk3q12gz"; }
34− { name = "servant-purescript";
35− url = "https://github.com/shmish111/servant-purescript.git";
36− rev = "ece5d1dad16a5731ac22040075615803796c7c21";
37− sha256 = "1axcbsaym64q67hvjc7b3izd48cgqwi734l7f7m22jpdc80li5f6"; }
38− { name = "cardano-crypto";
39− url = "https://github.com/input-output-hk/cardano-crypto.git";
40− rev = "f5cecb6e424cc84f85b6a3e1f803517bb7b4cfb1";
41− sha256 = "1jyzai4sn9hi3p6r97h54f9a7an7vk38lwrbl4mds9zmdsw5f5ad"; }
42− { name = "unlit";
43− url = "https://github.com/michaelpj/unlit.git";
44− rev = "9ca1112093c5ffd356fc99c7dafa080e686dd748";
45− sha256 = "145sffn8gbdn6xp9q5b75yd3m46ql5bnc02arzmpfs6wgjslfhff"; }
46− { name = "prometheus";
47− url = "https://github.com/bitnomial/prometheus.git";
48− rev = "69e4cefeb7d04d61a54cb0ae9fd57e2de134badb";
49− sha256 = "0h836qp0ic587gfyfkj9a53p8rczja50sfy2y8ymx8wwkmq9zdgc"; }
50− { name = "github";
51− url = "https://github.com/shmish111/github.git";
52− rev = "cc27b9de4d5d0939235fa9a8b418de3ea4807bab";
53− sha256 = "0jx65x4c8s561nbxa0hv7mp8fvndfhs8i8gzxng7ym808n4n538i"; }
54− ];
55− # This is needed due to some deficiencies in stackage snapshots.
56− # maybe we should make this part of some `stack-default-pkg-def-extras`?
57− # We have similar logic in the snapshots.nix file to deal with this in
58− # snapshots.
59− #
60− # TODO: move this somewhere into stackProject
61− pkg-def-extras = [
62− (hackage: {
63− packages = {
64− "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
65− "process" = (((hackage.process)."1.6.5.0").revisions).default;
66− };
67− })
68− (hackage: {
69− packages = {
70− "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
71− };
72− })
73− ];
74−}
examples/plutus-mingw32.nixdeleted−3
@@ -1,3 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs (nixpkgsArgs // { crossSystem.config = "x86_64-pc-mingw32"; });
3−in (pkgs.haskell-nix.stackProject (import ./plutus-args.nix)).language-plutus-core.components.all
examples/plutus.nixdeleted−3
@@ -1,3 +0,0 @@
1−let inherit (import ../. {}) sources nixpkgsArgs;
2− pkgs = import sources.nixpkgs nixpkgsArgs;
3−in (pkgs.haskell-nix.stackProject (import ./plutus-args.nix)).language-plutus-core.components.all
lib/default.nix+5−12
@@ -52,8 +52,7 @@ in {
5252 tys;
5353 in libComp (subComps z);
5454
55− getAllComponents = foldComponents subComponentTypes (c: acc:
56− lib.optional c.buildable c ++ acc) [];
55+ getAllComponents = foldComponents subComponentTypes (c: acc: [c] ++ acc) [];
5756
5857 componentPrefix = {
5958 sublibs = "lib";
@@ -68,19 +67,16 @@ in {
6867 comps = config.components;
6968 applyLibrary = cname: f { cname = config.package.identifier.name; ctype = "lib"; };
7069 applySubComp = ctype: cname: f { inherit cname; ctype = componentPrefix.${ctype} or (throw "Missing component mapping for ${ctype}."); };
71− applyAllComp = f { cname = config.package.identifier.name; ctype = "all"; };
7270 buildableAttrs = lib.filterAttrs (n: comp: comp.buildable or true);
7371 libComp = if comps.library == null || !(comps.library.buildable or true)
7472 then {}
75− else lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "all" "setup" ]));
73+ else lib.mapAttrs applyLibrary (removeAttrs comps (subComponentTypes ++ [ "setup" ]));
7674 subComps = lib.mapAttrs
7775 (ctype: attrs: lib.mapAttrs (applySubComp ctype) (buildableAttrs attrs))
7876 (builtins.intersectAttrs (lib.genAttrs subComponentTypes (_: null)) comps);
79− allComp = { all = applyAllComp comps.all; };
80− in subComps // libComp // allComp;
77+ in subComps // libComp;
8178
8279 isLibrary = componentId: componentId.ctype == "lib";
83− isAll = componentId: componentId.ctype == "all";
8480 isExe = componentId: componentId.ctype == "exe";
8581 isTest = componentId: componentId.ctype == "test";
8682 isBenchmark = componentId: componentId.ctype == "bench";
@@ -89,8 +85,7 @@ in {
8985 || isTest componentId
9086 || isBenchmark componentId;
9187 mayHaveExecutable = componentId:
92− isExecutableType componentId
93− || isAll componentId;
88+ isExecutableType componentId;
9489
9590 # Was there a reference to the package source in the `cabal.project` or `stack.yaml` file.
9691 # This is used to make the default `packages` list for `shellFor`.
@@ -104,9 +99,7 @@ in {
10499
105100 # Format a componentId as it should appear as a target on the
106101 # command line of the setup script.
107− componentTarget = componentId:
108− if componentId.ctype == "all" then ""
109− else "${componentId.ctype}:${componentId.cname}";
102+ componentTarget = componentId:"${componentId.ctype}:${componentId.cname}";
110103
111104 # Remove null or empty values from an attrset.
112105 optionalHooks = lib.filterAttrs (_: hook: hook != null && hook != "");
modules/package.nix−34
@@ -263,15 +263,6 @@ in {
263263 type = attrsOf componentType;
264264 default = {};
265265 };
266− all = mkOption {
267− type = componentType;
268− apply = all: all // {
269− # TODO: Should this check for the entire component
270− # definition to match, rather than just the identifier?
271− depends = builtins.filter (p: p.identifier != config.package.identifier) all.depends;
272− };
273− description = "The merged dependencies of all other components";
274− };
275266 };
276267
277268 name = mkOption {
@@ -305,29 +296,4 @@ in {
305296 default = [];
306297 };
307298 };
308−
309− # This has one quirk. Manually setting options on the all component
310− # will be considered a conflict. This is almost always fine; most
311− # settings should be modified in either the package options, or an
312− # individual component's options. When this isn't sufficient,
313− # mkForce is a reasonable workaround.
314− #
315− # An alternative solution to mkForce for many of the options where
316− # this is relevant would be to switch from the bool type to
317− # something like an anyBool type, which would merge definitions by
318− # returning true if any is true.
319− config.components.all =
320− let allComps = haskellLib.getAllComponents config;
321− in lib.mkMerge (
322− builtins.map (c:
323− # Exclude attributes that are likely to have conflicting definitions
324− # (a common use case for `all` is in `shellFor` and it only has an
325− # install phase).
326− builtins.removeAttrs c ["preCheck" "postCheck" "keepSource"]
327− ) allComps
328− ) // {
329− # If any one of the components needs us to keep the source
330− # then keep it for the `all` component
331− keepSource = lib.foldl' (x: comp: x || comp.keepSource) false allComps;
332− };
333299}
test/cabal-22/default.nix+1−1
@@ -14,7 +14,7 @@ in recurseIntoAttrs {
1414 ifdInputs = {
1515 inherit (project) plan-nix;
1616 };
17− shell = util.addCabalInstall packages.project.components.all;
17+ shell = util.addCabalInstall packages.project.components.library;
1818 run = stdenv.mkDerivation {
1919 name = "cabal-22-test";
2020
test/cabal-hpack/default.nix−9
@@ -25,10 +25,6 @@ in recurseIntoAttrs {
2525 inherit (project) plan-nix;
2626 };
2727
28− # Used for testing externally with nix-shell (../tests.sh).
29− # This just adds cabal-install to the existing shells.
30− test-shell = util.addCabalInstall packages.cabal-hpack.components.all;
31−
3228 run = stdenv.mkDerivation {
3329 name = "cabal-hpack-test";
3430
@@ -56,11 +52,6 @@ in recurseIntoAttrs {
5652 otool -L $exe |grep .dylib
5753 '')) + ''
5854
59− printf "Checking that \"all\" component has the programs... " >& 2
60− all_exe="${packages.cabal-hpack.components.all}/bin/cabal-hpack${stdenv.hostPlatform.extensions.executable}"
61− test -f "$all_exe"
62− echo "$all_exe" >& 2
63−
6455 touch $out
6556 '';
6657
test/cabal-simple-prof/default.nix−4
@@ -51,10 +51,6 @@ in recurseIntoAttrs {
5151 passthru = {
5252 # Used for debugging with nix repl
5353 inherit project packages;
54−
55− # Used for testing externally with nix-shell (../tests.sh).
56− # This just adds cabal-install to the existing shells.
57− test-shell = util.addCabalInstall packages.cabal-simple.components.all;
5854 };
5955 };
6056}
test/cabal-simple/default.nix+1−7
@@ -26,8 +26,7 @@ in recurseIntoAttrs {
2626 };
2727
2828 # Used for testing externally with nix-shell (../tests.sh).
29− # This just adds cabal-install to the existing shells.
30− test-shell = util.addCabalInstall packages.cabal-simple.components.all;
29+ test-shell = packages.shellFor { tools = { cabal = "3.2.0.0"; }; };
3130
3231 run = stdenv.mkDerivation {
3332 name = "cabal-simple-test";
@@ -56,11 +55,6 @@ in recurseIntoAttrs {
5655 otool -L $exe |grep .dylib
5756 '')) + ''
5857
59− printf "Checking that \"all\" component has the programs... " >& 2
60− all_exe="${packages.cabal-simple.components.all}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}"
61− test -f "$all_exe"
62− echo "$all_exe" >& 2
63−
6458 touch $out
6559 '';
6660
test/cabal-sublib/default.nix−9
@@ -48,11 +48,6 @@ in recurseIntoAttrs {
4848 otool -L $exe |grep .dylib
4949 '') + ''
5050
51− printf "Checking that \"all\" component has the programs... " >& 2
52− all_exe="${packages.cabal-sublib.components.all}/bin/cabal-sublib${stdenv.hostPlatform.extensions.executable}"
53− test -f "$all_exe"
54− echo "$all_exe" >& 2
55−
5651 touch $out
5752 '';
5853
@@ -61,10 +56,6 @@ in recurseIntoAttrs {
6156 passthru = {
6257 # Used for debugging with nix repl
6358 inherit packages;
64−
65− # Used for testing externally with nix-shell (../tests.sh).
66− # This just adds cabal-install to the existing shells.
67− test-shell = util.addCabalInstall packages.cabal-sublib.components.all;
6859 };
6960 };
7061}
test/exe-only/default.nix−9
@@ -41,11 +41,6 @@ in recurseIntoAttrs {
4141 otool -L $exe |grep .dylib
4242 '') + ''
4343
44− printf "Checking that \"all\" component has the programs... " >& 2
45− all_exe="${packages.exe-only.components.all}/bin/exe-only${stdenv.hostPlatform.extensions.executable}"
46− test -f "$all_exe"
47− echo "$all_exe" >& 2
48−
4944 touch $out
5045 '';
5146
@@ -54,10 +49,6 @@ in recurseIntoAttrs {
5449 passthru = {
5550 # Used for debugging with nix repl
5651 inherit packages;
57−
58− # Used for testing externally with nix-shell (../tests.sh).
59− # This just adds cabal-install to the existing shells.
60− test-shell = util.addCabalInstall packages.exe-only.components.all;
6152 };
6253 };
6354}
test/extra-hackage/default.nix−4
@@ -56,10 +56,6 @@ in recurseIntoAttrs {
5656 '' + optionalString stdenv.isDarwin ''
5757 otool -L $exe |grep .dylib
5858 '')) + ''
59− printf "Checking that \"all\" component has the programs... " >& 2
60− all_exe="${packages.external-package-user.components.all}/bin/external-package-user${stdenv.hostPlatform.extensions.executable}"
61− test -f "$all_exe"
62− echo "$all_exe" >& 2
6359 touch $out
6460 '';
6561 meta.platforms = platforms.all;
test/sublib-docs/default.nix−9
@@ -38,11 +38,6 @@ in recurseIntoAttrs {
3838 otool -L $exe |grep .dylib
3939 '') + ''
4040
41− printf "Checking that \"all\" component has the programs... " >& 2
42− all_exe="${packages.sublib-docs.components.all}/bin/sublib-docs${stdenv.hostPlatform.extensions.executable}"
43− test -f "$all_exe"
44− echo "$all_exe" >& 2
45−
4641 # Check that it looks like we have docs
4742 test -f "${packages.sublib-docs.components.library.doc}/share/doc/sublib-docs/html/Lib.html"
4843 test -f "${packages.sublib-docs.components.sublibs.slib.doc}/share/doc/slib/html/Slib.html"
@@ -55,10 +50,6 @@ in recurseIntoAttrs {
5550 passthru = {
5651 # Used for debugging with nix repl
5752 inherit packages;
58−
59− # Used for testing externally with nix-shell (../tests.sh).
60− # This just adds cabal-install to the existing shells.
61− test-shell = util.addCabalInstall packages.sublib-docs.components.all;
6253 };
6354 };
6455}
test/tests.sh+1−1
@@ -129,7 +129,7 @@ echo >& 2
129129printf "*** Checking that package with extra Hackages can be build...\n" >& 2
130130nix build $NIX_BUILD_ARGS --no-link \
131131 -f ./default.nix --argstr compiler-nix-name $GHC \
132− extra-hackage.run.project.hsPkgs.external-package-user.components.all
132+ extra-hackage.run.project.hsPkgs.external-package-user.components.exes.external-package-user
133133echo >& 2
134134
135135printf "\n*** Finished successfully\n" >& 2
test/with-packages/default.nix+23−24
@@ -5,7 +5,7 @@ with util;
55
66let
77 pkgs = import ./pkgs.nix;
8− pkgSet = mkPkgSet {
8+ pkgSet = doExactConfig: mkPkgSet {
99 # generated with:
1010 # cabal new-build
1111 # plan-to-nix -o .
@@ -19,65 +19,64 @@ let
1919
2020 # vary component config for tests
2121 {
22− packages.test-with-packages.components = {
23− all.doExactConfig = mkForce false; # the default; use force because of quirk in all. See package.nix
24− library.doExactConfig = true; # not the default
25− };
22+ packages.test-with-packages.components.library.doExactConfig = doExactConfig;
2623 }
2724 ];
2825 };
2926
30− packages = pkgSet.config.hsPkgs;
27+ packages = doExactConfig: (pkgSet doExactConfig).config.hsPkgs;
3128
32− package = packages.test-with-packages;
33− inherit (package.components) library;
29+ package = doExactConfig: (packages doExactConfig).test-with-packages;
30+
31+ decLibrary = (package true).components.library;
32+ library = (package false).components.library;
3433
3534 pkgId = p: "${p.identifier.name}-${p.identifier.version}";
36− showDepends = component: concatMapStringsSep " " pkgId component.depends;
35+ showDepends = component: concatMapStringsSep " " pkgId (component.depends or []);
3736
3837in recurseIntoAttrs {
3938 # Used for testing externally with nix-shell (../tests.sh).
4039 # This just adds cabal-install to the existing shells.
41− test-shell = addCabalInstall packages.test-with-packages.components.all;
40+ test-shell = addCabalInstall library;
4241
4342 # A variant of test-shell with the component option doExactConfig enabled
44− test-shell-dec = addCabalInstall packages.test-with-packages.components.library;
43+ test-shell-dec = addCabalInstall decLibrary;
4544
4645 run = stdenv.mkDerivation {
4746 name = "with-packages-test";
48− libraryDepends = showDepends pkgSet.config.packages.test-with-packages.components.library;
49− allDepends = showDepends pkgSet.config.packages.test-with-packages.components.all;
47+ decLibraryDepends = showDepends (pkgSet true).config.packages.test-with-packages.components.library;
48+ libraryDepends = showDepends (pkgSet false).config.packages.test-with-packages.components.library;
5049
5150 buildCommand = ''
5251 ########################################################################
5352 # test with-packages
5453
55− printf "checking merging of the 'all' component depends ... " >& 2
56− if [ -n "$libraryDepends" -a "$libraryDepends" = "$allDepends" ]; then
54+ printf "checking component depends ... " >& 2
55+ if [ -n "$decLibraryDepends" -a "$decLibraryDepends" = "$libraryDepends" ]; then
5756 echo "PASS" >& 2
5857 else
5958 echo "FAIL" >& 2
59+ echo "decLibraryDepends = $decLibraryDepends"
6060 echo "libraryDepends = $libraryDepends"
61− echo "allDepends = $allDepends"
6261 exit 1
6362 fi
6463
65− printf "checking that the 'all' component works... " >& 2
66− echo ${package.components.all} >& 2
64+ printf "checking that the 'library' without doExactConfig works... " >& 2
65+ echo ${library} >& 2
6766
68− printf "checking that the 'library' component works... " >& 2
69− echo ${package.components.library} >& 2
67+ printf "checking that the 'library' with doExactConfig works... " >& 2
68+ echo ${decLibrary} >& 2
7069 '' + (if stdenv.hostPlatform.isWindows
7170 then ''
7271 printf "runghc tests are not working yet for windows. skipping. " >& 2
7372 ''
7473 else ''
75− printf "checking that the package env has the dependencies... " >& 2
76− ${package.components.all.env}/bin/${package.components.all.env.targetPrefix}runghc ${./Point.hs}
74+ printf "checking that non doExactConfig liarary.env has the dependencies... " >& 2
75+ ${library.env}/bin/${library.env.targetPrefix}runghc ${./Point.hs}
7776 echo >& 2
7877
79− printf "checking that components.library.env has the dependencies... " >& 2
80− ${library.env}/bin/${library.env.targetPrefix}runghc ${./Point.hs}
78+ printf "checking that doExactConfig library.env has the dependencies... " >& 2
79+ ${decLibrary.env}/bin/${decLibrary.env.targetPrefix}runghc ${./Point.hs}
8180 echo >& 2
8281 '') + ''
8382 touch $out