on iko/ghcjs-patch-master help sign in
Remove `canCleanSource` (#1409)
a385241DavHau
@@ -68,7 +68,11 @@ in rec {
68 ];
68 ];
69 };
69 };
70 check-materialization-concurrency = pkgs.buildPackages.callPackage ./scripts/check-materialization-concurrency/check.nix {};
70 check-materialization-concurrency = pkgs.buildPackages.callPackage ./scripts/check-materialization-concurrency/check.nix {};
71− check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix {};
71+ check-path-support = pkgs.buildPackages.callPackage ./scripts/check-path-support.nix {
72+ # TODO remove this when nixpkgs-2205 is released and used for `pkgs`
73+ # check-path-support fails unless we have nix 2.4 or newer.
74+ inherit (import haskellNix.sources.nixpkgs-unstable {}) nix;
75+ };
72 };
76 };
73
77
74 # These are pure parts of maintainer-script so they can be built by hydra
78 # These are pure parts of maintainer-script so they can be built by hydra
lib/call-stack-to-nix.nix+9−12
@@ -24,15 +24,12 @@ let
24
24
25 subDir' = src.origSubDir or "";
25 subDir' = src.origSubDir or "";
26 subDir = pkgs.lib.strings.removePrefix "/" subDir';
26 subDir = pkgs.lib.strings.removePrefix "/" subDir';
27− maybeCleanedSource =
28− if haskellLib.canCleanSource src
29− then (haskellLib.cleanSourceWith {
27+ cleanedSource = (haskellLib.cleanSourceWith {
30− name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files";
28+ name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files";
31− src = src.origSrc or src;
29+ src = src.origSrc or src;
32− filter = path: type: (!(src ? filter) || src.filter path type) && (
30+ filter = path: type: (!(src ? filter) || src.filter path type) && (
33− type == "directory" ||
31+ type == "directory" ||
34− pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ stackYaml ".cabal" "package.yaml" ]); })
32+ pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ stackYaml ".cabal" "package.yaml" ]); });
35− else src.origSrc or src;
36
33
37 stackToNixArgs = builtins.concatStringsSep " " [
34 stackToNixArgs = builtins.concatStringsSep " " [
38 "--full"
35 "--full"
@@ -59,14 +56,14 @@ let
59 mkdir -p $out${subDir'}
56 mkdir -p $out${subDir'}
60 SRC=$(mktemp -d)
57 SRC=$(mktemp -d)
61 cd $SRC
58 cd $SRC
62− # if maybeCleanedSource is empty, this means it's a new
59+ # if cleanedSource is empty, this means it's a new
63 # project where the files haven't been added to the git
60 # project where the files haven't been added to the git
64 # repo yet. We fail early and provide a useful error
61 # repo yet. We fail early and provide a useful error
65 # message to prevent headaches (#290).
62 # message to prevent headaches (#290).
66− if [ -z "$(ls -A ${maybeCleanedSource})" ]; then
63+ if [ -z "$(ls -A ${cleanedSource})" ]; then
67 echo "cleaned source is empty. Did you forget to 'git add -A'?"; exit 1;
64 echo "cleaned source is empty. Did you forget to 'git add -A'?"; exit 1;
68 fi
65 fi
69− lndir -silent "${maybeCleanedSource}/." $SRC
66+ lndir -silent "${cleanedSource}/." $SRC
70 ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"}
67 ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"}
71 ${
68 ${
72 # If a resolver was fetched use the it instead of the original stack.yaml
69 # If a resolver was fetched use the it instead of the original stack.yaml
lib/clean-cabal-component.nix+2−2
@@ -1,6 +1,6 @@
1# Use cleanSourceWith to filter just the files needed for a particular
1# Use cleanSourceWith to filter just the files needed for a particular
2# component of the package
2# component of the package
3−{ lib, cleanSourceWith, canCleanSource }: package: component: componentName: src:
3+{ lib, cleanSourceWith }: package: component: componentName: src:
4let
4let
5 srcStr' = src.origSrc or null;
5 srcStr' = src.origSrc or null;
6 subDir = if src.origSubDir or "" == ""
6 subDir = if src.origSubDir or "" == ""
@@ -56,7 +56,7 @@ let
56 then p
56 then p
57 else p + "/";
57 else p + "/";
58in
58in
59− if srcStr' == null || package.detailLevel != "FullDetails" || !canCleanSource src
59+ if srcStr' == null || package.detailLevel != "FullDetails"
60 then src
60 then src
61 else
61 else
62 let
62 let
lib/clean-source-with.nix+4−8
@@ -2,7 +2,10 @@
2# https://github.com/NixOS/nixpkgs/blob/1d9d31a0eb8e8358830528538a391df52f6a075a/lib/sources.nix#L41
2# https://github.com/NixOS/nixpkgs/blob/1d9d31a0eb8e8358830528538a391df52f6a075a/lib/sources.nix#L41
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 }:
6+if lib.versionOlder builtins.nixVersion "2.4"
7+then throw "Nix version 2.4 or higher is required for Haskell.nix"
8+else rec {
6
9
7 # Like `builtins.filterSource`, except it will compose with itself,
10 # Like `builtins.filterSource`, except it will compose with itself,
8 # allowing you to chain multiple calls together without any
11 # allowing you to chain multiple calls together without any
@@ -113,11 +116,4 @@
113 _isLibCleanSourceWith = origSubDir == "";
116 _isLibCleanSourceWith = origSubDir == "";
114 name = name';
117 name = name';
115 };
118 };
116−
117− pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
118−
119− canCleanSource = src:
120− src ? _isLibCleanSourceWithEx
121− || src ? _isLibCleanSourceWith
122− || !(pathHasContext (toString src));
123}
119}
lib/default.nix+5−22
@@ -192,11 +192,11 @@ in {
192 collectChecks' = collectChecks (_: true);
192 collectChecks' = collectChecks (_: true);
193
193
194 # Replacement for lib.cleanSourceWith that has a subDir argument.
194 # Replacement for lib.cleanSourceWith that has a subDir argument.
195− inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
195+ inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith;
196
196
197 # Use cleanSourceWith to filter just the files needed for a particular
197 # Use cleanSourceWith to filter just the files needed for a particular
198 # component of a package
198 # component of a package
199− cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith canCleanSource; };
199+ cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith; };
200
200
201 # Clean git directory based on `git ls-files --recurse-submodules`
201 # Clean git directory based on `git ls-files --recurse-submodules`
202 cleanGit = import ./clean-git.nix {
202 cleanGit = import ./clean-git.nix {
@@ -290,26 +290,9 @@ in {
290 if subDir == ""
290 if subDir == ""
291 then src
291 then src
292 else
292 else
293− if haskellLib.canCleanSource src
294− then haskellLib.cleanSourceWith {
293+ haskellLib.cleanSourceWith {
295− inherit src subDir includeSiblings;
294+ inherit src subDir includeSiblings;
296− }
297− else let name = src.name or "source" + "-" + __replaceStrings ["/"] ["-"] subDir;
298− in if includeSiblings
299− then rec {
300− # Keep `src.origSrc` so it can be used to allow references
301− # to other parts of that root.
302− inherit name;
303− origSrc = src.origSrc or src;
304− origSubDir = src.origSubDir or "" + "/" + subDir;
305− outPath = origSrc + origSubDir;
306− }
307− else {
308− # We are not going to need other parts of `origSrc` if there
309− # was one and we can ignore it
310− inherit name;
311− outPath = src + "/" + subDir;
312− };
295+ };
313
296
314 # Givin a `src` split it into a `root` path (based on `src.origSrc` if
297 # Givin a `src` split it into a `root` path (based on `src.origSrc` if
315 # present) and `subDir` (based on `src.origSubDir). The
298 # present) and `subDir` (based on `src.origSubDir). The
lib/import-and-filter-project.nix+5−8
@@ -6,14 +6,11 @@
6let
6let
7 # Full source including possible relative paths form the
7 # Full source including possible relative paths form the
8 # project directory.
8 # project directory.
9− srcRoot =
10− if haskellLib.canCleanSource src
11− then haskellLib.cleanSourceWith {
9+ srcRoot = haskellLib.cleanSourceWith {
12− name = if src ? name then "${src.name}-root" else "source-root";
10+ name = if src ? name then "${src.name}-root" else "source-root";
13− src = src.origSrc or src;
11+ src = src.origSrc or src;
14− filter = src.filter or (_: _: true);
12+ filter = src.filter or (_: _: true);
15− }
13+ };
16− else src.origSrc or src;
17 # The sub directory containing the cabal.project or stack.yaml file
14 # The sub directory containing the cabal.project or stack.yaml file
18 projectSubDir' = src.origSubDir or ""; # With leading /
15 projectSubDir' = src.origSubDir or ""; # With leading /
19 projectSubDir = pkgs.lib.strings.removePrefix "/" projectSubDir'; # Without /
16 projectSubDir = pkgs.lib.strings.removePrefix "/" projectSubDir'; # Without /
lib/stack-cache-generator.nix+14−17
@@ -30,25 +30,22 @@ let
30 }) resolver fetchedResolver;
30 }) resolver fetchedResolver;
31
31
32 # Filter just the stack yaml file and any resolver yaml file it points to.
32 # Filter just the stack yaml file and any resolver yaml file it points to.
33− maybeCleanedSource =
34− if haskellLib.canCleanSource src
35− then haskellLib.cleanSourceWith {
33+ maybeCleanedSource = haskellLib.cleanSourceWith {
36− inherit src;
34+ inherit src;
37− filter = path: type:
35+ filter = path: type:
38− let
36+ let
39− origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src;
37+ origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src;
40− origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else "";
38+ origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else "";
41− relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path;
39+ relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path;
42
40
43− # checks if path1 is a parent directory for path2
41+ # checks if path1 is a parent directory for path2
44− isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2;
42+ isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2;
45
43
46− in
44+ in
47− (relPath == stackYaml)
45+ (relPath == stackYaml)
48− || (resolver != null && (relPath == resolver || isParent relPath resolver))
46+ || (resolver != null && (relPath == resolver || isParent relPath resolver))
49− ;
47+ ;
50− }
48+ };
51− else src;
52
49
53 # All repos served via ssh or git protocols are usually private
50 # All repos served via ssh or git protocols are usually private
54 private = url: pkgs.lib.substring 0 4 url != "http";
51 private = url: pkgs.lib.substring 0 4 url != "http";
overlays/hydra.nix+4
@@ -1,4 +1,8 @@
1{ sources, ...}:
1{ sources, ...}:
2+# This hydra overlay is required to circumvent problems with builtins.path
3+# in restricted eval mode.
4+# This can be removed once hydra in nixpkgs is based on a recent enough nix,
5+# which contains this fix: https://github.com/NixOS/nix/pull/5163
2
6
3final: prev: {
7final: prev: {
4 hydra-unstable = sources.hydra.defaultPackage.${prev.system};
8 hydra-unstable = sources.hydra.defaultPackage.${prev.system};