on iko/ghcjs-patch-master help sign in
Update cleanSourceWith based on the latest nixpkgs (#401)
06ea6abHamish Mackenzie
lib/call-cabal-project-to-nix.nix+1−1
@@ -1,5 +1,5 @@
1{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib, materialize }@defaults:
1{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib, materialize }@defaults:
2−{ name ? null # optional name for better error messages
2+{ name ? src.name or (baseNameOf src) # optional name for better error messages
3, src
3, src
4, index-state ? null # Hackage index-state, eg. "2019-10-10T00:00:00Z"
4, index-state ? null # Hackage index-state, eg. "2019-10-10T00:00:00Z"
5, index-sha256 ? null # The hash of the truncated hackage index-state
5, index-sha256 ? null # The hash of the truncated hackage index-state
lib/clean-source-with.nix+47−2
@@ -3,7 +3,45 @@
3# It adds a subDir argument in a way that allows descending into a subdirectory
3# It adds a subDir argument in a way that allows descending into a subdirectory
4# to compose with cleaning the source with a filter.
4# to compose with cleaning the source with a filter.
5{ lib }: rec {
5{ lib }: rec {
6+
7+ # Like `builtins.filterSource`, except it will compose with itself,
8+ # allowing you to chain multiple calls together without any
9+ # intermediate copies being put in the nix store.
10+ #
6− cleanSourceWith = { filter ? path: type: true, src, subDir ? "" }:
11+ # lib.cleanSourceWith {
12+ # filter = f;
13+ # src = lib.cleanSourceWith {
14+ # filter = g;
15+ # src = ./.;
16+ # };
17+ # }
18+ # # Succeeds!
19+ #
20+ # builtins.filterSource f (builtins.filterSource g ./.)
21+ # # Fails!
22+ #
23+ # Parameters:
24+ #
25+ # src: A path or cleanSourceWith result to filter and/or rename.
26+ #
27+ # filter: A function (path -> type -> bool)
28+ # Optional with default value: constant true (include everything)
29+ # The function will be combined with the && operator such
30+ # that src.filter is called lazily.
31+ # For implementing a filter, see
32+ # https://nixos.org/nix/manual/#builtin-filterSource
33+ #
34+ # subDir: Descend into a subdirectory in a way that will compose.
35+ # It will be ase if `src = src + "/${subDir}` and filters
36+ # already applied to `src` will be respected.
37+ #
38+ # name: Optional name to use as part of the store path.
39+ # This defaults `src.name` or otherwise `baseNameOf src`.
40+ # We recommend setting `name` whenever `src` is syntactically `./.`.
41+ # Otherwise, you depend on `./.`'s name in the parent directory,
42+ # which can cause inconsistent names, defeating caching.
43+ #
44+ cleanSourceWith = { filter ? _path: _type: true, src, subDir ? "", name ? null }:
7 let
45 let
8 subDir' = if subDir == "" then "" else "/" + subDir;
46 subDir' = if subDir == "" then "" else "/" + subDir;
9 # In case this is mixed with older versions of cleanSourceWith
47 # In case this is mixed with older versions of cleanSourceWith
@@ -22,14 +60,21 @@
22 # Children only if both filters return true
60 # Children only if both filters return true
23 || (lib.strings.hasPrefix (origSrcSubDir + "/") path
61 || (lib.strings.hasPrefix (origSrcSubDir + "/") path
24 && (filter path type && parentFilter path type));
62 && (filter path type && parentFilter path type));
63+ name' = if name != null
64+ then name
65+ else (if isFiltered && src ? name
66+ then src.name
67+ else baseNameOf src)
68+ + (lib.optionalString (origSubDir != "") ("--" + baseNameOf origSubDir));
25 in {
69 in {
26 inherit origSrc origSubDir origSrcSubDir;
70 inherit origSrc origSubDir origSrcSubDir;
27 filter = filter';
71 filter = filter';
28− outPath = (builtins.filterSource filter' origSrc) + origSubDir;
72+ outPath = (builtins.path { filter = filter'; path = origSrc; name = name'; }) + origSubDir;
29 _isLibCleanSourceWithEx = true;
73 _isLibCleanSourceWithEx = true;
30 # It is only safe for older cleanSourceWith to filter this one
74 # It is only safe for older cleanSourceWith to filter this one
31 # if the we are still looking at the root of origSrc
75 # if the we are still looking at the root of origSrc
32 _isLibCleanSourceWith = origSubDir == "";
76 _isLibCleanSourceWith = origSubDir == "";
77+ name = name';
33 };
78 };
34
79
35 pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
80 pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
overlays/haskell.nix+1−2
@@ -412,8 +412,7 @@ self: super: {
412 # separately from the hsPkgs. The advantage is that the you can get the
412 # separately from the hsPkgs. The advantage is that the you can get the
413 # plan-nix without building the project.
413 # plan-nix without building the project.
414 cabalProject' =
414 cabalProject' =
415− { name ? null
416− , ... }@args:
415+ { ... }@args:
417 let plan = importAndFilterProject (callCabalProjectToNix args);
416 let plan = importAndFilterProject (callCabalProjectToNix args);
418 in let pkg-set = mkCabalProjectPkgSet
417 in let pkg-set = mkCabalProjectPkgSet
419 { plan-pkgs = plan.pkgs;
418 { plan-pkgs = plan.pkgs;
test/buildable/default.nix+1−2
@@ -4,7 +4,6 @@ with stdenv.lib;
4
4
5let
5let
6 project = cabalProject' {
6 project = cabalProject' {
7− name = "test-buildable";
8 index-state = "2019-04-30T00:00:00Z";
7 index-state = "2019-04-30T00:00:00Z";
9 src = haskellLib.cleanGit { src = ../..; subDir = "test/buildable"; };
8 src = haskellLib.cleanGit { src = ../..; subDir = "test/buildable"; };
10 modules = [ { packages.buildable-test.flags.exclude-broken = true; } ];
9 modules = [ { packages.buildable-test.flags.exclude-broken = true; } ];
@@ -33,4 +32,4 @@ in recurseIntoAttrs {
33 inherit project packages;
32 inherit project packages;
34 };
33 };
35 };
34 };
36−}
35+}
test/cabal-22/default.nix+1−2
@@ -4,7 +4,6 @@ with stdenv.lib;
4
4
5let
5let
6 project = cabalProject' {
6 project = cabalProject' {
7− name = "cabal-22";
8 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-22"; };
7 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-22"; };
9 };
8 };
10
9
@@ -63,4 +62,4 @@ in recurseIntoAttrs {
63 inherit (packages) project;
62 inherit (packages) project;
64 };
63 };
65 };
64 };
66−}
65+}
test/cabal-simple-prof/default.nix−1
@@ -16,7 +16,6 @@ let
16 ];
16 ];
17
17
18 project = cabalProject' {
18 project = cabalProject' {
19− name = "cabal-simple-prof";
20 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-simple-prof"; };
19 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-simple-prof"; };
21 inherit modules;
20 inherit modules;
22 };
21 };
test/cabal-simple/default.nix−1
@@ -26,7 +26,6 @@ let
26 ];
26 ];
27
27
28 project = cabalProject' {
28 project = cabalProject' {
29− name = "cabal-simple";
30 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-simple"; };
29 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-simple"; };
31 inherit modules;
30 inherit modules;
32 };
31 };
test/cabal-source-repo/default.nix+1−2
@@ -4,7 +4,6 @@ with stdenv.lib;
4
4
5let
5let
6 project = cabalProject' {
6 project = cabalProject' {
7− name = "test-cabal-source-repo";
8 index-state = "2019-04-30T00:00:00Z";
7 index-state = "2019-04-30T00:00:00Z";
9 src = ./.;
8 src = ./.;
10 };
9 };
@@ -32,4 +31,4 @@ in recurseIntoAttrs {
32 inherit pkgSet packages;
31 inherit pkgSet packages;
33 };
32 };
34 };
33 };
35−}
34+}
test/cabal-sublib/default.nix−1
@@ -14,7 +14,6 @@ let
14
14
15 # The ./pkgs.nix works for linux & darwin, but not for windows
15 # The ./pkgs.nix works for linux & darwin, but not for windows
16 project = cabalProject' {
16 project = cabalProject' {
17− name = "cabal-sublib";
18 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-sublib"; };
17 src = haskellLib.cleanGit { src = ../..; subDir = "test/cabal-sublib"; };
19 inherit modules;
18 inherit modules;
20 };
19 };
test/call-cabal-project-to-nix/default.nix+1−2
@@ -6,7 +6,6 @@ let
6 # This test could use cabalProject', but it does so that it
6 # This test could use cabalProject', but it does so that it
7 # tests using callCabalProjectToNix and importAndFilterProject
7 # tests using callCabalProjectToNix and importAndFilterProject
8 plan = (importAndFilterProject (callCabalProjectToNix {
8 plan = (importAndFilterProject (callCabalProjectToNix {
9− name = "test-call-cabal-project-to-nix";
10 index-state = "2019-04-30T00:00:00Z";
9 index-state = "2019-04-30T00:00:00Z";
11 # reuse the cabal-simple test project
10 # reuse the cabal-simple test project
12 src = ../cabal-simple;
11 src = ../cabal-simple;
@@ -39,4 +38,4 @@ in recurseIntoAttrs {
39 inherit pkgSet packages;
38 inherit pkgSet packages;
40 };
39 };
41 };
40 };
42−}
41+}
test/exe-only/default.nix−1
@@ -5,7 +5,6 @@ with stdenv.lib;
5
5
6let
6let
7 project = haskell-nix.cabalProject' {
7 project = haskell-nix.cabalProject' {
8− name = "exe-only";
9 src = ./.;
8 src = ./.;
10 };
9 };
11
10
test/ghc-options/cabal.nix+1−2
@@ -4,7 +4,6 @@ with stdenv.lib;
4
4
5let
5let
6 project = cabalProject' {
6 project = cabalProject' {
7− name = "test-ghc-options";
8 index-state = "2019-04-30T00:00:00Z";
7 index-state = "2019-04-30T00:00:00Z";
9 src = ./.;
8 src = ./.;
10 # TODO find a way to get the ghc-options into plan.json so we can use it in plan-to-nix
9 # TODO find a way to get the ghc-options into plan.json so we can use it in plan-to-nix
@@ -33,4 +32,4 @@ in recurseIntoAttrs {
33 inherit project packages;
32 inherit project packages;
34 };
33 };
35 };
34 };
36−}
35+}
test/project-flags/cabal.nix−1
@@ -4,7 +4,6 @@ with stdenv.lib;
4
4
5let
5let
6 project = cabalProject' {
6 project = cabalProject' {
7− name = "test-project-flags";
8 index-state = "2019-04-30T00:00:00Z";
7 index-state = "2019-04-30T00:00:00Z";
9 src = ./.;
8 src = ./.;
10 };
9 };
test/setup-deps/default.nix−1
@@ -5,7 +5,6 @@ with stdenv.lib;
5
5
6let
6let
7 project = haskell-nix.cabalProject' {
7 project = haskell-nix.cabalProject' {
8− name = "test-setup-deps";
9 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ../..; subDir = "test/setup-deps"; };
8 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ../..; subDir = "test/setup-deps"; };
10 modules = [{
9 modules = [{
11 # Package has no exposed modules which causes
10 # Package has no exposed modules which causes
test/shell-for-setup-deps/default.nix−1
@@ -4,7 +4,6 @@ with stdenv.lib;
4
4
5let
5let
6 project = cabalProject' {
6 project = cabalProject' {
7− name = "test-shell-for-setup-deps";
8 src = ./.;
7 src = ./.;
9 modules = [{
8 modules = [{
10 # Package has no exposed modules which causes
9 # Package has no exposed modules which causes